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

Function addZigzagShapes

src/component/axis/axisBreakHelperImpl.ts:196–317  ·  view source on GitHub ↗
(
        zigzagRandomList: number[],
        breakGroup: Group,
        startCoord: number,
        endCoord: number,
        isAxisHorizontal: boolean,
        trimmedBreak: ParsedAxisBreak
    )

Source from the content-addressed store, hash-verified

194 removeUnusedCacheVisual(cachedVisualList);
195
196 function addZigzagShapes(
197 zigzagRandomList: number[],
198 breakGroup: Group,
199 startCoord: number,
200 endCoord: number,
201 isAxisHorizontal: boolean,
202 trimmedBreak: ParsedAxisBreak
203 ) {
204 const polylineStyle = {
205 stroke: borderColor,
206 lineWidth: borderWidth,
207 lineDash: borderType,
208 fill: 'none'
209 };
210
211 const dimBrk = isAxisHorizontal ? 0 : 1;
212 const dimZigzag = 1 - dimBrk;
213 const zigzagCoordMax = coordSysRect[XY[dimZigzag]] + coordSysRect[WH[dimZigzag]];
214
215 // Apply `subPixelOptimizeLine` for alignning with break ticks.
216 function subPixelOpt(brkCoord: number): number {
217 const pBrk: number[] = [];
218 const dummyP: number[] = [];
219 pBrk[dimBrk] = dummyP[dimBrk] = brkCoord;
220 pBrk[dimZigzag] = coordSysRect[XY[dimZigzag]];
221 dummyP[dimZigzag] = zigzagCoordMax;
222 const dummyShape = {x1: pBrk[0], y1: pBrk[1], x2: dummyP[0], y2: dummyP[1]};
223 subPixelOptimizeLine(dummyShape, dummyShape, {lineWidth: 1});
224 pBrk[0] = dummyShape.x1;
225 pBrk[1] = dummyShape.y1;
226 return pBrk[dimBrk];
227 }
228 startCoord = subPixelOpt(startCoord);
229 endCoord = subPixelOpt(endCoord);
230
231 const pointsA = [];
232 const pointsB = [];
233
234 let isSwap = true;
235 let current = coordSysRect[XY[dimZigzag]];
236 for (let idx = 0; ; idx++) {
237 // Use `isFirstPoint` `isLastPoint` to ensure the intersections between zigzag
238 // and axis are precise, thus it can join its axis tick correctly.
239 const isFirstPoint = current === coordSysRect[XY[dimZigzag]];
240 const isLastPoint = current >= zigzagCoordMax;
241 if (isLastPoint) {
242 current = zigzagCoordMax;
243 }
244
245 const pA: number[] = [];
246 const pB: number[] = [];
247 pA[dimBrk] = startCoord;
248 pB[dimBrk] = endCoord;
249 if (!isFirstPoint && !isLastPoint) {
250 pA[dimBrk] += isSwap ? -zigzagAmplitude : zigzagAmplitude;
251 pB[dimBrk] -= !isSwap ? -zigzagAmplitude : zigzagAmplitude;
252 }
253 pA[dimZigzag] = current;

Callers 1

rectCoordBuildBreakAxisFunction · 0.85

Calls 3

getScaleBreakHelperFunction · 0.90
subPixelOptFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…