Skip to content

[Bug] Series-line is clipped incorrectly at the rightmost position #19051

@RexSkz

Description

@RexSkz

Version

5.4.3

Link to Minimal Reproduction

https://codepen.io/rexskz/pen/WNLweyw

Steps to Reproduce

  1. Open the codepen link.
  2. Look at the rightmost position of the line.

Current Behavior

It's clipped incorrectly, but the leftmost position of the line is okay.

image

Expected Behavior

The rightmost position should not be clipped, just like the leftmost one.

Environment

- OS: macOS Ventura
- Browser: Chrome 116.0.5845.110
- Framework: /

Any additional comments?

The root cause is that ECharts uses Math.round in createClipPathFromCoordSys.ts:

const rect = cartesian.getArea();
let width = rect.width;
width = Math.round(width);

The width here can be a float with the decimal part less than 0.5:

image

Finally, it results in the incorrect clipPath, just 1px smaller than expected:

image

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 on x, I think it's okay to use Math.ceil on width to ensure the clipPath is large enough to contain the whole line (with cap).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenThis issue is in EnglishpendingWe are not sure about whether this is a bug/new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions