Home
Options

Saving a chart with a title

I'm using some sample code I found in LINQPad's tutorials for generating a chart, and it works great. But now I want to save that chart to a JPG image. I'm using the following code, and what I cannot figure out is how to get the title in the actual image?

// display the chart
var winChart = payroll.Take(10).Chart(x => $"{x.ClientId}-{x.ClientLegalName}\\n{x.YTDPayroll.Trim()}", y => y.YTDPayroll, Util.SeriesType.Column).ToWindowsChart();
winChart.Titles.Add("Top 10 Clients YTD Payroll");
winChart.Dump();

// save the chart as an image... but it's missing the title, and cannot figure out how to add it
var winChartImage = payroll.Take(10).Chart(x => $"{x.ClientId}-{x.ClientLegalName}\\n{x.YTDPayroll.Trim()}", y => y.YTDPayroll, Util.SeriesType.Column).ToBitmap(1920,1080);
winChartImage.Save(@C:\hold\LINQPad CHarts\YTD_Top5_Payroll.jpg, System.Drawing.Imaging.ImageFormat.Jpeg);
Sign In or Register to comment.