简体   繁体   中英

Server-side rendering with Highcharts in C#

I want to add highchart on Doc report on a web API based Angularjs (ASP.NET MVC 5) application. Everything related to the chart needs to be done on C#. I have used http://export.highcharts.com/ .I have tried possible solution from this C# Server Side rendering suggested tutorial but the final image is invalid. My code is below.

string outputFile = System.Web.HttpContext.Current.Server.MapPath("image.jpg");
var settings = new HighchartsSetting
{
  ExportImageType = "jpg",
  ImageWidth = 800,
  ServerAddress = "http://export.highcharts.com/"
};

var client = new HighchartsClient(settings);
var options = new
{
  xAxis = new
  {
    categories = new[] { "Jan", "Feb", "Mar" }
  },
  series = new[]
  {
    new { data = new[] {29.9, 71.5, 106.4} }
  }
};

var res = await client.GetChartImageFromOptionsAsync(JsonConvert.SerializeObject(options));
System.IO.File.WriteAllBytes(outputFile, res);

Is there any others way or any solution?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM