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
- Hannah Pate asked 4 years ago
- You must login to post comments
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;
}
}
- Nazariy Pelyushkevych answered 4 years ago
- You must login to post comments
Please login first to submit.