@visactor/vrender-components 0.20.3-alpha.0 → 0.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/axis/line.js +3 -2
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/overlap/auto-limit.d.ts +2 -0
- package/cjs/axis/overlap/auto-limit.js +23 -3
- package/cjs/axis/overlap/auto-limit.js.map +1 -1
- package/cjs/axis/type.d.ts +4 -0
- package/cjs/axis/type.js.map +1 -1
- package/cjs/axis/util.js +1 -2
- package/cjs/brush/brush.js +2 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/label/arc.d.ts +2 -0
- package/cjs/label/arc.js +28 -27
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/dataLabel.js +1 -0
- package/cjs/label/dataLabel.js.map +1 -1
- package/cjs/label/type.d.ts +3 -2
- package/cjs/label/type.js.map +1 -1
- package/cjs/label/util.d.ts +1 -0
- package/cjs/label/util.js +6 -2
- package/cjs/label/util.js.map +1 -1
- package/dist/index.es.js +75 -39
- package/es/axis/line.js +3 -2
- package/es/axis/line.js.map +1 -1
- package/es/axis/overlap/auto-limit.d.ts +2 -0
- package/es/axis/overlap/auto-limit.js +24 -4
- package/es/axis/overlap/auto-limit.js.map +1 -1
- package/es/axis/type.d.ts +4 -0
- package/es/axis/type.js.map +1 -1
- package/es/axis/util.js +1 -2
- package/es/brush/brush.js +2 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/label/arc.d.ts +2 -0
- package/es/label/arc.js +29 -26
- package/es/label/arc.js.map +1 -1
- package/es/label/dataLabel.js +1 -0
- package/es/label/dataLabel.js.map +1 -1
- package/es/label/type.d.ts +3 -2
- package/es/label/type.js.map +1 -1
- package/es/label/util.d.ts +1 -0
- package/es/label/util.js +4 -0
- package/es/label/util.js.map +1 -1
- package/package.json +5 -5
package/cjs/label/util.d.ts
CHANGED
package/cjs/label/util.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.connectLineBetweenBounds = exports.labelingLineOrArea = exports.getPointsOfLineArea = exports.labelingPoint = exports.degrees = exports.checkBoundsOverlap = exports.connectLineRadian = exports.lineCirclePoints = exports.isQuadrantRight = exports.isQuadrantLeft = void 0;
|
|
5
|
+
}), exports.getAlignOffset = exports.connectLineBetweenBounds = exports.labelingLineOrArea = exports.getPointsOfLineArea = exports.labelingPoint = exports.degrees = exports.checkBoundsOverlap = exports.connectLineRadian = exports.lineCirclePoints = exports.isQuadrantRight = exports.isQuadrantLeft = void 0;
|
|
6
6
|
|
|
7
7
|
const vutils_1 = require("@visactor/vutils");
|
|
8
8
|
|
|
@@ -169,6 +169,10 @@ function getIntersection(dx, dy, cx, cy, w, h) {
|
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
function getAlignOffset(align) {
|
|
173
|
+
return "left" === align ? 0 : "right" === align ? 1 : .5;
|
|
174
|
+
}
|
|
175
|
+
|
|
172
176
|
exports.getPointsOfLineArea = getPointsOfLineArea, exports.labelingLineOrArea = labelingLineOrArea,
|
|
173
|
-
exports.connectLineBetweenBounds = connectLineBetweenBounds;
|
|
177
|
+
exports.connectLineBetweenBounds = connectLineBetweenBounds, exports.getAlignOffset = getAlignOffset;
|
|
174
178
|
//# sourceMappingURL=util.js.map
|
package/cjs/label/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/label/util.ts"],"names":[],"mappings":";;;AAGA,6CAAoH;AAEpH,SAAgB,cAAc,CAAC,QAAkB;IAC/C,OAAO,QAAQ,KAAK,CAAC,IAAI,QAAQ,KAAK,CAAC,CAAC;AAC1C,CAAC;AAFD,wCAEC;AAED,SAAgB,eAAe,CAAC,QAAkB;IAChD,O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AAC,EAAE,CAAC;KACvE;IAED,OAAO,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACxE,CAAC","file":"util.js","sourcesContent":["import type { IArea, ILine } from '@visactor/vrender-core';\nimport type { IPoint, Quadrant } from './type';\nimport type { IBoundsLike, IPointLike } from '@visactor/vutils';\nimport { radianToDegree, isValidNumber, isRectIntersect, normalizeAngle, polarToCartesian } from '@visactor/vutils';\n\nexport function isQuadrantLeft(quadrant: Quadrant): boolean {\n return quadrant === 3 || quadrant === 4;\n}\n\nexport function isQuadrantRight(quadrant: Quadrant): boolean {\n return quadrant === 1 || quadrant === 2;\n}\n\n/**\n * 计算直线与圆交点\n * 直线方程:ax + by + c = 0\n * 圆方程:(x - x0)^2 + (y - y0)^2 = r^2\n */\nexport function lineCirclePoints(a: number, b: number, c: number, x0: number, y0: number, r: number): IPoint[] {\n if ((a === 0 && b === 0) || r <= 0) {\n return [];\n }\n if (a === 0) {\n const y1 = -c / b;\n const fy = (y1 - y0) ** 2;\n const fd = r ** 2 - fy;\n if (fd < 0) {\n return [];\n } else if (fd === 0) {\n return [{ x: x0, y: y1 }];\n }\n const x1 = Math.sqrt(fd) + x0;\n const x2 = -Math.sqrt(fd) + x0;\n return [\n { x: x1, y: y1 },\n { x: x2, y: y1 }\n ];\n } else if (b === 0) {\n const x1 = -c / a;\n const fx = (x1 - x0) ** 2;\n const fd = r ** 2 - fx;\n if (fd < 0) {\n return [];\n } else if (fd === 0) {\n return [{ x: x1, y: y0 }];\n }\n const y1 = Math.sqrt(fd) + y0;\n const y2 = -Math.sqrt(fd) + y0;\n return [\n { x: x1, y: y1 },\n { x: x1, y: y2 }\n ];\n }\n const fa = (b / a) ** 2 + 1;\n const fb = 2 * ((c / a + x0) * (b / a) - y0);\n const fc = (c / a + x0) ** 2 + y0 ** 2 - r ** 2;\n const fd = fb ** 2 - 4 * fa * fc;\n if (fd < 0) {\n return [];\n }\n const y1 = (-fb + Math.sqrt(fd)) / (2 * fa);\n const y2 = (-fb - Math.sqrt(fd)) / (2 * fa);\n const x1 = -(b * y1 + c) / a;\n const x2 = -(b * y2 + c) / a;\n if (fd === 0) {\n return [{ x: x1, y: y1 }];\n }\n return [\n { x: x1, y: y1 },\n { x: x2, y: y2 }\n ];\n}\n\n/**\n * 根据圆弧两点连接线长度计算弧度\n * @param radius 圆弧半径\n * @param length 连接线长度\n */\nexport function connectLineRadian(radius: number, length: number) {\n if (length > radius * 2) {\n return NaN;\n }\n return Math.asin(length / 2 / radius) * 2;\n}\n\nexport function checkBoundsOverlap(boundsA: IBoundsLike, boundsB: IBoundsLike): boolean {\n const { x1: ax1, y1: ay1, x2: ax2, y2: ay2 } = boundsA;\n const { x1: bx1, y1: by1, x2: bx2, y2: by2 } = boundsB;\n return !(\n (ax1 <= bx1 && ax2 <= bx1) ||\n (ax1 >= bx2 && ax2 >= bx2) ||\n (ay1 <= by1 && ay2 <= by1) ||\n (ay1 >= by2 && ay2 >= by2)\n );\n}\n\nexport const degrees = (angle?: number) => {\n if (!isValidNumber(angle)) {\n return null;\n }\n return radianToDegree(angle);\n};\n\nexport const labelingPoint = (textBounds: IBoundsLike, graphicBounds: IBoundsLike, position = 'top', offset = 0) => {\n if (!textBounds) {\n return;\n }\n\n const { x1, y1, x2, y2 } = textBounds;\n const width = Math.abs(x2 - x1);\n const height = Math.abs(y2 - y1);\n\n const anchorX = (graphicBounds.x1 + graphicBounds.x2) / 2;\n const anchorY = (graphicBounds.y1 + graphicBounds.y2) / 2;\n\n let sx = 0;\n let sy = 0;\n let offsetX = 0;\n let offsetY = 0;\n if (graphicBounds) {\n offsetX = Math.abs(graphicBounds.x1 - graphicBounds.x2) / 2;\n offsetY = Math.abs(graphicBounds.y1 - graphicBounds.y2) / 2;\n }\n\n const angle = {\n 'top-right': -235,\n 'top-left': 235,\n 'bottom-right': 45,\n 'bottom-left': -45\n };\n\n switch (position) {\n case 'top':\n sy = -1;\n break;\n case 'bottom':\n sy = 1;\n break;\n case 'left':\n sx = -1;\n break;\n case 'right':\n sx = 1;\n break;\n case 'bottom-left':\n case 'bottom-right':\n case 'top-left':\n case 'top-right':\n sx = Math.sin(angle[position] * (Math.PI / 180));\n sy = Math.cos(angle[position] * (Math.PI / 180));\n break;\n case 'center':\n sx = 0;\n sy = 0;\n break;\n }\n\n const x = anchorX + sx * (offset + offsetX) + Math.sign(sx) * (width / 2);\n const y = anchorY + sy * (offset + offsetY) + Math.sign(sy) * (height / 2);\n\n return { x, y };\n};\n\nexport const getPointsOfLineArea = (graphic: ILine | IArea): IPointLike[] => {\n if (!graphic || !graphic.attribute) {\n return [];\n }\n\n const { points, segments } = graphic.attribute;\n\n if (segments && segments.length) {\n const res: IPointLike[] = [];\n\n segments.forEach(seg => {\n const segPoints = seg.points;\n\n segPoints.forEach(point => {\n res.push(point);\n });\n });\n\n return res;\n }\n\n return points;\n};\n\nexport function labelingLineOrArea(\n textBounds: IBoundsLike,\n graphicBounds: IBoundsLike,\n position: string = 'end',\n offset = 0\n) {\n if (!textBounds || !graphicBounds) {\n return { x: Infinity, y: Infinity };\n }\n\n const { x1, x2 } = textBounds;\n const width = Math.abs(x2 - x1);\n\n const anchorX = graphicBounds.x1;\n const anchorY = graphicBounds.y1;\n\n let x = anchorX;\n const y = anchorY;\n\n if (position === 'end') {\n x = anchorX + width / 2 + offset;\n } else if (position === 'start') {\n x = anchorX - width / 2 - offset;\n }\n\n return { x, y };\n}\n\nexport function connectLineBetweenBounds(boundA: IBoundsLike, boundB: IBoundsLike) {\n if (!boundA || !boundB) {\n return;\n }\n\n if (isRectIntersect(boundA, boundB, true)) {\n return;\n }\n // Top left coordinates\n const x1 = Math.min(boundA.x1, boundA.x2);\n const y1 = Math.min(boundA.y1, boundA.y2);\n const x2 = Math.min(boundB.x1, boundB.x2);\n const y2 = Math.min(boundB.y1, boundB.y2);\n\n // Half widths and half heights\n const w1 = Math.abs(boundA.x2 - x1) / 2;\n const h1 = Math.abs(boundA.y2 - y1) / 2;\n const w2 = Math.abs(boundB.x2 - x2) / 2;\n const h2 = Math.abs(boundB.y2 - y2) / 2;\n\n // Center coordinates\n const cx1 = x1 + w1;\n const cy1 = y1 + h1;\n const cx2 = x2 + w2;\n const cy2 = y2 + h2;\n\n // Distance between centers\n const dx = cx2 - cx1;\n const dy = cy2 - cy1;\n\n const p1 = getIntersection(dx, dy, cx1, cy1, w1, h1);\n const p2 = getIntersection(-dx, -dy, cx2, cy2, w2, h2);\n\n return [p1, p2];\n}\n\nfunction getIntersection(dx: number, dy: number, cx: number, cy: number, w: number, h: number) {\n if (Math.abs(dy / dx) < h / w) {\n // Hit vertical edge of box1\n return { x: cx + (dx > 0 ? w : -w), y: cy + (dy * w) / Math.abs(dx) };\n }\n // Hit horizontal edge of box1\n return { x: cx + (dx * h) / Math.abs(dy), y: cy + (dy > 0 ? h : -h) };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/label/util.ts"],"names":[],"mappings":";;;AAGA,6CAAoH;AAEpH,SAAgB,cAAc,CAAC,QAAkB;IAC/C,OAAO,QAAQ,KAAK,CAAC,IAAI,QAAQ,KAAK,CAAC,CAAC;AAC1C,CAAC;AAFD,wCAEC;AAED,SAAgB,eAAe,CAAC,QAAkB;IAChD,OAAO,QAAQ,KAAK,CAAC,IAAI,QAAQ,KAAK,CAAC,CAAC;AAC1C,CAAC;AAFD,0CAEC;AAOD,SAAgB,gBAAgB,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,EAAU,EAAE,EAAU,EAAE,CAAS;IACjG,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAClC,OAAO,EAAE,CAAC;KACX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AAkC;IAC/D,IAAI,KAAK,KAAK,MAAM,EAAE;QACpB,OAAO,CAAC,CAAC;KACV;SAAM,IAAI,KAAK,KAAK,OAAO,EAAE;QAC5B,OAAO,CAAC,CAAC;KACV;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AARD,wCAQC","file":"util.js","sourcesContent":["import type { IArea, ILine } from '@visactor/vrender-core';\nimport type { IPoint, Quadrant } from './type';\nimport type { IBoundsLike, IPointLike } from '@visactor/vutils';\nimport { radianToDegree, isValidNumber, isRectIntersect, normalizeAngle, polarToCartesian } from '@visactor/vutils';\n\nexport function isQuadrantLeft(quadrant: Quadrant): boolean {\n return quadrant === 3 || quadrant === 4;\n}\n\nexport function isQuadrantRight(quadrant: Quadrant): boolean {\n return quadrant === 1 || quadrant === 2;\n}\n\n/**\n * 计算直线与圆交点\n * 直线方程:ax + by + c = 0\n * 圆方程:(x - x0)^2 + (y - y0)^2 = r^2\n */\nexport function lineCirclePoints(a: number, b: number, c: number, x0: number, y0: number, r: number): IPoint[] {\n if ((a === 0 && b === 0) || r <= 0) {\n return [];\n }\n if (a === 0) {\n const y1 = -c / b;\n const fy = (y1 - y0) ** 2;\n const fd = r ** 2 - fy;\n if (fd < 0) {\n return [];\n } else if (fd === 0) {\n return [{ x: x0, y: y1 }];\n }\n const x1 = Math.sqrt(fd) + x0;\n const x2 = -Math.sqrt(fd) + x0;\n return [\n { x: x1, y: y1 },\n { x: x2, y: y1 }\n ];\n } else if (b === 0) {\n const x1 = -c / a;\n const fx = (x1 - x0) ** 2;\n const fd = r ** 2 - fx;\n if (fd < 0) {\n return [];\n } else if (fd === 0) {\n return [{ x: x1, y: y0 }];\n }\n const y1 = Math.sqrt(fd) + y0;\n const y2 = -Math.sqrt(fd) + y0;\n return [\n { x: x1, y: y1 },\n { x: x1, y: y2 }\n ];\n }\n const fa = (b / a) ** 2 + 1;\n const fb = 2 * ((c / a + x0) * (b / a) - y0);\n const fc = (c / a + x0) ** 2 + y0 ** 2 - r ** 2;\n const fd = fb ** 2 - 4 * fa * fc;\n if (fd < 0) {\n return [];\n }\n const y1 = (-fb + Math.sqrt(fd)) / (2 * fa);\n const y2 = (-fb - Math.sqrt(fd)) / (2 * fa);\n const x1 = -(b * y1 + c) / a;\n const x2 = -(b * y2 + c) / a;\n if (fd === 0) {\n return [{ x: x1, y: y1 }];\n }\n return [\n { x: x1, y: y1 },\n { x: x2, y: y2 }\n ];\n}\n\n/**\n * 根据圆弧两点连接线长度计算弧度\n * @param radius 圆弧半径\n * @param length 连接线长度\n */\nexport function connectLineRadian(radius: number, length: number) {\n if (length > radius * 2) {\n return NaN;\n }\n return Math.asin(length / 2 / radius) * 2;\n}\n\nexport function checkBoundsOverlap(boundsA: IBoundsLike, boundsB: IBoundsLike): boolean {\n const { x1: ax1, y1: ay1, x2: ax2, y2: ay2 } = boundsA;\n const { x1: bx1, y1: by1, x2: bx2, y2: by2 } = boundsB;\n return !(\n (ax1 <= bx1 && ax2 <= bx1) ||\n (ax1 >= bx2 && ax2 >= bx2) ||\n (ay1 <= by1 && ay2 <= by1) ||\n (ay1 >= by2 && ay2 >= by2)\n );\n}\n\nexport const degrees = (angle?: number) => {\n if (!isValidNumber(angle)) {\n return null;\n }\n return radianToDegree(angle);\n};\n\nexport const labelingPoint = (textBounds: IBoundsLike, graphicBounds: IBoundsLike, position = 'top', offset = 0) => {\n if (!textBounds) {\n return;\n }\n\n const { x1, y1, x2, y2 } = textBounds;\n const width = Math.abs(x2 - x1);\n const height = Math.abs(y2 - y1);\n\n const anchorX = (graphicBounds.x1 + graphicBounds.x2) / 2;\n const anchorY = (graphicBounds.y1 + graphicBounds.y2) / 2;\n\n let sx = 0;\n let sy = 0;\n let offsetX = 0;\n let offsetY = 0;\n if (graphicBounds) {\n offsetX = Math.abs(graphicBounds.x1 - graphicBounds.x2) / 2;\n offsetY = Math.abs(graphicBounds.y1 - graphicBounds.y2) / 2;\n }\n\n const angle = {\n 'top-right': -235,\n 'top-left': 235,\n 'bottom-right': 45,\n 'bottom-left': -45\n };\n\n switch (position) {\n case 'top':\n sy = -1;\n break;\n case 'bottom':\n sy = 1;\n break;\n case 'left':\n sx = -1;\n break;\n case 'right':\n sx = 1;\n break;\n case 'bottom-left':\n case 'bottom-right':\n case 'top-left':\n case 'top-right':\n sx = Math.sin(angle[position] * (Math.PI / 180));\n sy = Math.cos(angle[position] * (Math.PI / 180));\n break;\n case 'center':\n sx = 0;\n sy = 0;\n break;\n }\n\n const x = anchorX + sx * (offset + offsetX) + Math.sign(sx) * (width / 2);\n const y = anchorY + sy * (offset + offsetY) + Math.sign(sy) * (height / 2);\n\n return { x, y };\n};\n\nexport const getPointsOfLineArea = (graphic: ILine | IArea): IPointLike[] => {\n if (!graphic || !graphic.attribute) {\n return [];\n }\n\n const { points, segments } = graphic.attribute;\n\n if (segments && segments.length) {\n const res: IPointLike[] = [];\n\n segments.forEach(seg => {\n const segPoints = seg.points;\n\n segPoints.forEach(point => {\n res.push(point);\n });\n });\n\n return res;\n }\n\n return points;\n};\n\nexport function labelingLineOrArea(\n textBounds: IBoundsLike,\n graphicBounds: IBoundsLike,\n position: string = 'end',\n offset = 0\n) {\n if (!textBounds || !graphicBounds) {\n return { x: Infinity, y: Infinity };\n }\n\n const { x1, x2 } = textBounds;\n const width = Math.abs(x2 - x1);\n\n const anchorX = graphicBounds.x1;\n const anchorY = graphicBounds.y1;\n\n let x = anchorX;\n const y = anchorY;\n\n if (position === 'end') {\n x = anchorX + width / 2 + offset;\n } else if (position === 'start') {\n x = anchorX - width / 2 - offset;\n }\n\n return { x, y };\n}\n\nexport function connectLineBetweenBounds(boundA: IBoundsLike, boundB: IBoundsLike) {\n if (!boundA || !boundB) {\n return;\n }\n\n if (isRectIntersect(boundA, boundB, true)) {\n return;\n }\n // Top left coordinates\n const x1 = Math.min(boundA.x1, boundA.x2);\n const y1 = Math.min(boundA.y1, boundA.y2);\n const x2 = Math.min(boundB.x1, boundB.x2);\n const y2 = Math.min(boundB.y1, boundB.y2);\n\n // Half widths and half heights\n const w1 = Math.abs(boundA.x2 - x1) / 2;\n const h1 = Math.abs(boundA.y2 - y1) / 2;\n const w2 = Math.abs(boundB.x2 - x2) / 2;\n const h2 = Math.abs(boundB.y2 - y2) / 2;\n\n // Center coordinates\n const cx1 = x1 + w1;\n const cy1 = y1 + h1;\n const cx2 = x2 + w2;\n const cy2 = y2 + h2;\n\n // Distance between centers\n const dx = cx2 - cx1;\n const dy = cy2 - cy1;\n\n const p1 = getIntersection(dx, dy, cx1, cy1, w1, h1);\n const p2 = getIntersection(-dx, -dy, cx2, cy2, w2, h2);\n\n return [p1, p2];\n}\n\nfunction getIntersection(dx: number, dy: number, cx: number, cy: number, w: number, h: number) {\n if (Math.abs(dy / dx) < h / w) {\n // Hit vertical edge of box1\n return { x: cx + (dx > 0 ? w : -w), y: cy + (dy * w) / Math.abs(dx) };\n }\n // Hit horizontal edge of box1\n return { x: cx + (dx * h) / Math.abs(dy), y: cy + (dy > 0 ? h : -h) };\n}\n\nexport function getAlignOffset(align: 'left' | 'right' | 'center') {\n if (align === 'left') {\n return 0;\n } else if (align === 'right') {\n return 1;\n }\n\n return 0.5;\n}\n"]}
|
package/dist/index.es.js
CHANGED
|
@@ -4550,7 +4550,7 @@ class Graphic extends Node {
|
|
|
4550
4550
|
return this._transMatrix || (this._transMatrix = new Matrix()), this.shouldUpdateLocalMatrix() && (this.doUpdateLocalMatrix(), clearTag && this.clearUpdateLocalPositionTag()), this._transMatrix;
|
|
4551
4551
|
}
|
|
4552
4552
|
shouldUpdateAABBBounds() {
|
|
4553
|
-
return this.shadowRoot ? !!(this._updateTag & UpdateTag.UPDATE_BOUNDS) || this.shadowRoot.shouldUpdateAABBBounds() : !!(this._updateTag & UpdateTag.UPDATE_BOUNDS);
|
|
4553
|
+
return this.shadowRoot ? (!!(this._updateTag & UpdateTag.UPDATE_BOUNDS) || this.shadowRoot.shouldUpdateAABBBounds()) && application.graphicService.validCheck(this.attribute, this.getGraphicTheme(), this._AABBBounds, this) : !!(this._updateTag & UpdateTag.UPDATE_BOUNDS) && application.graphicService.validCheck(this.attribute, this.getGraphicTheme(), this._AABBBounds, this);
|
|
4554
4554
|
}
|
|
4555
4555
|
shouldSelfChangeUpdateAABBBounds() {
|
|
4556
4556
|
return this.shadowRoot ? !!(this._updateTag & UpdateTag.UPDATE_BOUNDS) || this.shadowRoot.shouldUpdateAABBBounds() : !!(this._updateTag & UpdateTag.UPDATE_BOUNDS);
|
|
@@ -9293,7 +9293,6 @@ class Circle extends Graphic {
|
|
|
9293
9293
|
return getTheme(this).circle;
|
|
9294
9294
|
}
|
|
9295
9295
|
updateAABBBounds(attribute, circleTheme, aabbBounds, full) {
|
|
9296
|
-
if (!application.graphicService.validCheck(attribute, circleTheme, aabbBounds, this)) return aabbBounds;
|
|
9297
9296
|
this.updatePathProxyAABBBounds(aabbBounds) || (full ? this.updateCircleAABBBoundsImprecise(attribute, circleTheme, aabbBounds) : this.updateCircleAABBBoundsAccurate(attribute, circleTheme, aabbBounds));
|
|
9298
9297
|
const {
|
|
9299
9298
|
tb1: tb1,
|
|
@@ -9486,7 +9485,6 @@ class Text extends Graphic {
|
|
|
9486
9485
|
return getTheme(this).text;
|
|
9487
9486
|
}
|
|
9488
9487
|
updateAABBBounds(attribute, textTheme, aabbBounds) {
|
|
9489
|
-
if (!application.graphicService.validCheck(attribute, textTheme, aabbBounds, this)) return aabbBounds;
|
|
9490
9488
|
const {
|
|
9491
9489
|
text = textTheme.text
|
|
9492
9490
|
} = this.attribute;
|
|
@@ -10595,7 +10593,6 @@ let Symbol$1 = class Symbol extends Graphic {
|
|
|
10595
10593
|
return getTheme(this).symbol;
|
|
10596
10594
|
}
|
|
10597
10595
|
updateAABBBounds(attribute, symbolTheme, aabbBounds, full) {
|
|
10598
|
-
if (!application.graphicService.validCheck(attribute, symbolTheme, aabbBounds, this)) return aabbBounds;
|
|
10599
10596
|
this.updatePathProxyAABBBounds(aabbBounds) || (full ? this.updateSymbolAABBBoundsImprecise(attribute, symbolTheme, aabbBounds) : this.updateSymbolAABBBoundsAccurate(attribute, symbolTheme, aabbBounds));
|
|
10600
10597
|
const {
|
|
10601
10598
|
tb1: tb1,
|
|
@@ -10673,7 +10670,6 @@ let Line$1 = class Line extends Graphic {
|
|
|
10673
10670
|
return getTheme(this).line;
|
|
10674
10671
|
}
|
|
10675
10672
|
updateAABBBounds(attribute, lineTheme, aabbBounds) {
|
|
10676
|
-
if (!application.graphicService.validCheck(attribute, lineTheme, aabbBounds, this)) return aabbBounds;
|
|
10677
10673
|
this.updatePathProxyAABBBounds(aabbBounds) || (attribute.segments ? this.updateLineAABBBoundsBySegments(attribute, lineTheme, aabbBounds) : this.updateLineAABBBoundsByPoints(attribute, lineTheme, aabbBounds)), application.graphicService.updateTempAABBBounds(aabbBounds);
|
|
10678
10674
|
const {
|
|
10679
10675
|
lineJoin = lineTheme.lineJoin
|
|
@@ -10754,7 +10750,6 @@ class Rect extends Graphic {
|
|
|
10754
10750
|
return getTheme(this).rect;
|
|
10755
10751
|
}
|
|
10756
10752
|
updateAABBBounds(attribute, rectTheme, aabbBounds) {
|
|
10757
|
-
if (!application.graphicService.validCheck(attribute, rectTheme, aabbBounds, this)) return aabbBounds;
|
|
10758
10753
|
if (!this.updatePathProxyAABBBounds(aabbBounds)) {
|
|
10759
10754
|
let {
|
|
10760
10755
|
width: width,
|
|
@@ -11079,7 +11074,6 @@ class Image extends Graphic {
|
|
|
11079
11074
|
return getTheme(this).image;
|
|
11080
11075
|
}
|
|
11081
11076
|
updateAABBBounds(attribute, imageTheme, aabbBounds) {
|
|
11082
|
-
if (!application.graphicService.validCheck(attribute, imageTheme, aabbBounds, this)) return aabbBounds;
|
|
11083
11077
|
if (!this.updatePathProxyAABBBounds(aabbBounds)) {
|
|
11084
11078
|
const {
|
|
11085
11079
|
width = imageTheme.width,
|
|
@@ -11353,7 +11347,6 @@ class RichText extends Graphic {
|
|
|
11353
11347
|
return getTheme(this).richtext;
|
|
11354
11348
|
}
|
|
11355
11349
|
updateAABBBounds(attribute, richtextTheme, aabbBounds) {
|
|
11356
|
-
if (!application.graphicService.validCheck(attribute, richtextTheme, aabbBounds, this)) return aabbBounds;
|
|
11357
11350
|
const {
|
|
11358
11351
|
width = richtextTheme.width,
|
|
11359
11352
|
height = richtextTheme.height,
|
|
@@ -11570,7 +11563,6 @@ class Path extends Graphic {
|
|
|
11570
11563
|
return getTheme(this).path;
|
|
11571
11564
|
}
|
|
11572
11565
|
updateAABBBounds(attribute, pathTheme, aabbBounds) {
|
|
11573
|
-
if (!application.graphicService.validCheck(attribute, pathTheme, aabbBounds, this)) return aabbBounds;
|
|
11574
11566
|
if (!this.updatePathProxyAABBBounds(aabbBounds)) {
|
|
11575
11567
|
const pathShape = this.getParsedPathShape();
|
|
11576
11568
|
aabbBounds.union(pathShape.getBounds());
|
|
@@ -11636,7 +11628,6 @@ class Area extends Graphic {
|
|
|
11636
11628
|
return getTheme(this).area;
|
|
11637
11629
|
}
|
|
11638
11630
|
updateAABBBounds(attribute, areaTheme, aabbBounds) {
|
|
11639
|
-
if (!application.graphicService.validCheck(attribute, areaTheme, aabbBounds, this)) return aabbBounds;
|
|
11640
11631
|
this.updatePathProxyAABBBounds(aabbBounds) || (attribute.segments ? this.updateAreaAABBBoundsBySegments(attribute, areaTheme, aabbBounds) : this.updateAreaAABBBoundsByPoints(attribute, areaTheme, aabbBounds)), application.graphicService.updateTempAABBBounds(aabbBounds);
|
|
11641
11632
|
const {
|
|
11642
11633
|
lineJoin = areaTheme.lineJoin
|
|
@@ -11837,7 +11828,6 @@ class Arc extends Graphic {
|
|
|
11837
11828
|
return getTheme(this).arc;
|
|
11838
11829
|
}
|
|
11839
11830
|
updateAABBBounds(attribute, arcTheme, aabbBounds, full) {
|
|
11840
|
-
if (!application.graphicService.validCheck(attribute, arcTheme, aabbBounds, this)) return aabbBounds;
|
|
11841
11831
|
this.updatePathProxyAABBBounds(aabbBounds) || (full ? this.updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds) : this.updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds));
|
|
11842
11832
|
const {
|
|
11843
11833
|
tb1: tb1,
|
|
@@ -11945,7 +11935,6 @@ class Polygon extends Graphic {
|
|
|
11945
11935
|
return getTheme(this).polygon;
|
|
11946
11936
|
}
|
|
11947
11937
|
updateAABBBounds(attribute, polygonTheme, aabbBounds) {
|
|
11948
|
-
if (!application.graphicService.validCheck(attribute, polygonTheme, aabbBounds, this)) return aabbBounds;
|
|
11949
11938
|
this.updatePathProxyAABBBounds(aabbBounds) || this.updatePolygonAABBBoundsImprecise(attribute, polygonTheme, aabbBounds), application.graphicService.updateTempAABBBounds(aabbBounds);
|
|
11950
11939
|
const {
|
|
11951
11940
|
lineJoin = polygonTheme.lineJoin
|
|
@@ -16114,6 +16103,15 @@ function getIntersection(dx, dy, cx, cy, w, h) {
|
|
|
16114
16103
|
}
|
|
16115
16104
|
return { x: cx + (dx * h) / Math.abs(dy), y: cy + (dy > 0 ? h : -h) };
|
|
16116
16105
|
}
|
|
16106
|
+
function getAlignOffset(align) {
|
|
16107
|
+
if (align === 'left') {
|
|
16108
|
+
return 0;
|
|
16109
|
+
}
|
|
16110
|
+
else if (align === 'right') {
|
|
16111
|
+
return 1;
|
|
16112
|
+
}
|
|
16113
|
+
return 0.5;
|
|
16114
|
+
}
|
|
16117
16115
|
|
|
16118
16116
|
function loadLabelComponent() {
|
|
16119
16117
|
registerGroup();
|
|
@@ -16989,6 +16987,8 @@ class ArcLabel extends LabelBase {
|
|
|
16989
16987
|
this._ellipsisWidth = 0;
|
|
16990
16988
|
this._arcLeft = new Map();
|
|
16991
16989
|
this._arcRight = new Map();
|
|
16990
|
+
this._line2MinLength = 0;
|
|
16991
|
+
this._alignOffset = 0;
|
|
16992
16992
|
}
|
|
16993
16993
|
_overlapping(labels) {
|
|
16994
16994
|
return labels;
|
|
@@ -17000,6 +17000,7 @@ class ArcLabel extends LabelBase {
|
|
|
17000
17000
|
return { x: 0, y: 0 };
|
|
17001
17001
|
}
|
|
17002
17002
|
_layout(texts) {
|
|
17003
|
+
var _a;
|
|
17003
17004
|
if (!texts || !texts.length) {
|
|
17004
17005
|
return;
|
|
17005
17006
|
}
|
|
@@ -17013,7 +17014,15 @@ class ArcLabel extends LabelBase {
|
|
|
17013
17014
|
ellipsisWidth = ellipsisTextBounds.x2 - ellipsisTextBounds.x1;
|
|
17014
17015
|
}
|
|
17015
17016
|
const data = labels.map(label => label.attribute);
|
|
17016
|
-
const
|
|
17017
|
+
const currentMarks = Array.from(this._idToGraphic.values());
|
|
17018
|
+
this._line2MinLength = isFunction(this.attribute.line.line2MinLength)
|
|
17019
|
+
? this.attribute.line.line2MinLength(texts, currentMarks, this.attribute)
|
|
17020
|
+
: this.attribute.line.line2MinLength;
|
|
17021
|
+
this._alignOffset =
|
|
17022
|
+
(_a = (isFunction(this.attribute.layout.alignOffset)
|
|
17023
|
+
? this.attribute.layout.alignOffset(texts, currentMarks, this.attribute)
|
|
17024
|
+
: this.attribute.layout.alignOffset)) !== null && _a !== void 0 ? _a : 0;
|
|
17025
|
+
const arcs = this.layoutArcLabels(this.attribute.position, this.attribute, currentMarks, data, textBoundsArray, ellipsisWidth);
|
|
17017
17026
|
for (let i = 0; i < data.length; i++) {
|
|
17018
17027
|
const textData = data[i];
|
|
17019
17028
|
const basedArc = arcs.find(arc => { var _a; return ((_a = arc.refDatum) === null || _a === void 0 ? void 0 : _a.id) === textData.id; });
|
|
@@ -17160,13 +17169,12 @@ class ArcLabel extends LabelBase {
|
|
|
17160
17169
|
var _a, _b, _c;
|
|
17161
17170
|
const center = { x: (_a = currentMarks[0].attribute.x) !== null && _a !== void 0 ? _a : 0, y: (_b = currentMarks[0].attribute.y) !== null && _b !== void 0 ? _b : 0 };
|
|
17162
17171
|
const height = center.y * 2;
|
|
17163
|
-
const line2MinLength = attribute.line.line2MinLength;
|
|
17164
17172
|
const labelLayout = attribute.layout;
|
|
17165
17173
|
const spaceWidth = attribute.spaceWidth;
|
|
17166
17174
|
arcs.forEach(arc => {
|
|
17167
17175
|
const direction = isQuadrantLeft(arc.quadrant) ? -1 : 1;
|
|
17168
17176
|
arc.labelPosition = {
|
|
17169
|
-
x: arc.outerCenter.x + direction * (arc.labelSize.width / 2 +
|
|
17177
|
+
x: arc.outerCenter.x + direction * (arc.labelSize.width / 2 + this._line2MinLength + spaceWidth),
|
|
17170
17178
|
y: arc.outerCenter.y
|
|
17171
17179
|
};
|
|
17172
17180
|
});
|
|
@@ -17179,11 +17187,11 @@ class ArcLabel extends LabelBase {
|
|
|
17179
17187
|
arc.labelLimit = labelSize.width;
|
|
17180
17188
|
arc.pointB = isQuadrantLeft(arc.quadrant)
|
|
17181
17189
|
? {
|
|
17182
|
-
x: labelPosition.x + labelSize.width / 2 +
|
|
17190
|
+
x: labelPosition.x + labelSize.width / 2 + this._line2MinLength + spaceWidth,
|
|
17183
17191
|
y: labelPosition.y
|
|
17184
17192
|
}
|
|
17185
17193
|
: {
|
|
17186
|
-
x: labelPosition.x - labelSize.width / 2 -
|
|
17194
|
+
x: labelPosition.x - labelSize.width / 2 - this._line2MinLength - spaceWidth,
|
|
17187
17195
|
y: labelPosition.y
|
|
17188
17196
|
};
|
|
17189
17197
|
this._computeX(arc, attribute, currentMarks);
|
|
@@ -17212,22 +17220,27 @@ class ArcLabel extends LabelBase {
|
|
|
17212
17220
|
arcs.forEach(arc => {
|
|
17213
17221
|
var _a, _b;
|
|
17214
17222
|
if (arc.labelVisible &&
|
|
17215
|
-
(isLess(arc.pointB.x,
|
|
17216
|
-
isGreater(arc.pointB.x, width -
|
|
17223
|
+
(isLess(arc.pointB.x, this._line2MinLength + spaceWidth) ||
|
|
17224
|
+
isGreater(arc.pointB.x, width - this._line2MinLength - spaceWidth))) {
|
|
17217
17225
|
arc.labelVisible = false;
|
|
17218
17226
|
}
|
|
17219
17227
|
arc.angle = (_b = (_a = attribute.textStyle) === null || _a === void 0 ? void 0 : _a.angle) !== null && _b !== void 0 ? _b : 0;
|
|
17220
17228
|
if (attribute.offsetAngle) {
|
|
17221
17229
|
arc.angle += attribute.offsetAngle;
|
|
17222
17230
|
}
|
|
17223
|
-
arc.labelLine = Object.assign({}, attribute.line);
|
|
17231
|
+
arc.labelLine = Object.assign(Object.assign({}, attribute.line), { visible: arc.labelVisible });
|
|
17224
17232
|
});
|
|
17225
17233
|
return arcs;
|
|
17226
17234
|
}
|
|
17227
17235
|
_computeX(arc, attribute, currentMarks) {
|
|
17228
17236
|
var _a;
|
|
17229
17237
|
const center = arc.circleCenter;
|
|
17230
|
-
const plotLayout = {
|
|
17238
|
+
const plotLayout = {
|
|
17239
|
+
x1: 0,
|
|
17240
|
+
x2: this.attribute.width,
|
|
17241
|
+
y1: 0,
|
|
17242
|
+
y2: this.attribute.height
|
|
17243
|
+
};
|
|
17231
17244
|
let maxRadius = 0;
|
|
17232
17245
|
currentMarks.forEach((currentMark) => {
|
|
17233
17246
|
if (currentMark.attribute.outerRadius > maxRadius) {
|
|
@@ -17236,7 +17249,6 @@ class ArcLabel extends LabelBase {
|
|
|
17236
17249
|
});
|
|
17237
17250
|
const radiusRatio = this.computeLayoutOuterRadius(maxRadius, attribute.width, attribute.height);
|
|
17238
17251
|
const line1MinLength = attribute.line.line1MinLength;
|
|
17239
|
-
const line2MinLength = attribute.line.line2MinLength;
|
|
17240
17252
|
const labelLayoutAlign = (_a = attribute.layout) === null || _a === void 0 ? void 0 : _a.align;
|
|
17241
17253
|
const spaceWidth = attribute.spaceWidth;
|
|
17242
17254
|
const { labelPosition, quadrant, pointB } = arc;
|
|
@@ -17248,11 +17260,10 @@ class ArcLabel extends LabelBase {
|
|
|
17248
17260
|
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height);
|
|
17249
17261
|
const flag = isQuadrantLeft(quadrant) ? -1 : 1;
|
|
17250
17262
|
let cx = 0;
|
|
17251
|
-
|
|
17252
|
-
let limit = restWidth - line2MinLength - spaceWidth;
|
|
17263
|
+
let limit = (flag > 0 ? plotLayout.x2 - pointB.x : pointB.x - plotLayout.x1) - this._line2MinLength - spaceWidth;
|
|
17253
17264
|
if (labelLayoutAlign === 'labelLine') {
|
|
17254
|
-
cx = (radius + line1MinLength +
|
|
17255
|
-
limit = (flag > 0 ? plotLayout.
|
|
17265
|
+
cx = (radius + line1MinLength + this._line2MinLength) * flag + center.x;
|
|
17266
|
+
limit = (flag > 0 ? plotLayout.x2 - cx : cx - plotLayout.x1) - spaceWidth;
|
|
17256
17267
|
}
|
|
17257
17268
|
const text = this._getFormatLabelText(arc.refDatum, limit);
|
|
17258
17269
|
arc.labelText = text;
|
|
@@ -17261,24 +17272,25 @@ class ArcLabel extends LabelBase {
|
|
|
17261
17272
|
case 'labelLine':
|
|
17262
17273
|
break;
|
|
17263
17274
|
case 'edge':
|
|
17264
|
-
cx = flag > 0 ? plotLayout.
|
|
17275
|
+
cx = flag > 0 ? plotLayout.x2 - labelWidth - spaceWidth : plotLayout.x1 + labelWidth + spaceWidth;
|
|
17265
17276
|
break;
|
|
17266
17277
|
case 'arc':
|
|
17267
17278
|
default:
|
|
17268
|
-
cx = pointB.x + flag *
|
|
17279
|
+
cx = pointB.x + flag * this._line2MinLength;
|
|
17269
17280
|
break;
|
|
17270
17281
|
}
|
|
17271
17282
|
labelWidth = Math.max(this._ellipsisWidth, labelWidth);
|
|
17272
17283
|
arc.labelLimit = labelWidth;
|
|
17273
17284
|
arc.pointC = { x: cx, y: labelPosition.y };
|
|
17274
|
-
const
|
|
17285
|
+
const align = this._computeAlign(arc, attribute);
|
|
17286
|
+
const targetCenterOffset = getAlignOffset(align) * (arc.labelLimit < arc.labelSize.width ? arc.labelLimit : arc.labelSize.width);
|
|
17275
17287
|
if (labelLayoutAlign === 'edge') {
|
|
17276
|
-
|
|
17277
|
-
|
|
17288
|
+
labelPosition.x =
|
|
17289
|
+
(flag > 0 ? plotLayout.x2 : plotLayout.x1) - flag * targetCenterOffset + flag * this._alignOffset;
|
|
17290
|
+
arc.pointC.x += flag * this._alignOffset;
|
|
17278
17291
|
}
|
|
17279
17292
|
else {
|
|
17280
|
-
|
|
17281
|
-
labelPosition.x = cx + alignOffset + flag * (spaceWidth + targetCenterOffset);
|
|
17293
|
+
labelPosition.x = cx + flag * (this._alignOffset + spaceWidth + targetCenterOffset);
|
|
17282
17294
|
}
|
|
17283
17295
|
}
|
|
17284
17296
|
_computeAlign(arc, attribute) {
|
|
@@ -17736,6 +17748,10 @@ class DataLabel extends AbstractComponent {
|
|
|
17736
17748
|
if (labelComponent) {
|
|
17737
17749
|
const { baseMarkGroupName, type } = dataLabel;
|
|
17738
17750
|
const id = (_a = dataLabel.id) !== null && _a !== void 0 ? _a : `${baseMarkGroupName}-${type}-${i}`;
|
|
17751
|
+
if (dataLabel.type === 'arc') {
|
|
17752
|
+
dataLabel.width = size.width;
|
|
17753
|
+
dataLabel.height = size.height;
|
|
17754
|
+
}
|
|
17739
17755
|
let component = this._componentMap.get(id);
|
|
17740
17756
|
if (component) {
|
|
17741
17757
|
component.setBitmapTool(tool);
|
|
@@ -18995,11 +19011,27 @@ function getYAxisLabelAlign(orient, angle = 0) {
|
|
|
18995
19011
|
};
|
|
18996
19012
|
}
|
|
18997
19013
|
|
|
19014
|
+
function normalizeOverflowLimitLength(overflowLimitLength) {
|
|
19015
|
+
if (isValidNumber(overflowLimitLength)) {
|
|
19016
|
+
return {
|
|
19017
|
+
left: overflowLimitLength,
|
|
19018
|
+
right: overflowLimitLength
|
|
19019
|
+
};
|
|
19020
|
+
}
|
|
19021
|
+
else if (isObject(overflowLimitLength)) {
|
|
19022
|
+
return {
|
|
19023
|
+
left: overflowLimitLength.left || 0,
|
|
19024
|
+
right: overflowLimitLength.right || 0
|
|
19025
|
+
};
|
|
19026
|
+
}
|
|
19027
|
+
return { left: 0, right: 0 };
|
|
19028
|
+
}
|
|
18998
19029
|
function autoLimit(labels, config) {
|
|
18999
19030
|
const { limitLength, verticalLimitLength, ellipsis = '...', orient, axisLength } = config;
|
|
19000
19031
|
if (isEmpty(labels) || !isValidNumber(limitLength)) {
|
|
19001
19032
|
return;
|
|
19002
19033
|
}
|
|
19034
|
+
const overflowLimitLength = normalizeOverflowLimitLength(config.overflowLimitLength);
|
|
19003
19035
|
labels.forEach(label => {
|
|
19004
19036
|
var _a;
|
|
19005
19037
|
const angle = label.attribute.angle;
|
|
@@ -19036,14 +19068,17 @@ function autoLimit(labels, config) {
|
|
|
19036
19068
|
if (isX) {
|
|
19037
19069
|
const { x1, x2 } = label.AABBBounds;
|
|
19038
19070
|
const tan = sin / cos;
|
|
19071
|
+
const verticalSizeLimit = Math.abs(limitLength / sin);
|
|
19039
19072
|
if (tan > 0 && x1 <= axisLength && limitLength / tan + x1 > axisLength) {
|
|
19040
|
-
|
|
19073
|
+
const lengthLimit = (axisLength - x1) / Math.abs(cos) + overflowLimitLength.right;
|
|
19074
|
+
limitLabelLength = Math.min(lengthLimit, verticalSizeLimit);
|
|
19041
19075
|
}
|
|
19042
19076
|
else if (tan < 0 && x2 >= 0 && limitLength / tan + x2 < 0) {
|
|
19043
|
-
|
|
19077
|
+
const lengthLimit = x2 / Math.abs(cos) + overflowLimitLength.left;
|
|
19078
|
+
limitLabelLength = Math.min(lengthLimit, verticalSizeLimit);
|
|
19044
19079
|
}
|
|
19045
19080
|
else {
|
|
19046
|
-
limitLabelLength =
|
|
19081
|
+
limitLabelLength = verticalSizeLimit;
|
|
19047
19082
|
}
|
|
19048
19083
|
}
|
|
19049
19084
|
else {
|
|
@@ -19578,7 +19613,7 @@ class LineAxis extends AxisBase {
|
|
|
19578
19613
|
}
|
|
19579
19614
|
const { verticalLimitSize, label, orient } = this.attribute;
|
|
19580
19615
|
const limitLength = this._getAxisLabelLimitLength(verticalLimitSize, layerCount);
|
|
19581
|
-
const { layoutFunc, autoRotate: autoRotate$1, autoRotateAngle, autoLimit: autoLimit$1, limitEllipsis, autoHide: autoHide$1, autoHideMethod, autoHideSeparation, lastVisible, autoWrap: autoWrap$1 } = label;
|
|
19616
|
+
const { layoutFunc, autoRotate: autoRotate$1, autoRotateAngle, autoLimit: autoLimit$1, limitEllipsis, autoHide: autoHide$1, autoHideMethod, autoHideSeparation, lastVisible, autoWrap: autoWrap$1, overflowLimitLength } = label;
|
|
19582
19617
|
if (isFunction(layoutFunc)) {
|
|
19583
19618
|
layoutFunc(labelShapes, labelData, layer, this);
|
|
19584
19619
|
}
|
|
@@ -19611,7 +19646,8 @@ class LineAxis extends AxisBase {
|
|
|
19611
19646
|
verticalLimitLength,
|
|
19612
19647
|
ellipsis: limitEllipsis,
|
|
19613
19648
|
orient,
|
|
19614
|
-
axisLength
|
|
19649
|
+
axisLength,
|
|
19650
|
+
overflowLimitLength
|
|
19615
19651
|
});
|
|
19616
19652
|
}
|
|
19617
19653
|
if (autoHide$1) {
|
|
@@ -28783,6 +28819,6 @@ EmptyTip.defaultAttributes = {
|
|
|
28783
28819
|
}
|
|
28784
28820
|
};
|
|
28785
28821
|
|
|
28786
|
-
const version = "0.20.3
|
|
28822
|
+
const version = "0.20.3";
|
|
28787
28823
|
|
|
28788
28824
|
export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, ticks, traverseGroup, version };
|
package/es/axis/line.js
CHANGED
|
@@ -247,7 +247,7 @@ export class LineAxis extends AxisBase {
|
|
|
247
247
|
}
|
|
248
248
|
handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
249
249
|
if (isEmpty(labelShapes)) return;
|
|
250
|
-
const {verticalLimitSize: verticalLimitSize, label: label, orient: orient} = this.attribute, limitLength = this._getAxisLabelLimitLength(verticalLimitSize, layerCount), {layoutFunc: layoutFunc, autoRotate: autoRotate, autoRotateAngle: autoRotateAngle, autoLimit: autoLimit, limitEllipsis: limitEllipsis, autoHide: autoHide, autoHideMethod: autoHideMethod, autoHideSeparation: autoHideSeparation, lastVisible: lastVisible, autoWrap: autoWrap} = label;
|
|
250
|
+
const {verticalLimitSize: verticalLimitSize, label: label, orient: orient} = this.attribute, limitLength = this._getAxisLabelLimitLength(verticalLimitSize, layerCount), {layoutFunc: layoutFunc, autoRotate: autoRotate, autoRotateAngle: autoRotateAngle, autoLimit: autoLimit, limitEllipsis: limitEllipsis, autoHide: autoHide, autoHideMethod: autoHideMethod, autoHideSeparation: autoHideSeparation, lastVisible: lastVisible, autoWrap: autoWrap, overflowLimitLength: overflowLimitLength} = label;
|
|
251
251
|
if (isFunction(layoutFunc)) layoutFunc(labelShapes, labelData, layer, this); else {
|
|
252
252
|
if (autoRotate) autoRotateFunc(labelShapes, {
|
|
253
253
|
labelRotateAngle: autoRotateAngle,
|
|
@@ -268,7 +268,8 @@ export class LineAxis extends AxisBase {
|
|
|
268
268
|
verticalLimitLength: verticalLimitLength,
|
|
269
269
|
ellipsis: limitEllipsis,
|
|
270
270
|
orient: orient,
|
|
271
|
-
axisLength: axisLength
|
|
271
|
+
axisLength: axisLength,
|
|
272
|
+
overflowLimitLength: overflowLimitLength
|
|
272
273
|
});
|
|
273
274
|
}
|
|
274
275
|
autoHide && autoHideFunc(labelShapes, {
|