Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release_3_7] Fix JS Dataviz: When dataviz is not available #4597

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
})
})
Loading