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.39k stars 574 forks source link

Unable to instantiate SKGeoMap #1499

Closed mjanulaitis closed 2 months ago

mjanulaitis commented 7 months ago

The bug I have a background WPF process that generates images for email notifications and scheduled reports. Currently I am able to generate line, bar, pie and stacked charts however when I try to create an SKGeoMap to create the chart so I can then call the SaveImage method and error is thrown.

To Reproduce Steps to reproduce the behavior:

  1. Instantiate the following class:

    public class GeoMapChartControlEx
    {
        private ObservableCollection<HeatLandSeries> SeriesCollection { get; set; } = new();
    
        private readonly SKGeoMap chartCtrl = new();
    
        public GeoMapChartControlEx()
        {
            chartCtrl.Series = SeriesCollection;
        }
    
        public void SaveImage(ChartModel m, string outputFileName)
        {
            try
            {
                chartCtrl.Width = m.ChartOptionsModel.Width;
                chartCtrl.Height = m.ChartOptionsModel.Height;
    
                chartCtrl.CreateChart(m, SeriesCollection);
                chartCtrl.SaveImage(outputFileName);
            }
            catch (Exception ex)
            {
                MainViewModel.Instance.Log(ex);
            }
        }
    }
  2. The following error is thrown: There is no a ChartEngine registered.

Expected behavior The ChartEngine should registered and the class successfully instantiated.

Desktop (please complete the following information):

beto-rodriguez commented 2 months ago

Hi and thanks for the report, this is fixes with the referenced commit and will be included since rc3 version. Thanks again!

cornerbowlsoftware commented 2 months ago

@beto-rodriguez Thanks for all your work on this project. The graphing is great. I used to write my own real-time graphing solutions using C++, Java then later C# but didn't have the time to mess with a solution for the projects I have been working on the last 6 years. I am in the process of porting my WPF app to Avalonia for use on RHEL, Ubuntu and CentOS and your live charts code integrated flawlessly. I will get this added to my project in the coming weeks.