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.
- Dan Santimore asked 2 weeks ago
- Hi Dan, we have seen this, we haven’t answered yet as the answer is difficult :) Will get to it soon.
- You must login to post comments
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
- Andrew Burnett-Thompson answered 1 day ago
- last edited 1 day ago
- 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
- Hi Dan, will do just that!
- You must login to post comments
Please login first to submit.