You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "tarik56 (via GitHub)" <gi...@apache.org> on 2023/05/14 02:35:37 UTC
[GitHub] [echarts] tarik56 commented on issue #15103: browser zoom and dom zoom will cause mouse position fault in tooltip
tarik56 commented on issue #15103:
URL: https://github.com/apache/echarts/issues/15103#issuecomment-1546792533
Okey so for anyone encountering this issue, here is how I fixxed it after a few hours of torture. I have noticed that echarts has an internal rerenderer that triggers on certain conditions. Though, it won't do that when your zoom has already been applied to parent DOM elements.
If your parent element, for example the <html> element has a predefined zoom of eg. 0.7 set by you, you will have to calculate the inverse and set the zoom on the echart parent div or the echart div itself to trigger a rerender with a valid zoom for it to handle it correctly.
Calculate the inverse with eg.: **1 / 0.7 = 1.42857**
Sample:
```javascript
const element = document.getElementsByTagName('html')[0];
const computedStyle = window.getComputedStyle(element);
const zoom = computedStyle.getPropertyValue('zoom');
this.setState({zoom_amount: 1 / zoom})
//if zoom = 0.7
//then zoom_amount = 1.42857
//then give the new zoom, depending on what library you use like below
<EchartDivOrParentDiv options={your_options} style={{zoom: this.state.zoom}} />
```
Would be great to have this kind of logic naturally included in the echart code but that's one way to handle it. Hope it helps some of you.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org