beto-rodriguez / LiveCharts2

Simple, flexible, interactive & powerful charts, maps and gauges for .Net, LiveCharts2 can now practically run everywhere Maui, Uno Platform, Blazor-wasm, WPF, WinForms, Xamarin, Avalonia, WinUI, UWP.
https://livecharts.dev
MIT License
4.3k stars 563 forks source link

Cannot visualize on IOS #800

Closed canperk closed 3 weeks ago

canperk commented 1 year ago

Describe the bug When I try to use charts as basic usage. Android works fine but on IOS it shows only an empty space

To Reproduce Steps to reproduce the behavior:

  1. Create MAUI Project.
  2. Add LiveCharts dependency from Nuget
  3. Add sample Line Chart code from LiveCharts sample
  4. Try on IOS

Expected behavior Chart is shown

Screenshots image

Smartphone:

canperk commented 1 year ago

@beto-rodriguez as you mentioned in the issue here I added <AndroidLinkResources>false</AndroidLinkResources> to project file in Property Groups, stil same problem exists.

canperk commented 1 year ago

https://github.com/canperk/LiveChartMAUI_IOS_issue is the reproduced version. A Basic line chart is not able to shown on IOS. YOu can use this as a reference. Maybe I am missing a silly detail. I just followed the Getting Started Stuffs

ScottyLightnin commented 1 year ago

Hi @beto-rodriguez Unfortunately we are also seeing this behavior where a basic line chart does not display on iOS, but works as expected on Android and Windows. We're using dotnet 7 (MAUI), but dropping back to dotnet 6 did not correct the issue. Do you have plans to investigate and resolve this? Kind regards, Scott

frederikspang commented 1 year ago

We're seeing the same issue on iOS. Simplest of charts, static ISeries[], copied from Samples. Just a blank view.

JerryAndersen commented 1 year ago

I experience the same. Windows and Android is working well. iOS is showing blank. What do you other guys do? Trying to fix, found workaround, alternatives or just waiting.

beto-rodriguez commented 1 year ago

This should be fixed soon, will be apriority for the next release.

ScottyLightnin commented 1 year ago

This is such good news, thank you. Without this fix we cannot use LiveCharts2 which saddens me because they are so superior to the alternatives I wish you well for a speedy fix! Kind regards Scott

On Sat, 17 Jun 2023 at 07:13, Alberto Rodríguez @.***> wrote:

This should be fixed soon, will be apriority for the next release.

— Reply to this email directly, view it on GitHub https://github.com/beto-rodriguez/LiveCharts2/issues/800#issuecomment-1595167730, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACLWV7S72PCO6RJDO3B5Y3LXLSV6FANCNFSM6AAAAAASTRFZEM . You are receiving this because you commented.Message ID: @.***>

erdmenchen commented 1 year ago

Same issue here, is there a workaround or an expected time frame for a fix in the near future? Is the problem known and just needs to be implemented? Maybe we can help actively to fix as soon as possible, because this is actually a show stopper currently, if you want to build e.g. a MAUI app for Android and iOS...

erdmenchen commented 1 year ago

I got it working now. I did a lot of changes, so don´t know what fixed the issue... sorry ;-)

beto-rodriguez commented 1 year ago

This should be probably fixed if you update your MAUI/dotnet version, I have seen a lot of issues fixed when I upgraded from net 6.0 to net7.0, anyways I keep investigating this.

ScottyLightnin commented 1 year ago

still broken for us on the latest Maui stable and .net 7.0. Appreciate your investigation.

roja300 commented 1 year ago

Same issue here. Changed nuget version, changed .NET version etc.

Doesn't work.

JerryAndersen commented 1 year ago

I just updated to 2.0.0-beta.810 (from beta 802) and with latest .Net7 I have the same issue. Doesn't work at iOS (16.5.1) but works fine at Android (emulator). @erdmenchen I'm really curious why it is working for you. Can you please provide some versions of what you use? LiveChartsCore.SkiaSharpView.Maui MAUI version Maybe iOS version?

beto-rodriguez commented 1 year ago

After checking this out and setting up my Mac environment again I was able to deploy the sample provided in this repository to an iPad.

I was able to run this repo on iOS, this is the sample provided in this repo I just published it to an iPad without issues:

https://github.com/beto-rodriguez/LiveCharts2/assets/10853349/43fcea1d-83bc-4843-9357-515c33445867

Well, this is the dev branch version (not published to NuGet yet), but is just the MauiSample provided in this repo; In the last days I updated the Maui view of the library to net 7, that fixed some zooming and panning issues for me, I am not sure if this update fixed this issue, I see a couple of options to try to fix this error for your case:

  1. Wait for my next release (this weekend), it will force your dotnet version to be at least net 7.0, I am not sure if something in SkiaSharp or Maui has been improved.

  2. Try to clone this repo (use the dev branch), and deploy the Maui sample to your iOS device, this will give you a clue if the issue is on your development environment, with my current setup it works: dotnet version 7.0.36, visual studio 17.6.5, my iPadOS is on 16.5.1 and my MacOS is Ventura 13.4.1.

beto-rodriguez commented 1 year ago

Update

You can discard option 1, the library is working with the latest NuGet package (beta.810), the following repo is just a really basic app and is working on iOS also:

https://github.com/beto-rodriguez/MauiApp-LiveCharts

https://github.com/beto-rodriguez/LiveCharts2/assets/10853349/15d09fec-cf9e-43fe-a7aa-c38bce184162

Please verify your development environment (dotnet version, visual studio, MacOS) and try to publish https://github.com/beto-rodriguez/MauiApp-LiveCharts to your iOS device again, see the readme file in that repo for more info.

beto-rodriguez commented 1 year ago

Your issue could also be caused by #1063, it will be fixed once there is a stable release of SkiaSharp 2.88.4

JerryAndersen commented 1 year ago

I just cloned your repo and tried your sample and it doesn't work at my environment. It deploys fine but at iOS the view is blank.

I have .NET 7.0.306. VS 17..6.5. IOS 16.5.1. I don't use Mac for now but only iTunes 12.12.9.4 but I guess that can't be the cause. Everything else works fine. What do you think?

beto-rodriguez commented 1 year ago

I don't discard that the issue exists, it is just that we have not found what triggers it, so any feedback would be useful to find this.

Being honest, I don't think that the issue is in this library, we are not doing anything special for the iOS view, we are only using the SkiaSharp view for MAUI, this issue seems out of the scope of this library.

You could also be affected by https://github.com/dotnet/maui/issues/7350. They now removed the verified tag, which probably means that it is not happening on the latest version. I have not test this again, but in the past, I was able to reproduce the issue and gave them feedback on the issue I found.

beto-rodriguez commented 1 year ago

I just published beta.860, this version removes the support for the XAML designer (which just noticed is not actually supported on MAUI), please let me know if that fixed the issue.

JerryAndersen commented 1 year ago

I just published beta.860, this version removes the support for the XAML designer (which just noticed is not actually supported on MAUI), please let me know if that fixed the issue.

I just tried 860 and unfortunately it didn't fix the issue.

concer22 commented 1 year ago

I had the same problem. The only way i could fix it on iOS (for now) is to add HorizontalOptions = FillAndExpand + VerticalOptions = FillAndExpand on the chart object in xaml. Hope this comment helps someone avoiding hours of debugging!

ScottyLightnin commented 1 year ago

Thanks for your feedback @concer22. Sadly we tried that but for us the issue remains. Latest Preview of VS, on .Net 7, using:

Works great in Windows and Android, but just a blank chart on iOS

concer22 commented 1 year ago

Ok weird, same specs here and it works. Maybe if i post the whole code you can get it to work for you. It seems the chart is very sensitive for properties being there or not that can influence the height/width. The wrong property there means an invisible chart on iOS. (works fine in android)

<lvc:CartesianChart ZIndex="10" HorizontalOptions="FillAndExpand" VerticalOptions="Start" HeightRequest="550" x:Name="lineChart" TooltipPosition="Top" TooltipTextSize="10" LegendTextSize="10" Series="{Binding Series}" XAxes="{Binding XAxes}" YAxes="{Binding YAxes}"> </lvc:CartesianChart>

        `SeriesValue = new ObservableCollection<ISeries>
                {
                    new LineSeries<ObservableValue>
                    {
                        Values = ChartDataValue.Select(x => new ObservableValue((double)x.Value)),
                        Stroke = new SolidColorPaint(SKColor.Parse("#95C11F"), 3),
                        Fill = new SolidColorPaint(SKColor.Parse("#95C11F").WithAlpha(0x40)),
                        DataLabelsSize = 8,
                        DataLabelsPaint = new SolidColorPaint(SKColor.Parse("#000")),
                        GeometrySize = 6,
                        GeometryStroke = new SolidColorPaint(SKColor.Parse("#95C11F")),
                        GeometryFill = new SolidColorPaint(SKColor.Parse("#000").WithAlpha(0x80)),
                        DataLabelsPosition = LiveChartsCore.Measure.DataLabelsPosition.Top,

                    }
                };

                XAxesValue = new ObservableCollection<Axis>
                {
                    new Axis
                    {
                        Labels = ChartDataValue.Select(x => x.Label).ToArray(),
                        Labeler = (value) => value.ToString(),
                        TextSize=10,
                        MinStep = 1,
                        ForceStepToMin = true,
                        ShowSeparatorLines = true,
                        LabelsRotation = 70,
                        Padding = new LiveChartsCore.Drawing.Padding(0,10,5,10),
                        UnitWidth = SelectedStatisticType == StatisticTypeEnum.DAY ? TimeSpan.FromHours(1).Ticks : TimeSpan.FromDays(1).Ticks,
                    }
                };

                YAxesValue = new ObservableCollection<Axis>
                {
                    new Axis
                    {
                        TextSize=12,
                        MinLimit = 0
                    }
                };`
ScottyLightnin commented 1 year ago

ok finally an update and some good news. Our charts on iOS started working! For us, it took building and deploying from a Mac first, rather than from our main Windows dev boxes. @beto-rodriguez I don't know if this gives you a hint as to what could be wrong, or helps with your reproduction steps. But for us, this is great news as we're able to go ahead and use LiveCharts2 in our production apps.

beto-rodriguez commented 1 year ago

@ScottyLightnin Those are good news! thanks for the feedback, I will try to find the issue, at least now we know a workaround.

JerryAndersen commented 1 year ago

@ScottyLightnin that is very cool with a workaround. Just to be sure - is it a correct assumption that you use VS for Mac to build and deploy? So no Windows at all in this case. If that is the case I assume you haven't tried the "hybrid" with Windows VS and bridge remote mac.

ScottyLightnin commented 1 year ago

@ScottyLightnin that is very cool with a workaround. Just to be sure - is it a correct assumption that you use VS for Mac to build and deploy? So no Windows at all in this case. If that is the case I assume you haven't tried the "hybrid" with Windows VS and bridge remote mac.

Windows VS with Mac remote bridge also works for us. The only failure was deploying direct to local iOS from windows.

erdmenchen commented 1 year ago

I saw this issue with SkiaSharp based libraries multiple times recently, e.g. https://github.com/Mapsui/Mapsui/issues/1872#issuecomment-1573342107

Here is an original SkiaSharp issue about the same problem:
https://github.com/mono/SkiaSharp/issues/2410

Limitation of HotReload:

Static iOS libraries and frameworks aren't supported and you may see runtime errors or crashes if your app attempts to load these.

see https://learn.microsoft.com/en-us/dotnet/maui/ios/hot-restart#limitations

Solution: Do not directly connect your iOS devices to your Windows dev machine but use a Mac remote bridge...

sencagri commented 1 year ago

I saw this issue with SkiaSharp based libraries multiple times recently, e.g. Mapsui/Mapsui#1872 (comment)

Here is an original SkiaSharp issue about the same problem: mono/SkiaSharp#2410

Limitation of HotReload:

Static iOS libraries and frameworks aren't supported and you may see runtime errors or crashes if your app attempts to load these.

see https://learn.microsoft.com/en-us/dotnet/maui/ios/hot-restart#limitations

Solution: Do not directly connect your iOS devices to your Windows dev machine but use a Mac remote bridge...

Is this mean it will work when we publish it?

beto-rodriguez commented 3 weeks ago

I will close this issue since it seems that it does not belongs to this library, luckily there are workarounds for this.