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

Function cartesian2d

src/chart/bar/BarView.ts:684–727  ·  view source on GitHub ↗
(coordSysClipArea: CartesianCoordArea, layout: Rect['shape'])

Source from the content-addressed store, hash-verified

682 [key in 'cartesian2d' | 'polar']: Clipper
683} = {
684 cartesian2d(coordSysClipArea: CartesianCoordArea, layout: Rect['shape']) {
685 const signWidth = layout.width < 0 ? -1 : 1;
686 const signHeight = layout.height < 0 ? -1 : 1;
687 // Needs positive width and height
688 if (signWidth < 0) {
689 layout.x += layout.width;
690 layout.width = -layout.width;
691 }
692 if (signHeight < 0) {
693 layout.y += layout.height;
694 layout.height = -layout.height;
695 }
696
697 const coordSysX2 = coordSysClipArea.x + coordSysClipArea.width;
698 const coordSysY2 = coordSysClipArea.y + coordSysClipArea.height;
699 const x = mathMax(layout.x, coordSysClipArea.x);
700 const x2 = mathMin(layout.x + layout.width, coordSysX2);
701 const y = mathMax(layout.y, coordSysClipArea.y);
702 const y2 = mathMin(layout.y + layout.height, coordSysY2);
703
704 const xClipped = x2 < x;
705 const yClipped = y2 < y;
706
707 // When xClipped or yClipped, the element will be marked as `ignore`.
708 // But we should also place the element at the edge of the coord sys bounding rect.
709 // Because if data changed and the bar shows again, its transition animation
710 // will begin at this place.
711 layout.x = (xClipped && x > coordSysX2) ? x2 : x;
712 layout.y = (yClipped && y > coordSysY2) ? y2 : y;
713 layout.width = xClipped ? 0 : x2 - x;
714 layout.height = yClipped ? 0 : y2 - y;
715
716 // Reverse back
717 if (signWidth < 0) {
718 layout.x += layout.width;
719 layout.width = -layout.width;
720 }
721 if (signHeight < 0) {
722 layout.y += layout.height;
723 layout.height = -layout.height;
724 }
725
726 return xClipped || yClipped;
727 },
728
729 polar(coordSysClipArea: PolarCoordArea, layout: Sector['shape']) {
730 const signR = layout.r0 <= layout.r ? 1 : -1;

Callers

nothing calls this directly

Calls 4

extendFunction · 0.85
checkPropertiesNotValidFunction · 0.85
getLineWidthFunction · 0.85
getItemLayoutMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…