MCPcopy
hub / github.com/apache/echarts / createGridClipPath

Function createGridClipPath

src/chart/helper/createClipPathFromCoordSys.ts:34–107  ·  view source on GitHub ↗
(
    cartesian: Cartesian2D,
    hasAnimation: boolean,
    seriesModel: SeriesModelWithLineWidth,
    done?: () => void,
    during?: (percent: number, clipRect: graphic.Rect) => void
)

Source from the content-addressed store, hash-verified

32 lineStyle?: { width?: number }
33}>;
34export 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) => {

Callers 2

createLineClipPathFunction · 0.90
createClipPathFunction · 0.85

Calls 6

duringFunction · 0.85
getBaseAxisMethod · 0.65
isFunctionFunction · 0.50
getAreaMethod · 0.45
getMethod · 0.45
isHorizontalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…