Knowledgebase: Export to Bitmap
Exporting chart with legend to bitmap
Posted by Admin - on 21 March 2014 11:20 AM

As you probably now SciChart have such feature as showing legend. To do this you need to add LegendModifier to your chart and add SciChartLegend control which shows legend information. This approach has one disadvantage – because SciChartSurface and SciChartLegend are separated control you can’t save them to same bitmap. The most obvious way to omit this problems is to create some panel such as Grid, place chart and legend there and save to bitmap screenshot of that panel.

We want to show you another get to get the same result without significant changes to your application. To do it we will use CustomAnnotation. We’ll place legend there so when we’ll try to save chart to bitmap we save also legend.

<visuals:SciChartSurface Name="surface" visuals:ThemeManager.Theme="ExpressionLight">


        <visuals:FastLineRenderableSeries SeriesColor="#279B27" />

        <visuals:FastLineRenderableSeries SeriesColor="#FF1919" />

        <visuals:FastLineRenderableSeries SeriesColor="#1964FF" />



        <visuals:NumericAxis />



        <visuals:NumericAxis />




            <visuals:LegendModifier x:Name="legendModifier" GetLegendDataFor="AllSeries" />




    <!--  Annotation with Legend  -->


        <visuals:CustomAnnotation X1="0" Y1="300">



                    <visuals:SciChartLegend x:Name="legendControl"


                                    LegendData="{Binding LegendData,


                                                         Mode=OneWay}" />









Results of saving chart with annotation to bitmap

NOTE: During axis interactions when you’re changing axis VisibleRange annotation can move because it uses X and Y data coordinates not pixel coordinates. So when you’re using this approach you should update coordinate of annotation when changing VisibleRange of axis. To do this you can use value converter which bind X1 coordinate to min of x axis visible range and the same for Y1 coordinate or you can use HitTest API to update annotation position.



(2 vote(s))
Not helpful


Not sure where to start? Contact us, we are happy to help!


SciChart Ltd, 16 Beaufort Court, Admirals Way, Docklands, London, E14 9XL. Email: Legal Company Number: 07430048, VAT Number: 101957725