Skip to content

Commit

Permalink
Merge pull request #4598 from 3liz/backport-4595-to-release_3_8
Browse files Browse the repository at this point in the history
[Backport release_3_8] Fix JS Dataviz: When dataviz is not available
  • Loading branch information
rldhont authored Jul 11, 2024
2 parents 338770a + c76eb74 commit 85d8e5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lizmap/www/assets/js/dataviz/dataviz.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
10 changes: 10 additions & 0 deletions tests/end2end/playwright/embed.spec.js
Original file line number Diff line number Diff line change
@@ -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);
})
})

0 comments on commit 85d8e5c

Please sign in to comment.