Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm using a mashup to automate generating images of charts - I run it inside a headless browser using Puppeteer.
I'd like to be able to generate a set of screenshots every time I change the selections: this would be much quicker than having to reload the page every time with different selections.
The problem is that there might be a small delay in refreshing the visualisations after the selections change, so I'd like to know when the refresh is complete before taking the screenshot. Is there a way to do this using an event listener?
Here is the mashup code that creates the visualizations and exposes them to the automation system:
function showAndRegister(el, obj) {
app.visualization.get(obj).then(function(vis) {
vis.show(el);
if (window.automator.onVisualization){
window.automator.onVisualization(el, obj);
}
});
}
window.automator.setCountry = function(code) {
var field = app.field('Country Code');
field.clear();
field.selectValues([{qText: code}]);
}
//add the objects --
showAndRegister('QV04','gzCQfU');
showAndRegister('QV03','RwGpFhZ');
showAndRegister('QV02','EqHaWS');
showAndRegister('QV01','QSLrsS');
For what it's worth:
// vis.show returns a promise that resolves to an object, I don't know what kind
// but whatever the object is, you can set its options.onRendered to a callback
var p = app.visualization.get(obj).then((vis) => vis.show(el, opts))
p.then((x) => x.options.onRendered = (() =>console.log('Rendered!')))
And even easier, found thanks to https://github.com/qlik-oss/qlik-sense-visualization-extension-testing:
// including a callback as the onRendered property in the options passed to the visualization's show method
// will lead to the callback being called every time the visualization is rendered
app.visualization.get(obj).then((vis) => vis.show(el, { onRendered: () => console.log('Rendered!') }))
For what it's worth:
// vis.show returns a promise that resolves to an object, I don't know what kind
// but whatever the object is, you can set its options.onRendered to a callback
var p = app.visualization.get(obj).then((vis) => vis.show(el, opts))
p.then((x) => x.options.onRendered = (() =>console.log('Rendered!')))
And even easier, found thanks to https://github.com/qlik-oss/qlik-sense-visualization-extension-testing:
// including a callback as the onRendered property in the options passed to the visualization's show method
// will lead to the callback being called every time the visualization is rendered
app.visualization.get(obj).then((vis) => vis.show(el, { onRendered: () => console.log('Rendered!') }))