-
Notifications
You must be signed in to change notification settings - Fork 635
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
compents width is not right #460
Comments
@mobeigi Your pull request may have caused this problem. @WeiShengv99 You can lock version @3.0.1 |
This changed behaviour is caused by: #458 This problem is only caused when there is no defined width or height. Previously there would a resize after the first render which would make echarts fit its parent container. When that PR stopped the resize from happening to let animation work it prevented this auto resizing. From the
Some solutions would be:
I will try to investigate later to see if there is a nice fix for this. |
I did some investigation. It looks like internally There are two solutions. Method 1The best solution is to know the width and height before the first Method 2The second way is to do a temporary render to get the correct size and then dispose temporary echarts and init again. I have an example branch here with these changes: The lifecycle looks like this:
Unfortunately, we cannot just call With this commit:
The problems with this method:
Video JEjFOepgm2.mp4ConclusionMethod 2 isn't very nice but with the above changes it will behave closer to If we could get the correct final size from echarts library and do only 1 |
After some more investigation, I believe Method 2 is our only option. It will behave very similarly to |
Hi, very nice work for solving this issue, it was causing me trouble, it would be great if it was ready in production soon.🙌 |
version : 3.0.2
In my case when compents render , the compents width is not right ,it get window width ,not parents width,It contains slider width.
in doc demo ,i also find the same problem
first
open https://git.hust.cc/echarts-for-react/
second
go to demo page, you can see cmp width also not right,
but if you change the window size, the resize is working right.
i change version to 3.0.0, the problem is reslove, it seem like getBoundingClientRect not right in flex element or something, ..or get the error wrapper width,
here is demo for codesandbox
ps: sorry my english is bad, i hope you can understand what i mean...
The text was updated successfully, but these errors were encountered: