0

I am trying to save my plotly.Net chart to a jpg but when I try to do that there is no error but the code keeps running forever when it comes to the line maps.SaveJpg(path).
Can any please help thanks?

using Plotly.NET;
using Plotly.NET.ImageExport;

namespace Reports
{
    public class picture
    {

        public static void map()
        {
            string[] y = new string[] { "2.0", "1.5", "5.0", "1.5", "3.0", "5.0" };
            string[] x = new string[] { "Belarus", "Moldova", "Lithuania", "Russia", "Romania", "India" };
            
            var maps = ChartMap.Chart.ChoroplethMap<string, string>(locations: x, y, LocationMode: StyleParam.LocationFormat.CountryNames);
            maps.Show();
            string path = @"C:\Users\axx\Documents\Sucess";
            maps.SaveJPG(path);
            
        }
    
        public static void Main(string[] args)
        {
            map();
        }
    }
}

1 Answers1

0

I had exactly the same issue, when I called ToBase64PNGString it just never returned and didn't throw an exception.

The place the code is being called from is within an async block, and when I changed to calling the Async version instead I then got the exception ok. The exception I was getting was DLL load errors. Turned out that PuppeteerSharp was looking for different versions of some MS DLLs. Once I'd sorted out the binding redirects it was ok.

The key here was being able to catch the exceptions. There was something funky going on in my app which meant the exceptions got lost until I changed to the Async version.

Andy
  • 307
  • 4
  • 13
  • I have tried this but not able to trap any error. I took the code within aync block and used it directly in my code but still no error. It gets stuck at that async command. (which is a PuppeteerSharp line). How do I go further from here. – pal2ie Sep 01 '23 at 09:24