(
cartesian: Cartesian2D,
hasAnimation: boolean,
seriesModel: SeriesModelWithLineWidth,
done?: () => void,
during?: (percent: number, clipRect: graphic.Rect) => void
)
| 32 | lineStyle?: { width?: number } |
| 33 | }>; |
| 34 | export function createGridClipPath( |
| 35 | cartesian: Cartesian2D, |
| 36 | hasAnimation: boolean, |
| 37 | seriesModel: SeriesModelWithLineWidth, |
| 38 | done?: () => void, |
| 39 | during?: (percent: number, clipRect: graphic.Rect) => void |
| 40 | ) { |
| 41 | const rect = cartesian.getArea(); |
| 42 | |
| 43 | let x = rect.x; |
| 44 | let y = rect.y; |
| 45 | let width = rect.width; |
| 46 | let height = rect.height; |
| 47 | |
| 48 | const lineWidth = seriesModel.get(['lineStyle', 'width']) || 0; |
| 49 | // Expand the clip path a bit to avoid the border is clipped and looks thinner |
| 50 | x -= lineWidth / 2; |
| 51 | y -= lineWidth / 2; |
| 52 | width += lineWidth; |
| 53 | height += lineWidth; |
| 54 | |
| 55 | // fix: https://github.com/apache/incubator-echarts/issues/11369 |
| 56 | width = Math.ceil(width); |
| 57 | if (x !== Math.floor(x)) { |
| 58 | x = Math.floor(x); |
| 59 | // if no extra 1px on `width`, it will still be clipped since `x` is floored |
| 60 | width++; |
| 61 | } |
| 62 | |
| 63 | const clipPath = new graphic.Rect({ |
| 64 | shape: { |
| 65 | x: x, |
| 66 | y: y, |
| 67 | width: width, |
| 68 | height: height |
| 69 | } |
| 70 | }); |
| 71 | |
| 72 | if (hasAnimation) { |
| 73 | const baseAxis = cartesian.getBaseAxis(); |
| 74 | const isHorizontal = baseAxis.isHorizontal(); |
| 75 | const isAxisInversed = baseAxis.inverse; |
| 76 | |
| 77 | if (isHorizontal) { |
| 78 | if (isAxisInversed) { |
| 79 | clipPath.shape.x += width; |
| 80 | } |
| 81 | clipPath.shape.width = 0; |
| 82 | } |
| 83 | else { |
| 84 | if (!isAxisInversed) { |
| 85 | clipPath.shape.y += height; |
| 86 | } |
| 87 | clipPath.shape.height = 0; |
| 88 | } |
| 89 | |
| 90 | const duringCb = isFunction(during) |
| 91 | ? (percent: number) => { |
no test coverage detected
searching dependent graphs…