Pre loader

Export chart with HeatmapColorMap

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

Hello,

I want my HeatmapColorMap to be part of my chart, so that when I export it, the HeatmapColorMap is visible on the PNG / XPS.
In order to this, I put the HeatmapColorMap inside a CustomAnnotation.
I can see it nicely on my Surface but when I try to export it as XPS or as PNG with some specific size, the numbers and ticks have disappeared, only leaving the rectangle with color gradient (see attached picture)
Is there a way to solve this ?

Thank you !

Version
6.5.1.26063
Images
  • You must to post comments
1
0

Hello Renaud,

I’ve investigated the problem you’ve faced. I can confirm that this bug is reproduceable on our side. It seems that some of the properties of HeatmapColorMap were skipped during serialization process, that leads to missed ticks and labels on a resulted image.
We’ve logged it it, and we’re going to prioritize it, and probably include fix for this in one of our future releases.

Meanwhile I can suggest you the following workaround:

The point of this workaround is to create a custom class ‘SciChartSurfaceEx’ that is derived from our SciChartSurface, and override there CreateCloneOfSurfaceInMemory() method. where you can simply copy the content from an annotation on a real chart to the annotation on a cloned one.

public class SciChartSurfaceEx : SciChartSurface
{
    protected override SciChartSurfaceBase CreateCloneOfSurfaceInMemory(Size newSize)
    {
        // Grab custom annotation that stores HeatmapColormap on a real chart
        var colormap = (CustomAnnotation)this.Annotations.Where(x => x.GetType() == typeof(CustomAnnotation)).FirstOrDefault();

        // Perform exporting functionality(serializing\deserializing)
        var cloned = (SciChartSurface)base.CreateCloneOfSurfaceInMemory(newSize);

        // Grab custom annotation from a cloned surface
        var ann = (CustomAnnotation)cloned.Annotations.Where(x => x.GetType() == typeof(CustomAnnotation)).FirstOrDefault();

        // Copy content from a real chart annotation to a cloned one. 
        ann.Content = colormap.Content;

        return cloned;
    }
}

After that please substitute SciChartSurface on your view with this custom one, and you export functionality without changes.

Please try this and let us know if it helped.
If you have any other questions feel free to ask.

  • You must to post comments
1
0

The goal of any software project should be clearly defined and communicated to the entire team https://mlsdev.com. The owner must ensure that the backlog is detailed and clear to avoid confusion. The product owner is not responsible for the goals of the software development team, but rather the guiding force for the team. The absence of a product owner in a development project can result in failure to meet the business goals. The product owner should have a good understanding of the target market and what the customers want.

  • You must to post comments
1
0

Hello Renaud,

Please take my apologies, for such late reply, I was off-sick for a couple of days.

I’ve reinvestigated this problem, and tried different approaches, to solve this, and found few but they are not that elegant. The main problem here that ‘HeatMapColorMap’ has basically another SciChartSurface inside it and which re-creates xAxis on rendering(and I think this this the cause).

The only working option that I can suggest you now is to place your cloned surface to some new\custom window, show it, and then close it. Placing and showing a new window forces your cloned SciChartSurface rendering with all it’s inner annotations(including HeatMapColorMap)

please try something like this:

public class SciChartSurfaceEx : SciChartSurface
{
    protected override SciChartSurfaceBase CreateCloneOfSurfaceInMemory(Size newSize)
    {
        // Grab custom annotation that stores HeatmapColormap on a real chart
        var originalColormapAnnotation = (CustomAnnotation)this.Annotations.Where(x => x.GetType() == typeof(CustomAnnotation)).FirstOrDefault();
        var originalColorMap = originalColormapAnnotation.Content as HeatmapColorMap;

        // Perform exporting functionality(serializing\deserializing)
        var cloned = (SciChartSurface)base.CreateCloneOfSurfaceInMemory(newSize);

        var newWindow = new Window();
        newWindow.Content = cloned;
        newWindow.Show();
        newWindow.Close();

        return cloned;
    }
}
  • You must to post comments
0
0

Hello Nazariy,

I am re-opening this discussion because I have another related issue.

When using your code and creating a new window:

public class SciChartSurfaceEx : SciChartSurface
    {
        protected override SciChartSurfaceBase CreateCloneOfSurfaceInMemory(Size newSize)
        {
            // Grab custom annotation that stores HeatmapColormap on a real chart
            var originalColormapAnnotation = (CustomAnnotation)this.Annotations.Where(x => x.GetType() == typeof(CustomAnnotation)).FirstOrDefault();
            var originalColorMap = originalColormapAnnotation.Content as HeatmapColorMap;

            // Perform exporting functionality(serializing\deserializing)
            var cloned = (SciChartSurface)base.CreateCloneOfSurfaceInMemory(newSize);

            var newWindow = new Window();
            newWindow.Content = cloned;
            newWindow.Show();
            newWindow.Close();

            return cloned;
        }
    }

Exporting a PNG (with HeatmapColorMap) works fine. However, exporting an XPS file does not work anymore. I get the following exception when calling surface.ExportToFile :

System.InvalidOperationException: ‘Specified element is already the logical child of another element. Disconnect it first.’

Do you know any way around this ?

Thank you !

  • You must to post comments
0
0

Hi, to further clarify, we noticed that Scichart automatically scales as per the values and the height of the smartphone screen. We would like to control it a bit more like “traditional” EEG charts chinese take out restaurants near me which can show amplitude at 7Uv/mm or 20Uv/mm or 200Uv/mm or even 1000Uv/mm. Can Scichart help us with this?

  • You must to post comments
0
0

Hello Nazariy,

I have tested your workaround and it allows me to export the chart with the ticks and labels visible, so that is nice.
However, right after exporting the chart, the HeatmapColorMap disappears from the Surface, it is no longer visible. But if I export again, it is still printed out on the PNG / XPS. It is just not visible on the Surface anymore.

Could you help me with that ?

Thank you very much for your help !

  • You must to post comments
0
0

Hello Renaud,

I’ve re-tested, your inquiry and it seems that it works well with the latest SciChart version even without using overriding CreateCloneOfSurfaceInMemory() method.
I’ve modified one of our examples, please find it here ==> https://1drv.ms/u/s!ApXFjaRTY-1SgQ9FUn04DeK6Kndm?e=SbhHVH

Can you kindly test it on your side and give us your feedback.

  • You must to post comments
0
0

Hello Nazariy,

It does not solve the problem on my side. I include a screenshot of the Surface and the exported PNG for comparison. I moved the HeatmapColorMap on top to make it more visible that the ticks and labels are misssing.
When I use SciChartSurfaceEx, I still have the HeatmapColorMap disappearing right after exporting.

Would you know any way around that ?

Thank you !

Images
  • You must to post comments
0
0

Hello Nazariy,

Thank you very much, this works nicely !

  • You must to post comments
Showing 9 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