Pre loader

NumericAxis being Ignored in SciChart ExportToFile

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

Hello,

On our SciChart’s XAxis we are using a NumericAxis and within the NumericAxis we bind to a LabelProvider. In the UI, this works perfectly and we get the XAxis appearing with the titles we desire (as strings writing over the numeric values 0, 1, 2, …). Meanwhile the YAxis doesn’t use any LabelProvider and stays numeric. The XAxis.LabelProvider is an IList of strings.

Although this works great in the UI, when I export the SciChart it does not pick up the LabelProvider and the exported image only contains the numeric values 0, 1, 2, … on the XAxis.

I do the export as following:

SciChartSurfaceBase.ExportToFile(filename, SciChart.Core.ExportType.Png, useXamlRenderSurface, exportedSize);

Is there a way to get the ExportToFile command to acknowledge the LabelProvider is there like it does with the UI?

Thank you!
Hannah

Version
6.2.1.13304
  • You must to post comments
0
0

Hello Hannah,

Sorry for a late reply.
SciChart provides actually two types of exporting to file features:

  • First one when you call ExportToFile() without specifying size, and with ‘useXamlRenderSurface’ equals false. In this case SciChart exports itself as it is on the screen(in other words what you see on the screen the same, with the same size you’ll get in an resulted image).
  • Second(when size parameter is not null or when ‘useXamlRenderSurface’ is ‘true’) is a feature that is using cloning inside. This means that we create a copy(via serialization and deserialization feature) of a real surface and we do different manipulations with that copied surface to achieve size change, and font scale and so on.
    As you’ve mentioned you’re using second approach, and also as you’ve noticed “XAxis.LabelProvider is an IList” and serialization has limitation on serializing properties that are of Interface type.

In this case you can create a custom SciChartSurfaceEX that is derived from SciChartSurface, and override CreateCloneInMemory() method, and do something like this:

public class SciChartSurfaceEx : SciChartSurface
   {
       protected override SciChartSurfaceBase CreateCloneOfSurfaceInMemory(Size newSize)
       {
           //Save your LabelProvider;
           var xAxisLabelProvider = this.XAxis.LabelProvider;
           //Null-your LabelProvider so it's not serialized via default serialization
           this.XAxis.LabelProvider = null;

           //PerformClonning
           var clonedSurface =  (SciChartSurface)base.CreateCloneOfSurfaceInMemory(newSize);
           //reset LabelProvider back to clonedSurface
           clonedSurface.XAxis.LabelProvider = xAxisLabelProvider;

           //return cloned surface                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
           return clonedSurface;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
       }
   }             
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies