Plotly.Net图像导出



我正在尝试保存我的绘图。Net图表转换为jpg,但当我尝试这样做时,没有错误,但当涉及到线条图时,代码会永远运行。保存Jpg(路径(
有人能帮忙吗,谢谢?

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:UsersaxxDocumentsSucess";
maps.SaveJPG(path);

}

public static void Main(string[] args)
{
map();
}
}
}

我遇到了完全相同的问题,当我调用ToBase64PNGString时,它从未返回,也没有抛出异常。

代码的调用位置在异步块中,当我改为调用异步版本时,我得到了正常的异常。我得到的异常是DLL加载错误。原来PuppeteerSharp正在寻找一些MS DLL的不同版本。一旦我整理了绑定重定向,它就可以了。

这里的关键是能够捕捉到异常。我的应用程序中发生了一些奇怪的事情,这意味着在我改用异步版本之前,异常都会丢失。

可能是找不到用于渲染的浏览器路径。使用此设置可以设置浏览器的路径。这可能会解决这个问题。

Plotly.NET.ImageExport.PuppeterSharpRendererOptions.localBrowserExecutablePath="your/path/here/";

最新更新