Comments (7)
Any luck with this issue. Today at 2023 I am still having this issue but with React.
[ECharts] Can't get DOM width or height. Please check dom.clientWidth and dom.clientHeight. They should not be 0.For example, you may need to call this in the callback of window.onload.
from vue3-echarts.
@xzegga you could set width or height in init(element, theme, {width: 1000, height: 1000})
from vue3-echarts.
try this on your container CSS:
#chart-container {
position: relative;
height: 100vh;
overflow: hidden;
}
from vue3-echarts.
In the point 3 where shall I place the line with (this.$refs.chart as VueEcharts).refreshOption();?
You don't need to call refreshOption
when vue-echarts
is created. You need to call refreshOption
when the option is updated.
However, I got this error
It was strange. Could you provide more info such as stack trace and more importantly the status of vue-echarts
element when the exception was thrown?
from vue3-echarts.
Thanks @CarterLi for the hint checking the element. This is the status of my vue-charts
element:
<div class="vue-echarts" style="height: 500px; -webkit-tap-highlight-color: transparent; user-select: none; position: relative;" _echarts_instance_="ec_1636225806299"><div style="position: relative; width: 0px; height: 500px; padding: 0px; margin: 0px; border-width: 0px;"><canvas data-zr-dom-id="zr_0" width="0" height="500" style="position: absolute; left: 0px; top: 0px; width: 0px; height: 500px; user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); padding: 0px; margin: 0px; border-width: 0px;"></canvas></div><div class=""></div></div>
I created that with this vue template code just like in your README.md:
<template>
<vue-echarts :option="line" style="height: 500px;" ref="chart" />
</template>
The error is gone after I add the width, e.g. style="height: 500px; width: 1000px;"
.
from vue3-echarts.
The root element of vue-echarts is div, it should act as width: 100%
by default.
from vue3-echarts.
I also had this with React (inside some Joy UI component).
Following slava's suggestion, this call fixed it up for me:
<ReactEcharts
option={option}
style={{ width: '300px', height: '300px', minHeight: '300px', minWidth: '300px'}}
/>
from vue3-echarts.
Related Issues (9)
- how do u do resize for instance
- for those who don't know how to bind events
- TS 版本有问题 导致编译错误 HOT 3
- How to SetOption HOT 1
- i need refresh data from api like this How can i HOT 4
- vite项目用了这个插件页面HMR怎么失效了? HOT 6
- HOW TO Render Toggle SVG or Canvas
- Question: Property 'chart' does not exist on type 'CreateComponentPublicInstance HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue3-echarts.