Skip to content

Commit

Permalink
Merge pull request #4595 from rldhont/fix-dataviz-embed
Browse files Browse the repository at this point in the history
Fix JS Dataviz: When dataviz is not available
  • Loading branch information
rldhont authored Jul 11, 2024
2 parents e2bb302 + 5dd8977 commit 741b0e5
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);
})
})

1 comment on commit 741b0e5

@3liz-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest weekly run of end2end "playwright" tests failed with this latest commit on the branch release_3_6 😣

CC @nboisteault and @Gustry, please have a look to the logs. Maybe it's a false positive ?

Visit https://github.com/3liz/lizmap-web-client/actions/runs/9933220856

Please sign in to comment.