diff --git a/lizmap/www/assets/js/dataviz/dataviz.js b/lizmap/www/assets/js/dataviz/dataviz.js index 27de70e2f8..d9342dbf87 100644 --- a/lizmap/www/assets/js/dataviz/dataviz.js +++ b/lizmap/www/assets/js/dataviz/dataviz.js @@ -121,8 +121,6 @@ let lizDataviz = function () { // initialize plot info dv.plots[i] = { 'json': null, 'filter': null, 'show_plot': true, 'cache': null, 'data_fetched': false }; if (!(optionToBoolean(dv.config.layers[i]['only_show_child']))) { - let plotContainerId = `dataviz_plot_${i}`; - // Add plot container addPlotContainer(i); } @@ -143,6 +141,10 @@ let lizDataviz = function () { if (!(optionToBoolean(dv.config.layers[i]['only_show_child']))) { // Get the plot data and display it if the container is visible let elem = document.getElementById(plotContainerId); + // skip the element if it does not exist + if (elem === null) { + continue; + } if (isInViewport(elem) || getViewPercentage(elem) > 0) { getPlot(i, null, plotContainerId); } diff --git a/tests/end2end/playwright/embed.spec.js b/tests/end2end/playwright/embed.spec.js new file mode 100644 index 0000000000..74a5f9776a --- /dev/null +++ b/tests/end2end/playwright/embed.spec.js @@ -0,0 +1,10 @@ +// @ts-check +const { test, expect } = require('@playwright/test'); +const { gotoMap } = require('./globals') + +test.describe('Embed', () => { + test('Dataviz does not generate error', async ({ page }) => { + const url = '/index.php/view/embed/?repository=testsrepository&project=dataviz'; + await gotoMap(url, page); + }) +})