This is a migrated thread and some comments may be shown as answers.

Chart rendered event

1 Answer 88 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Eduan Marais
Top achievements
Rank 2
Eduan Marais asked on 04 May 2011, 03:18 PM
When exporting a chart, I first create a print friendly chart (a new instance of RadChart) where the legend, title, etc differs from the on-screen chart. The print friendly chart is then shown in a hidden window with a DocumentViewer. Should the chart be exported or saved before the print friendly chart is fully rendered, the saved bitmap is incorrect and incomplete. How can one determine that a RadChart has been completely rendered? Is there an event to which an event handler can be hooked?  

1 Answer, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 09 May 2011, 03:13 PM
Hi Eduan,

You can handle the Loaded event of the MainWindow and then by using the Dispatcher.BeginInvoke()  method you can export the Chart as .png image. The Dispatcher's method will be called as soon as the Chart is drawn. The following code snippet demonstrates this:

public partial class MainWindow : Window
    {
        string imageName = "image.png";
        public MainWindow()
        {
            InitializeComponent();
            int[] dataArray = new int[] { 12, 56, 23, 89, 12, 56, 34, 78, 32, 56 };
            RadChart1.DefaultView.ChartArea.EnableAnimations = false;
            RadChart1.ItemsSource = dataArray;
        }
  
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            ExportChart();
        }
  
        public void ExportChart()
        {
            Dispatcher.BeginInvoke((Action)(() => { ExportChart(); }), DispatcherPriority.Background);
            RadChart1.Save(imageName, 128, 128, new PngBitmapEncoder());
        }
    }

Note that the animations of the ChartArea are disabled.

Kind regards,
Evgenia
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Eduan Marais
Top achievements
Rank 2
Answers by
Evgenia
Telerik team
Share this question
or