(
zigzagRandomList: number[],
breakGroup: Group,
startCoord: number,
endCoord: number,
isAxisHorizontal: boolean,
trimmedBreak: ParsedAxisBreak
)
| 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; |
no test coverage detected
searching dependent graphs…