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

Function createLineClipPath

src/chart/line/LineView.ts:510–578  ·  view source on GitHub ↗
(
    lineView: LineView,
    coordSys: Cartesian2D | Polar,
    hasAnimation: boolean,
    seriesModel: LineSeriesModel
)

Source from the content-addressed store, hash-verified

508}
509
510function createLineClipPath(
511 lineView: LineView,
512 coordSys: Cartesian2D | Polar,
513 hasAnimation: boolean,
514 seriesModel: LineSeriesModel
515) {
516 if (isCoordinateSystemType<Cartesian2D>(coordSys, 'cartesian2d')) {
517 const endLabelModel = seriesModel.getModel('endLabel');
518 const valueAnimation = endLabelModel.get('valueAnimation');
519 const data = seriesModel.getData();
520
521 const labelAnimationRecord: EndLabelAnimationRecord = { lastFrameIndex: 0 };
522
523 const during = anyStateShowEndLabel(seriesModel)
524 ? (percent: number, clipRect: graphic.Rect) => {
525 lineView._endLabelOnDuring(
526 percent,
527 clipRect,
528 data,
529 labelAnimationRecord,
530 valueAnimation,
531 endLabelModel,
532 coordSys
533 );
534 }
535 : null;
536
537 const isHorizontal = coordSys.getBaseAxis().isHorizontal();
538 const clipPath = createGridClipPath(coordSys, hasAnimation, seriesModel, () => {
539 const endLabel = lineView._endLabel;
540 if (endLabel && hasAnimation) {
541 if (labelAnimationRecord.originalX != null) {
542 endLabel.attr({
543 x: labelAnimationRecord.originalX,
544 y: labelAnimationRecord.originalY
545 });
546 }
547 }
548 }, during);
549 // Expand clip shape to avoid clipping when line value exceeds axis
550 if (!seriesModel.get('clip', true)) {
551 const rectShape = clipPath.shape;
552 const expandSize = Math.max(rectShape.width, rectShape.height);
553 if (isHorizontal) {
554 rectShape.y -= expandSize;
555 rectShape.height += expandSize * 2;
556 }
557 else {
558 rectShape.x -= expandSize;
559 rectShape.width += expandSize * 2;
560 }
561 }
562
563 // Set to the final frame. To make sure label layout is right.
564 if (during) {
565 during(1, clipPath);
566 }
567 return clipPath;

Callers 1

renderMethod · 0.85

Calls 11

isCoordinateSystemTypeFunction · 0.90
createGridClipPathFunction · 0.90
createPolarClipPathFunction · 0.90
anyStateShowEndLabelFunction · 0.85
duringFunction · 0.85
_endLabelOnDuringMethod · 0.80
getDataMethod · 0.65
getBaseAxisMethod · 0.65
getModelMethod · 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…