Pre loader

Export to XPS loosing PaletteProvider coloring

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

Answered
0
0

Hi, I am trying to export an XyScatterRenderableSeries based on a XyzDataSeries<double,double,double> to XPS. The coloring is based on the z value and works perfectly in the application itself. The problem is that when exporting all the data and labels are perfectly visible ( no more vertical mirroring etc.), however all points are grey. I do see by setting a breakpoint on the OverridePointMarker below that the palette is used, just don’t see it in the end result. Anyone any tips or ideas what is going wrong?

Part of the Palette Provider;

    public PointPaletteInfo? OverridePointMarker(IRenderableSeries rSeries, int index, IPointMetadata metadata)
    {
        var rxyz = rSeries as XyScatterRenderableSeries;
        var xyz = rxyz?.DataSeries as XyzDataSeries<double, double, double>;
        if (xyz == null) return null;
        var z = xyz.ZValues[index];
        var i = Convert.ToInt32((_colormap.GetUpperBound(0) * z) / _max);
        var c = _colormap[i];
        return new PointPaletteInfo()
        {
            Fill = c,
            Stroke = c
        };
    }

Code to generate the chart in memory and export it to XPS

        var colormap = new ColorMappingAgain((Brush)Resources["DefaultBrush"], 100);
        var x = new ObservableCollection<IRenderableSeries>() {HeatmapSeries};

        foreach (var y in x)
            y.PaletteProvider = colormap;

        var surface = new SciChartSurface()
        {
            RenderSurface = new XamlRenderSurface(),
            ChartTitle = name,
            FontSize = (double) dpi * fontsize / 96,
            XAxes = xAxes,
            YAxes = yAxes,
            RenderableSeries = x,
        };

        foreach (var y in x)
            y.PaletteProvider = colormap;

        SciChart.ExportToFile(@"C:\Temp\again.xps",ExportType.Xps,true);
        SciChart.ExportToFile(@"C:\Temp\again2.xps", ExportType.Xps, false);
Version
nuget latest
  • You must to post comments
Best Answer
1
1

Hi Michel,

Thanks for your question. The Export feature relies on serialization to create a copy of a SciChartSurface. Some properties cannot be serialized because of the way serialization works. For example, properties of collection and interface types cannot be processed.

So such properties need to be set manually. For this purpose, SciChartSurface exposes the CreateCloneOfSurfaceInMemory(Size) method. Please try overriding it and applying your PaletteProvider to the corresponding RenderableSeries of the cloned SciChartSurface. It can be obtained from the base implementation:

public class SciChartSurfaceEx : SciChartSurface
{
    protected override SciChartSurfaceBase CreateCloneOfSurfaceInMemory(Size newSize)
    {
        var clonedSurface = (SciChartSurface)base.CreateCloneOfSurfaceInMemory(newSize);

        // Apply custom PaletteProvider here
        clonedSurface.RenderableSeries[0].PaletteProvider = new CustomPointMarkerFillPaletteProvider();

        return clonedSurface;
    }
}

Please let us know if this works for you,

Best regards,
Yuriy

  • You must to post comments
0
0

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-dev.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?

  • You must to post comments
1
0

Hi Michel,

Great, I glad it helped. You guessed it right, SciChartSurfaceEx has to be used as your main surface. It gets cloned for exporting. However, it should have worked even if created from code. We do this all the time in tests. Maybe it fails for you due to an exception being thrown?

Concerning the HeatmapColourMap, it is a separate control, so it doesn’t get exported with SciChart. We’ve got a task to improve this.
For now, I think you could try to put the ColourMap into a Legend. Please see this documentation article to learn how to do it.

Let us know if you managed to achieve this,

Best regards,
Yuriy

  • You must to post comments
0
0

I have implemented the following code which works perfectly as long as the colormap is defined by a static resource. However, colormaps can be changed and thus I need to use binding, the binding works when binding to the Tag of LegendModifier from within the template, I see the map perfectly and beautifully on my chart. Hooray for that. However, when I export I no longer have the filled rectangle on my chart :-/ Any idea how I should update the override of CreateCloneOfSurfaceInMemory to set the programmatically the fill ?

I know this is something that I need to do, but after some hours on this any help or fresh idea is welcome.

Best wishes,

Michel.

  • Yuriy Zadereckiy
    Hi Michel, I would suggest adding this as a property on your LegendModifier. You can create a custom one which would extend the existing LegendModifier. It will allow you to bind to this property from within the template and update colors properly from CreateCloneOfSurfaceInMemory. Hope this helps!
  • Michel Bieleveld
    That worked perfectly Yuriy, thank you so much ! Much easier than trying to find logical or visual children. Great way to start the Friday :D
  • You must to post comments
Showing 4 results
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