Muhammad Umar
Muhammad Umar

Reputation: 1467

LiveCharts: How to convert chart to image using Windows Forms

I want to export LiveChart chart to image using WinForms. What I found till now is only WPF related stuff. https://github.com/beto-rodriguez/Live-Charts/issues/243

Any help regarding WindowsForms will be much appreciated. Thanks

Upvotes: 0

Views: 3174

Answers (3)

jayesh
jayesh

Reputation: 11

You can save your code using DrawtoBitmap method but to apply margin and padding add your livechart control to panel and save panel using DrawtoBitmap method.

var chart = panel1;

using (var bmp = new Bitmap(chart.Width, chart.Height))
{
    chart.DrawToBitmap(bmp, new Rectangle(0, 0, chart.Width, chart.Height));
    bmp.Save("screenshotchart1.png");
}

Upvotes: 1

Gonzo345
Gonzo345

Reputation: 1333

As Documentation says, have you tried the RenderTargetBitMapClass?

Upvotes: 0

Manikandan Sekar
Manikandan Sekar

Reputation: 83

Did u tried the Chart.SaveImage() method?

try the following code

this.chart1.SaveImage("C:\\mycode\\mychart.png", ChartImageFormat.Png);

Upvotes: 0

Related Questions