Pre loader

Issue with updating theme just before export

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

This demo was very helpful in working export out. I have a followup question. For a specific user request, I’m currently attempting something along these lines (current state; there’s some spaghetti-against-the-wall method going on at the moment):

const previousTheme = surface.themeProvider;

    const exportTheme = {
        ...previousTheme,
        sciChartBackground:"Transparent",
        gridBackgroundBrush:"Transparent",
        axisBandsFill: "Transparent"
    }

    surface.applyTheme(exportTheme);
    surface.background = "Transparent";

    new Promise(r => setTimeout(r, 1000)).then(() => {
        try {
            const node = document.getElementById('scichart-stuff');
            if (!node)
                return;
            domtoimage
                .toPng(node )
                .then(function (blob) {
                    saveAs(blob, 'plot.png');
                })
                .catch(function (error) {
                    console.error('Problem exporting/saving image of plot', error);
                });
        } finally {
            surface.applyTheme(previousTheme);
        }
    })

I am able to see the update (after adding the delay) on the screen, but the export appears to be ignoring the values I’m setting. I’m wondering what I might be missing in terms of the interactions of these libraries.

Version
3.2.509
  • Andrew Burnett-Thompson
    Hi Dan, we have seen this, we haven’t answered yet as the answer is difficult :) Will get to it soon.
  • You must to post comments
0
0

Hi Dan,

Update, the answer to this is that after changing a property (including theme) you will need to wait for the chart to be redrawn before you can export the image.

The only possible way would be to wait for sciChartSurface.rendered callback to be fired and call your export after that.

Something like this might work (however this is really outside what is supported by scichart at the moment)

const callback = () => {
   // when redraw occurs, this code executes 
   sciChartSurface.rendered.unsubscribeAll();

    // DO EXPORT HERE
};

sciChartSurface.rendered.subscribe(callback);
sciChartSurface.applyTheme(exportTheme); // will trigger redraw

Are you generating a lot of images? Perhaps a discussion with our team is warranted as we are gathering requirements on creating a reporting service right now.

FYI I have created task SCJS-1675 [feature] Change theme before export of chart

Best regards
Andrew

  • Dan Santimore
    Hey Andrew, thank you for this and I will play around with it. I definitely understand that given how asynchronous all of this is, it does make it somewhat inelegant. In the organization I’m supporting, it appears that one of their primary use cases will be to generate lots of very similar plots of different data sets, and these have to be somewhat pretty, as sometimes they are shared externally. The suite I’ve built is extremely interactive and designed for research. I know I’ve thrown a bunch of new stuff at you, so if you want a closer look at what we’re doing (even though were a smaller fish for your market) I think that could be arranged. Feel free to email me directly. -Dan
  • Andrew Burnett-Thompson
    Hi Dan, will do just that!
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.