exporting pie chart to image is blank

1 Answer 10 Views
ChartView
dd
Top achievements
Rank 1
dd asked on 18 Apr 2024, 07:06 PM

This code produces a blank image. Am I missing something?


var radChartView1 = new RadChartView();
radChartView1.AreaType = ChartAreaType.Pie;
PieSeries series = new PieSeries();
series.DataPoints.Add(new PieDataPoint(50, "Germany"));
series.DataPoints.Add(new PieDataPoint(70, "United States"));
series.DataPoints.Add(new PieDataPoint(40, "France"));
series.DataPoints.Add(new PieDataPoint(25, "United Kingdom") { Label = "My Label" });
series.ShowLabels = true;
series.DrawLinesToLabels = true;
series.SyncLinesToLabelsColor = true;
radChartView1.ShowSmartLabels = true;
radChartView1.Series.Add(series);
flowLayoutPanel1.Controls.Add(radChartView1);
radChartView1.ChartElement.UpdateLayout();
var name5 = Path.Combine(_outputBasePath, "data05.png");
ThemeResolutionService.AllowAnimations = false;
radChartView1.ExportToImage(name5, radChartView1.Size, ImageFormat.Png);

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 23 Apr 2024, 09:13 AM

Hello, David,

Thank you for the provided code snippet.

In order to export RadChartView in such a manner (right after the chart is initialized and data added) you should force loading the element's tree that builds the control by calling the RadChartView.LoadElementTree() method. This is good to happen just before series initialization. Thus, you can ensure the chart control is loaded, and then export to image.

Another possible approach is to use a Timer object, set its interval to 500 ms, and export the chart in its Tick event. You can also, export on a button.Click event. Feel free to use this approach which is most suitable for you. 

I hope this information helps. If you have other questions, please let me know.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

A brand new ThemeBuilder course was just added to the Virtual Classroom. The training course was designed to help you get started with ThemeBuilder for styling Telerik and Kendo UI components for your applications. You can check it out at https://learn.telerik.com
Tags
ChartView
Asked by
dd
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or