MCPcopy Index your code
hub / github.com/apache/echarts / buildPath

Method buildPath

src/chart/tree/TreeView.ts:94–130  ·  view source on GitHub ↗
(ctx: CanvasRenderingContext2D, shape: TreeEdgeShape)

Source from the content-addressed store, hash-verified

92 }
93
94 buildPath(ctx: CanvasRenderingContext2D, shape: TreeEdgeShape) {
95 const childPoints = shape.childPoints;
96 const childLen = childPoints.length;
97 const parentPoint = shape.parentPoint;
98 const firstChildPos = childPoints[0];
99 const lastChildPos = childPoints[childLen - 1];
100
101 if (childLen === 1) {
102 ctx.moveTo(parentPoint[0], parentPoint[1]);
103 ctx.lineTo(firstChildPos[0], firstChildPos[1]);
104 return;
105 }
106
107 const orient = shape.orient;
108 const forkDim = (orient === 'TB' || orient === 'BT') ? 0 : 1;
109 const otherDim = 1 - forkDim;
110 const forkPosition = parsePercent(shape.forkPosition, 1);
111 const tmpPoint = [];
112 tmpPoint[forkDim] = parentPoint[forkDim];
113 tmpPoint[otherDim] = parentPoint[otherDim] + (lastChildPos[otherDim] - parentPoint[otherDim]) * forkPosition;
114
115 ctx.moveTo(parentPoint[0], parentPoint[1]);
116 ctx.lineTo(tmpPoint[0], tmpPoint[1]);
117 ctx.moveTo(firstChildPos[0], firstChildPos[1]);
118 tmpPoint[forkDim] = firstChildPos[forkDim];
119 ctx.lineTo(tmpPoint[0], tmpPoint[1]);
120 tmpPoint[forkDim] = lastChildPos[forkDim];
121 ctx.lineTo(tmpPoint[0], tmpPoint[1]);
122 ctx.lineTo(lastChildPos[0], lastChildPos[1]);
123
124 for (let i = 1; i < childLen - 1; i++) {
125 const point = childPoints[i];
126 ctx.moveTo(point[0], point[1]);
127 tmpPoint[forkDim] = point[forkDim];
128 ctx.lineTo(tmpPoint[0], tmpPoint[1]);
129 }
130 }
131}
132
133class TreeView extends ChartView {

Callers

nothing calls this directly

Calls 1

moveToMethod · 0.45

Tested by

no test coverage detected