-
Notifications
You must be signed in to change notification settings - Fork 19.7k
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
"Can't get dom width or height" incorrectly fires for width/height values of 0. #10478
"Can't get dom width or height" incorrectly fires for width/height values of 0. #10478
Comments
Hi! We've received your issue and please be patient to get responded. 🎉 In the meanwhile, please make sure that you have posted enough image to demo your request. You may also check out the API and chart option to get the answer. Have a nice day! 🍵 |
Why should 0 be a valid value for a container? The warning here is to warn users that the chart is not visible most likely because the container doesn't have width or height, in which case |
@Ovilia A relative sized
The warning is specifically But I'm not sure about original intent. Some history:
And afaict IE6 has support for |
The width and height of the container are required to create a canvas with the same size. So none of |
I have to say that your English is sooooo nice! |
I got this warning because I using tab card, when page onload the container set by CSS with |
if I set |
echarts-5.1.1: containing the chart is initially set to display:none;
|
Hi there! Guys, I am getting this warning:
And honestly I have tried with pretty much evertyhing:
No luck so far, I am using the latest version of ECharts and its React Wrapper and this is the only warning I was not allowed to clean.
Any help would be more than appreciated. Thanks in advance! |
I'm seeing this during jest testing and am providing parent width and height (and have also attempted to set window innerHeight and innerWidth in various ways). Just a warning, but would love if we could resolve somehow.
Have also tried other ways of setting window size before the test, both in
echarts 5.1.2 |
Same here. Any update on this? |
1 similar comment
Same here. Any update on this? |
still no update? |
Any update? |
Throwing a +1 on here. Seeing this warning pop up when the parent container, and the div the chartRef is on, both have an initial height. |
this bug still exist? the warning pop up still appears on me, i use this on dynamic container that doesn't have fixed width. sometimes it appears on display: none too,, "echarts": "^5.3.3", |
this bug still exist |
I have tried many options. This error disappears for me only when inline styles are set for the block. Namely inline styles in absolute units. Unfortunately, calc doesn't work. First option
There may be errors in the example, since I write in a framework and there is a different syntax. But the point is clear. If you don't need responsiveness, then just add inline pixel styles to the div element. Second option You can simply use a timeout set to check that the block already has sizes.
|
如果图表显示而没数据,是数据更新了没调用,所以会出现这个问题,这是我的解决方法,在watch里面再调用一下就没这个错误了,希望对你们有所帮助,原因出在,初始化的时候 |
In my case, I use ECharts with Angular (not ngx-echarts). I get this warning, but the chart is correct rendered/visible. It does not matter if I use ngInit or ngAfterViewInit. I think in the very first state of component loading, the container/layout is not yet fully loaded/sized. But it's ok and no problem when using ResizeObserver (what should use ECharts build-in btw.). So the warning is annoying. We could offer an option to disable this checks/logs. Btw. the warning is also displayed when using min-width, min-height to e.g. 1px. |
I use ECharts with vue 3 and I get this warning if I don't set width and height (in that case, chart isn't rendered). |
same problem. when running test with getByText in "App" , ECharts component returned the error "Can't get DOM width or height. Please check dom.clientWidth and dom.clientHeight." ECharts component is a child in "App". This error aborts the test. After spending almost a day looking for a solution, I found the answer https://stackoverflow.com/a/55100373
|
Any solution to this? |
Is there any update to this? I see the issue has been closed so I'll check if there is another one with a resolution |
+1,same issue with echarts-fo-react |
Solved by resizing chart like this:
echarts-for-react: v3.0.2 |
in vue 3 , i have solved the issue by adding a div container with css : .chart { height: 100vh; position: relative; } |
The lack of height and width for the component's root node causes the echars module to fail to inherit the width and height properties to the canvas. One solution is to set the height and width of the component's root node, and the other is to manually add width and height properties to the canvas. 组件的根节点没有高度和宽度导致echars模块无法将width属性和height属性继承到canvas中. |
@zekraouin I'm using vue3 too, here is a different way to handle that issue and still want to use the autoresize feature: <template>
<v-chart v-if="showChart" :option="myOptions" autoresize />
</template>
<script setup lang="ts">
import { onMounted, ref } from "vue";
import VChart from "vue-echarts";
const showChart = ref(false);
const myOptions = {
// ...
};
onMounted(() => (showChart.value = true));
</script> |
I'm developing using vue3 + nuxt3 and found a new way to apply echart. The method I used was defineAsyncComponent and set it in the parent component that uses echart. [EChartComponent.vue]
[Parent component using EChartComponent]
|
dame it. I got it fixed in my case. I can only guarantee that it works in my setup. But obviously, this isn't the best way, or even a good way, to handle it. We need to come up with a better solution. it's my solution: import ReactECharts from "echarts-for-react";
const option = {
// ...
// option defines
// ...
}
<ReactECharts
option={option}
style={{ width: 800, height: 400, minWidth: 800, minHeight: 400 }}
/> add the style if you wanna make it responsive to expend the whole width, you can use |
If it can be useful I just used With a file at import { vi } from 'vitest'
export const getInstanceByDom = {
setOption: vi.fn(),
} |
This is still happening to me, is fixed to me setting up a fixed height using CSS but it complicates responsiveness a lot. |
before, this Vue3 code has error message:
You can try using this code, add 'auto':
In my case, message disappeared. |
This is still happening to me with v5.5.1 |
For me, because I'm using echarts-for-react, I just need to do this:
|
@Ovilia Can we reopen this issue? This issue is not resolved by workarounds with min-width or smth like AfterViewInit in Angular. If you won't fix this issue please provide a possibility to silence this warning since it it possible to see this warning and a perfectly fine sized chart. |
Version
4.2.1
Steps to reproduce
This warning from echarts: https://github.com/apache/incubator-echarts/blob/b6ab21159617b45c8077d998d468977cdd87d146/src/echarts.js#L1999 seems to be triggered when
!dom.clientWidth
, however I believe it is valid fordom.clientWidth
to have a value of0
.I'm not sure why this warning was added, but I think the check should be
dom.clientWidth === undefined
if the check is for a failure of theclientWidth
API to exist.What is expected?
warning should not occur for element width/height of 0
What is actually happening?
warning is logged.
I'm happy to resolve this issue, but I'd like some confirmation my hunch is correct, or a clarification for why it is not.
The text was updated successfully, but these errors were encountered: