Strange behaviour with chart widget

0
Question:I'm experiencing an issue with the Charts Widget where the line chart renders correctly on initial load, but after navigating away from the page and returning to it, the chart extends beyond its container boundaries. I'm using Mendix version 10.24.22 and Charts version 6.2.3. What might be causing this behavior?Context:Chart displays properly on first page loadIssue occurs after navigation away and back to the chart pageChart overflows its container bordersEnvironment:Mendix version: 10.24.22Charts widget version: 6.2.3How it should look: How it looks:
asked
2 answers
1

Hi,

This looks like a Plotly resize/reflow issue rather than a problem with your chart data.


Since it renders correctly on the first load and only overflows after navigating back, the underlying Plotly chart is likely not recalculating its dimensions when the page is recreated.


As a quick test, try manually resizing the browser window after returning to the page. If the chart immediately fits the container again, that confirms it's a missing resize/reflow event.


A workaround is to trigger a Plotly resize after the page becomes visible, for example in a JavaScript action:


document.querySelectorAll(".js-plotly-plot").forEach(chart => {

if (chart.offsetParent !== null && typeof Plotly !== "undefined") {

Plotly.Plots.resize(chart);

}

});


window.dispatchEvent(new Event("resize"));


This forces the chart to recalculate its dimensions and fit back into its parent container.


Could you also confirm whether the chart is inside a Data View, Tab Container, or Snippet? That can help narrow down whether it's a visibility/reflow issue.


Kindly mark this as the accepted answer if it helps.

answered
0

Hello Krishnakummar,


The chart fits the container when I resize the browser but the code you suggested doesn't work to fix the issue.

The cart is inside some containers.



answered