Replies: 3 comments 27 replies
-
I have identified the reason this this bit of code. Commented it out and it only prints finished once. nicegui/nicegui/elements/echart.js Lines 59 to 63 in 8d48ec7 But, I think it is simply how Apache EChart works. Perhaps your logic should deduplicate the finished events. |
Beta Was this translation helpful? Give feedback.
-
Here is a more handy reproduction: ui.echart({
'xAxis': {'type': 'value'},
'yAxis': {'type': 'value'},
'series': [{'type': 'scatter', 'data': [[x, x] for x in range(50_000)]}],
}) And here is a reproduction with plain HTML/JavaScript: <html>
<head>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/echarts.min.js"></script>
</head>
<body>
<div id="chart" style="width: 600px; height: 400px"></div>
<script>
const el = document.getElementById("chart");
const chart = echarts.init(el);
const createResizeObserver = () => {
new ResizeObserver(chart.resize).observe(el);
chart.off("finished", createResizeObserver);
};
chart.on("finished", createResizeObserver);
chart.setOption({
xAxis: { type: "value" },
yAxis: { type: "value" },
series: [{ type: "scatter", data: Array.from({ length: 50000 }, (_, i) => [i, i]) }],
});
</script>
</body>
</html> Removing the resize observer prevents the chart from rendering twice. I still wonder if we really need this observer or if we can solve PR #3056 differently. |
Beta Was this translation helpful? Give feedback.
-
I just created issue #4535 as a fresh starting point for solving this problem and to track the progress of this bug. Let's continue our discussion over there. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question
Apache Echart is always rendering twice.
To Illustrate that I added an event:
chart.on('chart:finished', lambda e: print(f"finished: {datetime.now()} {more=}"))
This event is always triggered twice.
Why? Is there a way to only trigger once the rendering?
Here are the outputs on visiting the 2 routes of the code below:
This is problematic when more data is rendered.
Even worse when you want to interact with the chart based on a selection outside, cause the chart then waits until second finish and after that starts to render the changed stuff.
Beta Was this translation helpful? Give feedback.
All reactions