SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
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
Hello Hannah,
Sorry for a late reply.
SciChart provides actually two types of exporting to file features:
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;
}
}
Please login first to submit.