Pre loader

LabelProvider is not taken into account in SciChartSurface.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

1
0

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?

Version
5.3
  • You must to post comments
0
0

Any help? It is an urgent task for me.

I’ve attached a test project to demonstrate it

Attachments
  • You must to post comments
0
1

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?

  • Alexander Erkabaev
    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 to post comments
0
0

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;
    }
  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.