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

[Bug] Treemap disappears on interaction / scroll / drilldown (Vue 3) #20530

Open
DotoPototo opened this issue Nov 21, 2024 · 4 comments
Open
Labels

Comments

@DotoPototo
Copy link

Version

5.5.1

Link to Minimal Reproduction

https://codesandbox.io/p/sandbox/echart-treemap-vue-bug-q74ljp

Steps to Reproduce

Click on a node within the treemap OR click on the breadcrumb OR try to zoom with the mouse wheel and the treemap disappears.

A refresh brings it back.

Current Behavior

Treemap disappears/minimises to the top left.

Expected Behavior

Drilldown or zoom change

Environment

- OS: Any
- Browser: Chrome
- Framework: Vue 3

Any additional comments?

It uses data (data.js) which is the data directly from the disk usage example

@DotoPototo DotoPototo added the bug label Nov 21, 2024
@echarts-bot echarts-bot bot added en This issue is in English pending We are not sure about whether this is a bug/new feature. labels Nov 21, 2024
@helgasoft
Copy link

not-a-bug, probably due to error in Vue environment. Same code works fine in the Editor - Demo

@DotoPototo
Copy link
Author

@helgasoft just because something works outside of a framework doesn't automatically mean the bug is within the framework.

@helgasoft
Copy link

Are you using the recommended vue-echarts ? There are examples to follow there.

@plainheart
Copy link
Member

plainheart commented Nov 22, 2024

@DotoPototo Try to use shallowRef

- const chart = ref(null); 
+ const chart = shallowRef(null); 

Or a local unresponsive variable. (More recommended, as it doesn't really need reactivity)

- const chart = ref(null); 
+ let chart = null

const updateChart = () => {
-  chart.value.setOption({
+  chart.setOption({
    // ...
  })
})

onMounted(() => {
- chart.value = echarts.init(document.getElementById("main"), "dark");
+ chart = echarts.init(document.getElementById("main"), "dark");
  updateChart();
});

// Don't forget to dispose the chart instance when the component is destroyed
+ onBeforeUnmount(() => {
+   if (chart) {
+     chart.dispose()
+     chart = null
+   }
+ })

See also other similar issues here, especially #17723 (comment).

@plainheart plainheart added third-party waiting-for: author and removed bug pending We are not sure about whether this is a bug/new feature. labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants