ASP.NET Core: View: <input type="button" value="PNG" onclick="chartPng()" /> function chartPng(sender) { var chart = $("#container").ejChart("instance"), exporting = chart.model.exportSettings; exporting.fileName = "chart"; exporting.angle = 0; exporting.action = "Home/ExportChart"; type = "png"; exporting.mode = "server"; chart.export(); } Controller: static string path = "E:\\"; public void ExportChart(string Data, string ChartModel) { ChartProperties obj = ConvertChartObject(ChartModel); string type = obj.ExportSettings.Type.ToString().ToLower(); string fileName = obj.ExportSettings.FileName; string orientation = obj.ExportSettings.Orientation.ToString(); Data = Data.Remove(0, Data.IndexOf(',') + 1); MemoryStream stream = new MemoryStream(Convert.FromBase64String(Data)); using (FileStream fs = new FileStream(path + "CoreChart.png", FileMode.Create)) { using (BinaryWriter bw = new BinaryWriter(fs)) { byte[] data = Convert.FromBase64String(Data); bw.Write(data); bw.Dispose(); } } } |