I need to export a load of images from one graph. Export from the View is very long. So, I’ve implemented the export in memory like in this example:
https://support.scichart.com/index.php?/Knowledgebase/Article/View/17213/34/rendering-chart-to-bitmap-in-memory
Export is fast and flexible. One of my axes has a custom label provider, but I see a default axis labels after export. Export from View gives correct label values. Here is the code of the label provider:
public class MyCustomLabelProvider: NumericLabelProvider
{
public override string FormatLabel(IComparable dataValue)
{
return string.Format("{0:" + this.ParentAxis.TextFormatting + "}", 1 / (double)dataValue);
}
public override string FormatCursorLabel(IComparable dataValue)
{
return string.Format("{0:" + this.ParentAxis.TextFormatting + "}", 1 / (double)dataValue);
}
}
And a code of export:
var sciChartSurface = new SciChartSurface();
ThemeManager.SetTheme(sciChartSurface, "BrightSpark");
sciChartSurface.YAxes = new AxisCollection()
{
new NumericAxis()
{
AxisAlignment = AxisAlignment.Left,
VisibleRangeLimitMode = RangeClipMode.MinMax,
LabelProvider = new MyCustomLabelProvider(),
DrawMajorGridLines = false,
DrawMinorGridLines = false,
DrawMajorBands = false,
}
};
sciChartSurface.XAxes = new AxisCollection()
{
new NumericAxis()
{
AxisAlignment = AxisAlignment.Bottom,
LabelProvider = new CurvatureLabelProvider(),
VisibleRangeLimitMode = RangeClipMode.MinMax,
DrawMajorGridLines = false,
DrawMinorGridLines = false,
DrawMajorBands = false
}
};
sciChartSurface.RenderableSeries = new ObservableCollection<IRenderableSeries>()
{
new FastLineRenderableSeries() { DataSeries = lineSeries, Stroke = Colors.Green }
};
...
sciChartSurface.XAxes.FirstOrDefault().VisibleRange = new DoubleRange(0, 100);
sciChartSurface.ExportToFile(Path.Combine(folderPath, $"Object.png"), ExportType.Png, false, new Size(1500, 750));
Any suggestions?
- You must login to post comments
Any help? It is an urgent task for me.
I’ve attached a test project to demonstrate it
- Alexander Erkabaev answered 5 years ago
- You must login to post comments
I am considering applying server-side licensing for my javerScript application.
In the document below, there is a phrase “Our server-side licensing component is written in C++.”
(https://support.scichart.com/index.php?/Knowledgebase/Article/View/17256/42/)
However, there is only asp.net sample code on the provided github.
(https://github.com/ABTSoftware/SciChart.JS.Examples/tree/master/Sandbox/demo-dotnet-server-licensing)
I wonder if there is a sample code implemented in C++ for server-side licensing.
Can you provide c++ sample code?
Also, are there any examples to run on Ubuntu?
- Oleksandr Shvets answered 5 years ago
-
Hi, thanks for your reply, but it throws an exception “An error occurred when using serialization to clone a chart for export to file. Please check the inner exception for details.” on CreateCloneOfSurfaceInMemory
- You must login to post comments
I had this issue, but Alexander’s suggestion works fine in SciChart 6.
I created a new UserControl and changed the parent class to SciChartSurface. Then it’s easy to re-apply the label providers automatically:
protected override SciChartSurfaceBase CreateCloneOfSurfaceInMemory(System.Windows.Size newSize)
{
var clonedSurface = (SciChartSurface)base.CreateCloneOfSurfaceInMemory(newSize);
if (XAxes != null)
{
int numAxis = clonedSurface.XAxes.Count;
if (numAxis == XAxes.Count)
{
for (int i = 0; i < numAxis; i++)
{
clonedSurface.XAxes[i].LabelProvider = XAxes[i].LabelProvider;
}
}
}
if (YAxes != null)
{
int numAxis = clonedSurface.YAxes.Count;
if (numAxis == YAxes.Count)
{
for (int i = 0; i < numAxis; i++)
{
clonedSurface.YAxes[i].LabelProvider = YAxes[i].LabelProvider;
}
}
}
return clonedSurface;
}
- Patrik Adolfsson answered 4 years ago
- You must login to post comments
Please login first to submit.