-
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
[Bug] Series-line is clipped incorrectly at the rightmost position #19051
Comments
It seems that using - const lineWidth = seriesModel.get(['lineStyle', 'width']) || 2;
+ const _lineWidth = seriesModel.get(['lineStyle', 'width']) || 2;
+ // I don't know where to find the dpr from `echarts.init`, so I
+ // use `window.devicePixelRatio` as example
+ const lineWidth = _lineWidth * window.devicePixelRatio;
// Expand the clip path a bit to avoid the border is clipped and looks thinner
x -= lineWidth / 2;
y -= lineWidth / 2;
width += lineWidth;
height += lineWidth;
// fix: https://github.com/apache/incubator-echarts/issues/11369
x = Math.floor(x);
- width = Math.round(width);
+ width = Math.ceil(width); |
I just found that DPR can be retrieved from zrender instance: const zr = cartesian.model.ecModel.scheduler.ecInstance.getZr();
const dpr = zr.painter instanceof CanvasPainter
? zr.painter.dpr
: window.devicePixelRatio; /* global window */
const _lineWidth = seriesModel.get(['lineStyle', 'width']) || 2;
const lineWidth = _lineWidth * (dpr || 1); And after multiplying DPR, there are no such numbers as PR is on the way... |
It's ok to use only |
fix(clip): add an extra space to the clip-path width to prevent unexpected clip. close #19051
Version
5.4.3
Link to Minimal Reproduction
https://codepen.io/rexskz/pen/WNLweyw
Steps to Reproduce
Current Behavior
It's clipped incorrectly, but the leftmost position of the line is okay.
Expected Behavior
The rightmost position should not be clipped, just like the leftmost one.
Environment
Any additional comments?
The root cause is that ECharts uses
Math.round
increateClipPathFromCoordSys.ts
:The
width
here can be a float with the decimal part less than 0.5:Finally, it results in the incorrect
clipPath
, just 1px smaller than expected:This issue can only be reproduced in a container with a specific width (
503px
in the codepen link).This issue might be related to #11369; considering it meant to extend the clipPath and use
Math.floor
onx
, I think it's okay to useMath.ceil
onwidth
to ensure the clipPath is large enough to contain the whole line (with cap).The text was updated successfully, but these errors were encountered: