SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components


I’m trying to make sure I can get the full extents of the image before converting to something is useful for inclusion in a report; however, when I run the following code the image is not showing the entire zoomed out chart. The chart is however zoomed out when this function is complete.

Dispatcher.Invoke(() => CrosslineGraph.DoseChart.ZoomExtents());           
        BitmapSource bitmap = CrosslineGraph.DoseChart.ExportToBitmapSource();
        byte[] bytes;

        using (MemoryStream stream = new MemoryStream())
            BitmapEncoder encoder = new PngBitmapEncoder();
            bytes = stream.ToArray();
  • You must to post comments
Best Answer

Because you’re exporting you will need to set SciChartSurface.RenderPriority=Immediate when changing your properties so that the chart will draw immediately, before export.

I would suggest something like this

    sciChartSurface.RenderPriority = RenderPriority.Immediate;
    var bitmap = sciChartSurface.ExportToBitmapSource();
    sciChartSurface.RenderPriority = RenderPriority.Normal;

Be advised, RenderPriority.Immediate means ‘redraw on anything changed, properties, styles, data’ and will make your application extremely slow if you forget to set it back to Normal.

  • Chris Kirkman
    I have more than one chart in my UI, and they are on separate tabs. As soon as I call .ExportToBitmapSource() for one of the charts that is not shown (it’s tab is not selected) an exception is thrown… UIElement.Measure(availableSize) cannot be called with NaN size. Is there a way around this?
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.