@visactor/vrender-components 0.18.6 → 0.18.7-alpha.1

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.
@@ -4,13 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.autoLimit = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), util_1 = require("./util");
7
+ const vutils_1 = require("@visactor/vutils");
8
8
 
9
9
  function autoLimit(labels, config) {
10
10
  const {limitLength: limitLength, verticalLimitLength: verticalLimitLength, ellipsis: ellipsis = "...", orient: orient, axisLength: axisLength} = config;
11
11
  !(0, vutils_1.isEmpty)(labels) && (0, vutils_1.isValidNumber)(limitLength) && labels.forEach((label => {
12
12
  var _a;
13
- const angle = label.attribute.angle, hasAngle = !(0, vutils_1.isNil)(angle), isHorizontal = !hasAngle || 0 === angle || angle === Math.PI, isVertical = hasAngle && (angle === Math.PI / 2 || angle === 2 * Math.PI / 3), isX = "top" === orient || "bottom" === orient;
13
+ const angle = label.attribute.angle, hasAngle = !(0, vutils_1.isNil)(angle), cos = hasAngle ? Math.cos(angle) : 1, sin = hasAngle ? Math.sin(angle) : 0, isHorizontal = !hasAngle || (0,
14
+ vutils_1.isNumberClose)(sin, 0), isVertical = hasAngle && (0, vutils_1.isNumberClose)(cos, 0), isX = "top" === orient || "bottom" === orient;
14
15
  if (isX) {
15
16
  if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) return;
16
17
  if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) return;
@@ -24,21 +25,15 @@ function autoLimit(labels, config) {
24
25
  }
25
26
  }
26
27
  let limitLabelLength = null;
27
- if (isHorizontal || isVertical) limitLabelLength = isX || "vertical" === direction ? verticalLimitLength : limitLength; else {
28
- const {x1: x, y1: y} = label.AABBBounds, width = isX ? axisLength : limitLength, height = isX ? limitLength : axisLength, intersection = (0,
29
- util_1.borderPoint)({
30
- width: width,
31
- height: height,
32
- left: 0,
33
- top: 0
34
- }, {
35
- x: x,
36
- y: y
37
- }, label.attribute.angle);
38
- if (intersection) {
39
- const {x: _x, y: _y} = intersection;
40
- limitLabelLength = Math.floor(Math.sqrt((_x - x) ** 2 + (_y - y) ** 2));
41
- } else limitLabelLength = Math.abs(limitLength / Math.sin(angle));
28
+ if (isHorizontal || isVertical) limitLabelLength = isX ? isHorizontal ? verticalLimitLength : limitLength : "vertical" === direction || isVertical ? verticalLimitLength : limitLength; else {
29
+ const cos = Math.cos(angle), sin = Math.sin(angle);
30
+ if (isX) {
31
+ const {x1: x1, x2: x2} = label.AABBBounds;
32
+ limitLabelLength = cos > 0 && x1 <= axisLength && cos * limitLength / Math.abs(sin) + x1 > axisLength ? (axisLength - x1) / cos : cos < 0 && x2 >= 0 && cos * limitLength / Math.abs(sin) + x2 < 0 ? -x2 / cos : Math.abs(limitLength / sin);
33
+ } else {
34
+ const {y1: y1, y2: y2} = label.AABBBounds;
35
+ limitLabelLength = sin > 0 && y2 >= 0 && y2 - sin * limitLength / Math.abs(cos) < 0 ? y2 / sin : sin < 0 && y1 <= axisLength && y1 - sin * limitLength / Math.abs(cos) > axisLength ? -(axisLength - y1) / sin : Math.abs(limitLength / cos);
36
+ }
42
37
  }
43
38
  (0, vutils_1.isValidNumber)(label.attribute.maxLineWidth) && (limitLabelLength = (0,
44
39
  vutils_1.isValidNumber)(limitLabelLength) ? Math.min(label.attribute.maxLineWidth, limitLabelLength) : label.attribute.maxLineWidth),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/overlap/auto-limit.ts"],"names":[],"mappings":";;;AAIA,6CAAiE;AACjE,iCAAqC;AAUrC,SAAgB,SAAS,CAAC,MAAe,EAAE,MAAmB;IAC5D,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,GAAG,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC1F,IAAI,IAAA,gBAAO,EAAC,MAAM,CAAC,IAAI,CAAC,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AG,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,WAAW,CAAC;SACjF;QAED,IAAI,IAAA,sBAAa,EAAC,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE;YAC/C,gBAAgB,GAAG,IAAA,sBAAa,EAAC,gBAAgB,CAAC;gBAChD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,EAAE,gBAAgB,CAAC;gBAC1D,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC;SAClC;QACD,KAAK,CAAC,aAAa,CAAC;YAClB,YAAY,EAAE,gBAAgB;YAC9B,QAAQ,EAAE,MAAA,KAAK,CAAC,SAAS,CAAC,QAAQ,mCAAI,QAAQ;SAC/C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAvED,8BAuEC","file":"auto-limit.js","sourcesContent":["/**\n * 自动省略\n */\nimport type { IText } from '@visactor/vrender-core';\nimport { isEmpty, isNil, isValidNumber } from '@visactor/vutils';\nimport { borderPoint } from './util';\n\ntype LimitConfig = {\n orient: string;\n limitLength: number;\n axisLength: number;\n verticalLimitLength?: number;\n ellipsis?: string;\n};\n\nexport function autoLimit(labels: IText[], config: LimitConfig) {\n const { limitLength, verticalLimitLength, ellipsis = '...', orient, axisLength } = config;\n if (isEmpty(labels) || !isValidNumber(limitLength)) {\n return;\n }\n\n labels.forEach(label => {\n const angle = label.attribute.angle;\n\n const hasAngle = !isNil(angle);\n const isHorizontal = !hasAngle || angle === 0 || angle === Math.PI;\n const isVertical = hasAngle && (angle === Math.PI / 2 || angle === (Math.PI * 2) / 3);\n const isX = orient === 'top' || orient === 'bottom';\n\n if (isX) {\n if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {\n return;\n }\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) {\n return;\n }\n }\n\n const direction = label.attribute.direction;\n if (!isX) {\n if (direction === 'vertical' && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {\n return;\n }\n\n if (direction !== 'vertical') {\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) {\n return;\n }\n if (isVertical && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {\n return;\n }\n }\n }\n\n // 如果水平并且文本未发生旋转,则不配置 maxLineWidth\n let limitLabelLength = null;\n\n if (!isHorizontal && !isVertical) {\n const { x1: x, y1: y } = label.AABBBounds;\n\n const width = isX ? axisLength : limitLength;\n const height = isX ? limitLength : axisLength;\n\n const intersection = borderPoint({ width, height, left: 0, top: 0 }, { x, y }, label.attribute.angle);\n if (intersection) {\n const { x: _x, y: _y } = intersection;\n limitLabelLength = Math.floor(Math.sqrt((_x - x) ** 2 + (_y - y) ** 2));\n } else {\n limitLabelLength = Math.abs(limitLength / Math.sin(angle));\n }\n } else if (isX) {\n limitLabelLength = verticalLimitLength;\n } else {\n limitLabelLength = direction === 'vertical' ? verticalLimitLength : limitLength;\n }\n\n if (isValidNumber(label.attribute.maxLineWidth)) {\n limitLabelLength = isValidNumber(limitLabelLength)\n ? Math.min(label.attribute.maxLineWidth, limitLabelLength)\n : label.attribute.maxLineWidth;\n }\n label.setAttributes({\n maxLineWidth: limitLabelLength,\n ellipsis: label.attribute.ellipsis ?? ellipsis\n });\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/axis/overlap/auto-limit.ts"],"names":[],"mappings":";;;AAIA,6CAAgF;AAUhF,SAAgB,SAAS,CAAC,MAAe,EAAE,MAAmB;IAC5D,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,GAAG,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC1F,IAAI,IAAA,gBAAO,EAAC,MAAM,CAAC,IAAI,CAAC,IAAA,sBAAa,EAAC,WAAW,CAAC,EAAE;QAClD,OAAO;KACR;IAED,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;;QACrB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* 自动省略\n */\nimport type { IText } from '@visactor/vrender-core';\nimport { isEmpty, isNil, isNumberClose, isValidNumber } from '@visactor/vutils';\n\ntype LimitConfig = {\n orient: string;\n limitLength: number;\n axisLength: number;\n verticalLimitLength?: number;\n ellipsis?: string;\n};\n\nexport function autoLimit(labels: IText[], config: LimitConfig) {\n const { limitLength, verticalLimitLength, ellipsis = '...', orient, axisLength } = config;\n if (isEmpty(labels) || !isValidNumber(limitLength)) {\n return;\n }\n\n labels.forEach(label => {\n const angle = label.attribute.angle;\n\n const hasAngle = !isNil(angle);\n const cos = hasAngle ? Math.cos(angle) : 1;\n const sin = hasAngle ? Math.sin(angle) : 0;\n const isHorizontal = !hasAngle || isNumberClose(sin, 0);\n const isVertical = hasAngle && isNumberClose(cos, 0);\n const isX = orient === 'top' || orient === 'bottom';\n\n if (isX) {\n if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {\n return;\n }\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) {\n return;\n }\n }\n\n const direction = label.attribute.direction;\n if (!isX) {\n if (direction === 'vertical' && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {\n return;\n }\n\n if (direction !== 'vertical') {\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) {\n return;\n }\n if (isVertical && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {\n return;\n }\n }\n }\n\n // 如果水平并且文本未发生旋转,则不配置 maxLineWidth\n let limitLabelLength = null;\n\n if (!isHorizontal && !isVertical) {\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n if (isX) {\n const { x1, x2 } = label.AABBBounds;\n\n if (cos > 0 && x1 <= axisLength && (cos * limitLength) / Math.abs(sin) + x1 > axisLength) {\n limitLabelLength = (axisLength - x1) / cos;\n } else if (cos < 0 && x2 >= 0 && (cos * limitLength) / Math.abs(sin) + x2 < 0) {\n limitLabelLength = -x2 / cos;\n } else {\n limitLabelLength = Math.abs(limitLength / sin);\n }\n } else {\n const { y1, y2 } = label.AABBBounds;\n\n if (sin > 0 && y2 >= 0 && y2 - (sin * limitLength) / Math.abs(cos) < 0) {\n limitLabelLength = y2 / sin;\n } else if (sin < 0 && y1 <= axisLength && y1 - (sin * limitLength) / Math.abs(cos) > axisLength) {\n limitLabelLength = -(axisLength - y1) / sin;\n } else {\n limitLabelLength = Math.abs(limitLength / cos);\n }\n }\n } else if (isX) {\n limitLabelLength = isHorizontal ? verticalLimitLength : limitLength;\n } else {\n limitLabelLength = direction === 'vertical' || isVertical ? verticalLimitLength : limitLength;\n }\n\n if (isValidNumber(label.attribute.maxLineWidth)) {\n limitLabelLength = isValidNumber(limitLabelLength)\n ? Math.min(label.attribute.maxLineWidth, limitLabelLength)\n : label.attribute.maxLineWidth;\n }\n label.setAttributes({\n maxLineWidth: limitLabelLength,\n ellipsis: label.attribute.ellipsis ?? ellipsis\n });\n });\n}\n"]}
@@ -1,15 +1,3 @@
1
1
  import type { IText } from '@visactor/vrender-core';
2
2
  export declare function genRotateBounds(items: IText[]): void;
3
3
  export declare function itemIntersect(item1: IText, item2: IText): boolean;
4
- export declare function borderPoint(rect: {
5
- left: number;
6
- top: number;
7
- width: number;
8
- height: number;
9
- }, pt: {
10
- x: number;
11
- y: number;
12
- }, angle: number): {
13
- x: number;
14
- y: number;
15
- };
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
- }), exports.borderPoint = exports.itemIntersect = exports.genRotateBounds = void 0;
5
+ }), exports.itemIntersect = exports.genRotateBounds = void 0;
6
6
 
7
7
  const vutils_1 = require("@visactor/vutils");
8
8
 
@@ -40,43 +40,5 @@ function itemIntersect(item1, item2) {
40
40
  vutils_1.isRotateAABBIntersect)(item1.rotatedBounds, item2.rotatedBounds, !0));
41
41
  }
42
42
 
43
- function borderPoint(rect, pt, angle) {
44
- if (pt.x < rect.left) return null;
45
- if (pt.x > rect.left + rect.width) return null;
46
- if (pt.y < rect.top) return null;
47
- if (pt.y > rect.top + rect.height) return null;
48
- const dx = Math.cos(angle), dy = Math.sin(angle);
49
- if (dx < 1e-16) {
50
- const y = (rect.left - pt.x) * dy / dx + pt.y;
51
- if (y >= rect.top && y <= rect.top + rect.height) return {
52
- x: rect.left,
53
- y: y
54
- };
55
- }
56
- if (dx > 1e-16) {
57
- const y = (rect.left + rect.width - pt.x) * dy / dx + pt.y;
58
- if (y >= rect.top && y <= rect.top + rect.height) return {
59
- x: rect.left + rect.width,
60
- y: y
61
- };
62
- }
63
- if (dy < 1e-16) {
64
- const x = (rect.top - pt.y) * dx / dy + pt.x;
65
- if (x >= rect.left && x <= rect.left + rect.width) return {
66
- x: x,
67
- y: rect.top
68
- };
69
- }
70
- if (dy > 1e-16) {
71
- const x = (rect.top + rect.height - pt.y) * dx / dy + pt.x;
72
- if (x >= rect.left && x <= rect.left + rect.width) return {
73
- x: x,
74
- y: rect.top + rect.height
75
- };
76
- }
77
- return null;
78
- }
79
-
80
- exports.genRotateBounds = genRotateBounds, exports.itemIntersect = itemIntersect,
81
- exports.borderPoint = borderPoint;
43
+ exports.genRotateBounds = genRotateBounds, exports.itemIntersect = itemIntersect;
82
44
  //# sourceMappingURL=util.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/overlap/util.ts"],"names":[],"mappings":";;;AACA,6CAA0E;AAE1E,SAAS,MAAM,CAAC,CAAS,EAAE,CAAS,EAAE,GAAW,EAAE,OAAe,EAAE,OAAe;IACjF,OAAO;QACL,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO;QAC1E,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,IAAI,C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AAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QAC7D,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE;YACjD,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;SAC5C;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AA1DD,kCA0DC","file":"util.js","sourcesContent":["import type { IText } from '@visactor/vrender-core';\nimport { isRectIntersect, isRotateAABBIntersect } from '@visactor/vutils';\n\nfunction rotate(x: number, y: number, deg: number, originX: number, originY: number) {\n return {\n x: (x - originX) * Math.cos(deg) + (y - originY) * Math.sin(deg) + originX,\n y: (x - originX) * Math.sin(deg) + (originY - y) * Math.cos(deg) + originY\n };\n}\n\n// 计算水平情况下的包围盒\nfunction genNormalBounds(item: IText) {\n const bounds = item.AABBBounds;\n\n return {\n x1: bounds.x1,\n x2: bounds.x2,\n y1: bounds.y1,\n y2: bounds.y2,\n centerX: item.attribute.x,\n centerY: item.attribute.y,\n angle: item.attribute.angle\n };\n}\n\nexport function genRotateBounds(items: IText[]) {\n items.forEach(item => {\n if (item.rotatedBounds || !item.attribute.angle) {\n return;\n }\n // 计算水平情况下的包围盒\n const bounds = genNormalBounds(item);\n // 旋转\n const rotatedCenter = rotate(bounds.centerX, bounds.centerY, bounds.angle, item.attribute.x, item.attribute.y);\n const deltaX = rotatedCenter.x - bounds.centerX;\n const deltaY = rotatedCenter.y - bounds.centerY;\n bounds.x1 += deltaX;\n bounds.x2 += deltaX;\n bounds.y1 += deltaY;\n bounds.y2 += deltaY;\n bounds.centerX += deltaX;\n bounds.centerY += deltaY;\n item.rotatedBounds = bounds;\n });\n}\n\nexport function itemIntersect(item1: IText, item2: IText) {\n return (\n isRectIntersect(item1.AABBBounds, item2.AABBBounds, false) &&\n (item1.rotatedBounds && item2.rotatedBounds\n ? isRotateAABBIntersect(item1.rotatedBounds, item2.rotatedBounds, true)\n : true)\n );\n}\n\n// 计算矩形内的点与矩形边的交点\nexport function borderPoint(\n rect: { left: number; top: number; width: number; height: number },\n pt: { x: number; y: number },\n angle: number\n) {\n // catch cases where point is outside rectangle\n if (pt.x < rect.left) {\n return null;\n }\n if (pt.x > rect.left + rect.width) {\n return null;\n }\n if (pt.y < rect.top) {\n return null;\n }\n if (pt.y > rect.top + rect.height) {\n return null;\n }\n\n const dx = Math.cos(angle);\n const dy = Math.sin(angle);\n\n if (dx < 1.0e-16) {\n // left border\n const y = ((rect.left - pt.x) * dy) / dx + pt.y;\n\n if (y >= rect.top && y <= rect.top + rect.height) {\n return { x: rect.left, y: y };\n }\n }\n\n if (dx > 1.0e-16) {\n // right border\n const y = ((rect.left + rect.width - pt.x) * dy) / dx + pt.y;\n\n if (y >= rect.top && y <= rect.top + rect.height) {\n return { x: rect.left + rect.width, y: y };\n }\n }\n\n if (dy < 1.0e-16) {\n // top border\n const x = ((rect.top - pt.y) * dx) / dy + pt.x;\n\n if (x >= rect.left && x <= rect.left + rect.width) {\n return { x: x, y: rect.top };\n }\n }\n\n if (dy > 1.0e-16) {\n // bottom border\n const x = ((rect.top + rect.height - pt.y) * dx) / dy + pt.x;\n if (x >= rect.left && x <= rect.left + rect.width) {\n return { x: x, y: rect.top + rect.height };\n }\n }\n\n return null;\n}\n"]}
1
+ {"version":3,"sources":["../src/axis/overlap/util.ts"],"names":[],"mappings":";;;AACA,6CAA0E;AAE1E,SAAS,MAAM,CAAC,CAAS,EAAE,CAAS,EAAE,GAAW,EAAE,OAAe,EAAE,OAAe;IACjF,OAAO;QACL,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO;QAC1E,CAAC,EAAE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;QACpB,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC;QACpB,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC;QACzB,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAnBD,0CAmBC;AAED,SAAgB,aAAa,CAAC,KAAY,EAAE,KAAY;IACtD,OAAO,CACL,IAAA,wBAAe,EAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC;QAC1D,CAAC,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,aAAa;YACzC,CAAC,CAAC,IAAA,8BAAqB,EAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC;YACvE,CAAC,CAAC,IAAI,CAAC,CACV,CAAC;AACJ,CAAC;AAPD,sCAOC","file":"util.js","sourcesContent":["import type { IText } from '@visactor/vrender-core';\nimport { isRectIntersect, isRotateAABBIntersect } from '@visactor/vutils';\n\nfunction rotate(x: number, y: number, deg: number, originX: number, originY: number) {\n return {\n x: (x - originX) * Math.cos(deg) + (y - originY) * Math.sin(deg) + originX,\n y: (x - originX) * Math.sin(deg) + (originY - y) * Math.cos(deg) + originY\n };\n}\n\n// 计算水平情况下的包围盒\nfunction genNormalBounds(item: IText) {\n const bounds = item.AABBBounds;\n\n return {\n x1: bounds.x1,\n x2: bounds.x2,\n y1: bounds.y1,\n y2: bounds.y2,\n centerX: item.attribute.x,\n centerY: item.attribute.y,\n angle: item.attribute.angle\n };\n}\n\nexport function genRotateBounds(items: IText[]) {\n items.forEach(item => {\n if (item.rotatedBounds || !item.attribute.angle) {\n return;\n }\n // 计算水平情况下的包围盒\n const bounds = genNormalBounds(item);\n // 旋转\n const rotatedCenter = rotate(bounds.centerX, bounds.centerY, bounds.angle, item.attribute.x, item.attribute.y);\n const deltaX = rotatedCenter.x - bounds.centerX;\n const deltaY = rotatedCenter.y - bounds.centerY;\n bounds.x1 += deltaX;\n bounds.x2 += deltaX;\n bounds.y1 += deltaY;\n bounds.y2 += deltaY;\n bounds.centerX += deltaX;\n bounds.centerY += deltaY;\n item.rotatedBounds = bounds;\n });\n}\n\nexport function itemIntersect(item1: IText, item2: IText) {\n return (\n isRectIntersect(item1.AABBBounds, item2.AABBBounds, false) &&\n (item1.rotatedBounds && item2.rotatedBounds\n ? isRotateAABBIntersect(item1.rotatedBounds, item2.rotatedBounds, true)\n : true)\n );\n}\n"]}
package/cjs/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "0.18.6";
1
+ export declare const version = "0.18.7-alpha.1";
2
2
  export * from './core/base';
3
3
  export * from './core/type';
4
4
  export * from './scrollbar';
package/cjs/index.js CHANGED
@@ -17,7 +17,7 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
17
17
 
18
18
  Object.defineProperty(exports, "__esModule", {
19
19
  value: !0
20
- }), exports.version = void 0, exports.version = "0.18.6", __exportStar(require("./core/base"), exports),
20
+ }), exports.version = void 0, exports.version = "0.18.7-alpha.1", __exportStar(require("./core/base"), exports),
21
21
  __exportStar(require("./core/type"), exports), __exportStar(require("./scrollbar"), exports),
22
22
  __exportStar(require("./tag"), exports), __exportStar(require("./poptip"), exports),
23
23
  __exportStar(require("./crosshair"), exports), __exportStar(require("./label"), exports),
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,8CAA4B;AAC5B,8CAA4B;AAC5B,8CAA4B;AAC5B,wCAAsB;AACtB,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B;AAC5B,4CAA0B;AAC1B,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,yCAAuB","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.18.6\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './util';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,gBAAgB,CAAC;AAExC,8CAA4B;AAC5B,8CAA4B;AAC5B,8CAA4B;AAC5B,wCAAsB;AACtB,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B;AAC5B,4CAA0B;AAC1B,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,yCAAuB","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.18.7-alpha.1\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './util';\n"]}
@@ -46,7 +46,9 @@ class Segment extends base_1.AbstractComponent {
46
46
  this.add(line);
47
47
  }));
48
48
  } else {
49
- const line = vrender_core_1.graphicCreator.polygon(Object.assign(Object.assign({
49
+ let lineCreator = vrender_core_1.graphicCreator.line;
50
+ (0, vutils_1.array)(lineStyle)[0].cornerRadius && (lineCreator = vrender_core_1.graphicCreator.polygon);
51
+ const line = lineCreator(Object.assign(Object.assign({
50
52
  points: this._clipPoints(this.attribute.points)
51
53
  }, (0, vutils_1.array)(lineStyle)[0]), {
52
54
  fill: !1,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/segment/segment.ts"],"names":[],"mappings":";;;AAGA,6CAA+F;AAE/F,yDAAwD;AACxD,uCAAiD;AAIjD,yCAAkD;AAElD,IAAA,+BAAoB,GAAE,CAAC;AACvB,MAAa,OAAQ,SAAQ,wBAA8C;IAUzE,aAAa;QACX,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAMD,WAAW;QACT,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAGD,oBAAoB;QAClB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAoCD,YAAY,UAA6B,EAAE,OAA0B;QACnE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,OAAO,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QA7D9F,SAAI,GAAG,SAAS,CAAC;IA8DjB,CAAC;IAES,MAAM;QACd,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI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AC;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;IACjC,CAAC;;AAxQH,0BAyQC;AA9OQ,yBAAiB,GAA+B;IACrD,OAAO,EAAE,IAAI;IACb,SAAS,EAAE;QACT,SAAS,EAAE,CAAC;QACZ,MAAM,EAAE,MAAM;KACf;IACD,WAAW,EAAE;QACX,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,UAAU;QACtB,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,CAAC;SACV;KACF;IACD,SAAS,EAAE;QACT,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,UAAU;QACtB,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,CAAC;SACV;KACF;CACF,CAAC","file":"segment.js","sourcesContent":["/**\n * @description 标签组件\n */\nimport { array, flattenArray, isArray, isEmpty, isValidNumber, merge } from '@visactor/vutils';\nimport type { ISymbol } from '@visactor/vrender-core';\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../core/base';\nimport type { SegmentAttributes, SymbolAttributes } from './type';\nimport type { Point } from '../core/type';\nimport type { ComponentOptions } from '../interface';\nimport { loadSegmentComponent } from './register';\n\nloadSegmentComponent();\nexport class Segment extends AbstractComponent<Required<SegmentAttributes>> {\n name = 'segment';\n\n startSymbol?: ISymbol;\n endSymbol?: ISymbol;\n\n private _startAngle!: number;\n /**\n * 外部获取segment起点正方向\n */\n getStartAngle() {\n return this._startAngle;\n }\n\n private _endAngle!: number;\n /**\n * 外部获取segment终点正方向\n */\n getEndAngle() {\n return this._endAngle;\n }\n\n private _mainSegmentPoints: Point[]; // 组成主线段的点\n getMainSegmentPoints() {\n return this._mainSegmentPoints;\n }\n\n static defaultAttributes: Partial<SegmentAttributes> = {\n visible: true,\n lineStyle: {\n lineWidth: 1,\n stroke: '#000'\n },\n startSymbol: {\n visible: false,\n autoRotate: true,\n symbolType: 'triangle',\n size: 12,\n refX: 0,\n refY: 0,\n refAngle: 0,\n style: {\n fill: '#000',\n zIndex: 1 // 默认 symbol 绘制在 line 上面\n }\n },\n endSymbol: {\n visible: false,\n autoRotate: true,\n symbolType: 'triangle',\n size: 12,\n refX: 0,\n refY: 0,\n refAngle: 0,\n style: {\n fill: '#000',\n zIndex: 1 // 默认 symbol 绘制在 line 上面\n }\n }\n };\n\n constructor(attributes: SegmentAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Segment.defaultAttributes, attributes));\n }\n\n protected render() {\n this.removeAllChild(true);\n this._reset();\n const {\n // points,\n startSymbol,\n endSymbol,\n lineStyle,\n state,\n visible = true,\n multiSegment,\n mainSegmentIndex\n } = this.attribute as SegmentAttributes;\n\n if (!visible) {\n return;\n }\n\n // 计算线的起点和终点角度\n // 计算角度的原因:\n // 1. segment symbol的自动旋转提供参数\n // 2. 使用segment时,需要根据line的角度对附加元素进行自动旋转(比如:markLine的标签, markPoint的装饰线)\n this._computeLineAngle();\n\n // 绘制start和end symbol\n const startSymbolShape = this._renderSymbol(startSymbol as SymbolAttributes, 'start');\n const endSymbolShape = this._renderSymbol(endSymbol as SymbolAttributes, 'end');\n\n this.startSymbol = startSymbolShape;\n this.endSymbol = endSymbolShape;\n\n if (multiSegment) {\n const points = [...this.attribute.points];\n if (isValidNumber(mainSegmentIndex)) {\n points[mainSegmentIndex] = this._clipPoints(points[mainSegmentIndex] as Point[]);\n } else {\n const clipPoints = this._clipPoints(flattenArray(points) as Point[]);\n points[0][0] = clipPoints[0];\n (points[points.length - 1] as Point[])[(points[points.length - 1] as Point[]).length - 1] =\n clipPoints[clipPoints.length - 1];\n }\n points.forEach((point: Point[], index) => {\n const line = graphicCreator.line({\n points: point,\n ...(isArray(lineStyle) ? lineStyle[index] ?? lineStyle[lineStyle.length - 1] : lineStyle),\n fill: false\n });\n\n line.name = `${this.name}-line`;\n line.id = this._getNodeId('line' + index);\n if (!isEmpty(state?.line)) {\n line.states = isArray(state.line) ? state.line[index] ?? state.line[state.line.length - 1] : state.line;\n }\n this.add(line);\n });\n } else {\n const line = graphicCreator.polygon({\n points: this._clipPoints(this.attribute.points as Point[]),\n ...array(lineStyle)[0],\n fill: false,\n closePath: false\n });\n\n line.name = `${this.name}-line`;\n line.id = this._getNodeId('line');\n if (!isEmpty(state?.line)) {\n line.states = [].concat(state.line)[0];\n }\n this.add(line);\n }\n }\n\n private _renderSymbol(attribute: SymbolAttributes, dim: string): ISymbol | undefined {\n const points = this._getMainSegmentPoints();\n if (!points.length) {\n return;\n }\n\n const { autoRotate = true } = attribute;\n let symbol;\n if (attribute && attribute.visible) {\n const startAngle = this._startAngle;\n const endAngle = this._endAngle;\n const { state } = this.attribute as SegmentAttributes;\n const start = points[0];\n const end = points[points.length - 1];\n const { refX = 0, refY = 0, refAngle = 0, style, symbolType, size = 12 } = attribute;\n let position;\n let rotate;\n if (dim === 'start') {\n position = {\n x:\n start.x +\n (isValidNumber(startAngle) ? refX * Math.cos(startAngle) + refY * Math.cos(startAngle - Math.PI / 2) : 0),\n y:\n start.y +\n (isValidNumber(startAngle) ? refX * Math.sin(startAngle) + refY * Math.sin(startAngle - Math.PI / 2) : 0)\n };\n rotate = startAngle + Math.PI / 2; // @chensiji - 加Math.PI / 2是因为:默认symbol的包围盒垂直于line,所以在做自动旋转时需要在line正方向基础上做90度偏移\n } else {\n position = {\n x:\n end.x + (isValidNumber(endAngle) ? refX * Math.cos(endAngle) + refY * Math.cos(endAngle - Math.PI / 2) : 0),\n y: end.y + (isValidNumber(endAngle) ? refX * Math.sin(endAngle) + refY * Math.sin(endAngle - Math.PI / 2) : 0)\n };\n rotate = endAngle + Math.PI / 2;\n }\n\n symbol = graphicCreator.symbol({\n ...position,\n symbolType: symbolType as string,\n size,\n angle: autoRotate ? rotate + refAngle : 0,\n strokeBoundsBuffer: 0,\n ...style\n });\n symbol.name = `${this.name}-${dim}-symbol`;\n symbol.id = this._getNodeId(`${dim}-symbol`);\n\n if (!isEmpty(state?.symbol)) {\n symbol.states = state.symbol;\n }\n\n this.add(symbol);\n }\n return symbol;\n }\n\n private _getMainSegmentPoints(): Point[] {\n if (this._mainSegmentPoints) {\n return this._mainSegmentPoints;\n }\n const { points: originPoints, multiSegment, mainSegmentIndex } = this.attribute as SegmentAttributes;\n\n let points: Point[];\n // 需要做下约束判断\n if (multiSegment) {\n if (isValidNumber(mainSegmentIndex)) {\n points = originPoints[mainSegmentIndex] as Point[];\n } else {\n points = flattenArray(originPoints);\n }\n } else {\n points = originPoints as Point[];\n }\n this._mainSegmentPoints = points;\n\n return points;\n }\n\n private _clipPoints(points: Point[]) {\n const { startSymbol = {} as SegmentAttributes['startSymbol'], endSymbol = {} as SegmentAttributes['endSymbol'] } =\n this.attribute as SegmentAttributes;\n // 通过改变line起点和终点的方式达到symbol在fill为false的情况下,也可以遮盖line的效果\n let pointsAfterClip = points;\n if (startSymbol.visible) {\n const startSize = startSymbol.clip ? startSymbol.size || 10 : 0;\n const pointsStart = {\n x: points[0].x - (startSize / 2) * (Math.cos(this._startAngle) || 0),\n y: points[0].y - (startSize / 2) * (Math.sin(this._startAngle) || 0)\n };\n pointsAfterClip = [pointsStart, ...pointsAfterClip.slice(1)];\n }\n if (endSymbol.visible) {\n const endSize = endSymbol.clip ? endSymbol.size || 10 : 0;\n const pointsEnd = {\n x: points[points.length - 1].x - (endSize / 2) * (Math.cos(this._endAngle) || 0),\n y: points[points.length - 1].y - (endSize / 2) * (Math.sin(this._endAngle) || 0)\n };\n pointsAfterClip = [...pointsAfterClip.slice(0, pointsAfterClip.length - 1), pointsEnd];\n }\n\n return pointsAfterClip;\n }\n\n private _computeLineAngle() {\n const points = this._getMainSegmentPoints();\n if (points.length <= 1) {\n return;\n }\n const start = points[0];\n const startInside = points[1];\n const endInside = points[points.length - 2];\n const end = points[points.length - 1];\n const startVector = [start.x - startInside.x, start.y - startInside.y]; // 起点正方向向量\n const startAngle = Math.atan2(startVector[1], startVector[0]); // 起点正方向角度\n const endVector = [end.x - endInside.x, end.y - endInside.y]; // 终点正方向向量\n const endAngle = Math.atan2(endVector[1], endVector[0]); // 终点正方向角度\n\n this._startAngle = startAngle;\n this._endAngle = endAngle;\n }\n\n private _reset() {\n this.startSymbol = null;\n this.endSymbol = null;\n this._startAngle = null;\n this._endAngle = null;\n this._mainSegmentPoints = null;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/segment/segment.ts"],"names":[],"mappings":";;;AAGA,6CAA+F;AAE/F,yDAAwD;AACxD,uCAAiD;AAIjD,yCAAkD;AAElD,IAAA,+BAAoB,GAAE,CAAC;AACvB,MAAa,OAAQ,SAAQ,wBAA8C;IAUzE,aAAa;QACX,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAMD,WAAW;QACT,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAGD,oBAAoB;QAClB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAoCD,YAAY,UAA6B,EAAE,OAA0B;QACnE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,OAAO,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QA7D9F,SAAI,GAAG,SAAS,CAAC;IA8DjB,CAAC;IAES,MAAM;QACd,IAAI,CAAC,cAAc,CAAC,IAAI,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AE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAExD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAEO,MAAM;QACZ,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;IACjC,CAAC;;AA7QH,0BA8QC;AAnPQ,yBAAiB,GAA+B;IACrD,OAAO,EAAE,IAAI;IACb,SAAS,EAAE;QACT,SAAS,EAAE,CAAC;QACZ,MAAM,EAAE,MAAM;KACf;IACD,WAAW,EAAE;QACX,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,UAAU;QACtB,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,CAAC;SACV;KACF;IACD,SAAS,EAAE;QACT,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,UAAU;QACtB,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,CAAC;SACV;KACF;CACF,CAAC","file":"segment.js","sourcesContent":["/**\n * @description 标签组件\n */\nimport { array, flattenArray, isArray, isEmpty, isValidNumber, merge } from '@visactor/vutils';\nimport type { ISymbol } from '@visactor/vrender-core';\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../core/base';\nimport type { ILineGraphicWithCornerRadius, SegmentAttributes, SymbolAttributes } from './type';\nimport type { Point } from '../core/type';\nimport type { ComponentOptions } from '../interface';\nimport { loadSegmentComponent } from './register';\n\nloadSegmentComponent();\nexport class Segment extends AbstractComponent<Required<SegmentAttributes>> {\n name = 'segment';\n\n startSymbol?: ISymbol;\n endSymbol?: ISymbol;\n\n private _startAngle!: number;\n /**\n * 外部获取segment起点正方向\n */\n getStartAngle() {\n return this._startAngle;\n }\n\n private _endAngle!: number;\n /**\n * 外部获取segment终点正方向\n */\n getEndAngle() {\n return this._endAngle;\n }\n\n private _mainSegmentPoints: Point[]; // 组成主线段的点\n getMainSegmentPoints() {\n return this._mainSegmentPoints;\n }\n\n static defaultAttributes: Partial<SegmentAttributes> = {\n visible: true,\n lineStyle: {\n lineWidth: 1,\n stroke: '#000'\n },\n startSymbol: {\n visible: false,\n autoRotate: true,\n symbolType: 'triangle',\n size: 12,\n refX: 0,\n refY: 0,\n refAngle: 0,\n style: {\n fill: '#000',\n zIndex: 1 // 默认 symbol 绘制在 line 上面\n }\n },\n endSymbol: {\n visible: false,\n autoRotate: true,\n symbolType: 'triangle',\n size: 12,\n refX: 0,\n refY: 0,\n refAngle: 0,\n style: {\n fill: '#000',\n zIndex: 1 // 默认 symbol 绘制在 line 上面\n }\n }\n };\n\n constructor(attributes: SegmentAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Segment.defaultAttributes, attributes));\n }\n\n protected render() {\n this.removeAllChild(true);\n this._reset();\n const {\n // points,\n startSymbol,\n endSymbol,\n lineStyle,\n state,\n visible = true,\n multiSegment,\n mainSegmentIndex\n } = this.attribute as SegmentAttributes;\n\n if (!visible) {\n return;\n }\n\n // 计算线的起点和终点角度\n // 计算角度的原因:\n // 1. segment symbol的自动旋转提供参数\n // 2. 使用segment时,需要根据line的角度对附加元素进行自动旋转(比如:markLine的标签, markPoint的装饰线)\n this._computeLineAngle();\n\n // 绘制start和end symbol\n const startSymbolShape = this._renderSymbol(startSymbol as SymbolAttributes, 'start');\n const endSymbolShape = this._renderSymbol(endSymbol as SymbolAttributes, 'end');\n\n this.startSymbol = startSymbolShape;\n this.endSymbol = endSymbolShape;\n\n if (multiSegment) {\n const points = [...this.attribute.points];\n if (isValidNumber(mainSegmentIndex)) {\n points[mainSegmentIndex] = this._clipPoints(points[mainSegmentIndex] as Point[]);\n } else {\n const clipPoints = this._clipPoints(flattenArray(points) as Point[]);\n points[0][0] = clipPoints[0];\n (points[points.length - 1] as Point[])[(points[points.length - 1] as Point[]).length - 1] =\n clipPoints[clipPoints.length - 1];\n }\n points.forEach((point: Point[], index) => {\n const line = graphicCreator.line({\n points: point,\n ...(isArray(lineStyle) ? lineStyle[index] ?? lineStyle[lineStyle.length - 1] : lineStyle),\n fill: false\n });\n\n line.name = `${this.name}-line`;\n line.id = this._getNodeId('line' + index);\n if (!isEmpty(state?.line)) {\n line.states = isArray(state.line) ? state.line[index] ?? state.line[state.line.length - 1] : state.line;\n }\n this.add(line);\n });\n } else {\n // 如果配置了cornerRadius, 则绘制polygon, 否则绘制line\n let lineCreator = graphicCreator.line;\n if ((array(lineStyle)[0] as ILineGraphicWithCornerRadius).cornerRadius) {\n lineCreator = graphicCreator.polygon;\n }\n const line = lineCreator({\n points: this._clipPoints(this.attribute.points as Point[]),\n ...array(lineStyle)[0],\n fill: false,\n closePath: false\n });\n\n line.name = `${this.name}-line`;\n line.id = this._getNodeId('line');\n if (!isEmpty(state?.line)) {\n line.states = [].concat(state.line)[0];\n }\n this.add(line);\n }\n }\n\n private _renderSymbol(attribute: SymbolAttributes, dim: string): ISymbol | undefined {\n const points = this._getMainSegmentPoints();\n if (!points.length) {\n return;\n }\n\n const { autoRotate = true } = attribute;\n let symbol;\n if (attribute && attribute.visible) {\n const startAngle = this._startAngle;\n const endAngle = this._endAngle;\n const { state } = this.attribute as SegmentAttributes;\n const start = points[0];\n const end = points[points.length - 1];\n const { refX = 0, refY = 0, refAngle = 0, style, symbolType, size = 12 } = attribute;\n let position;\n let rotate;\n if (dim === 'start') {\n position = {\n x:\n start.x +\n (isValidNumber(startAngle) ? refX * Math.cos(startAngle) + refY * Math.cos(startAngle - Math.PI / 2) : 0),\n y:\n start.y +\n (isValidNumber(startAngle) ? refX * Math.sin(startAngle) + refY * Math.sin(startAngle - Math.PI / 2) : 0)\n };\n rotate = startAngle + Math.PI / 2; // @chensiji - 加Math.PI / 2是因为:默认symbol的包围盒垂直于line,所以在做自动旋转时需要在line正方向基础上做90度偏移\n } else {\n position = {\n x:\n end.x + (isValidNumber(endAngle) ? refX * Math.cos(endAngle) + refY * Math.cos(endAngle - Math.PI / 2) : 0),\n y: end.y + (isValidNumber(endAngle) ? refX * Math.sin(endAngle) + refY * Math.sin(endAngle - Math.PI / 2) : 0)\n };\n rotate = endAngle + Math.PI / 2;\n }\n\n symbol = graphicCreator.symbol({\n ...position,\n symbolType: symbolType as string,\n size,\n angle: autoRotate ? rotate + refAngle : 0,\n strokeBoundsBuffer: 0,\n ...style\n });\n symbol.name = `${this.name}-${dim}-symbol`;\n symbol.id = this._getNodeId(`${dim}-symbol`);\n\n if (!isEmpty(state?.symbol)) {\n symbol.states = state.symbol;\n }\n\n this.add(symbol);\n }\n return symbol;\n }\n\n private _getMainSegmentPoints(): Point[] {\n if (this._mainSegmentPoints) {\n return this._mainSegmentPoints;\n }\n const { points: originPoints, multiSegment, mainSegmentIndex } = this.attribute as SegmentAttributes;\n\n let points: Point[];\n // 需要做下约束判断\n if (multiSegment) {\n if (isValidNumber(mainSegmentIndex)) {\n points = originPoints[mainSegmentIndex] as Point[];\n } else {\n points = flattenArray(originPoints);\n }\n } else {\n points = originPoints as Point[];\n }\n this._mainSegmentPoints = points;\n\n return points;\n }\n\n private _clipPoints(points: Point[]) {\n const { startSymbol = {} as SegmentAttributes['startSymbol'], endSymbol = {} as SegmentAttributes['endSymbol'] } =\n this.attribute as SegmentAttributes;\n // 通过改变line起点和终点的方式达到symbol在fill为false的情况下,也可以遮盖line的效果\n let pointsAfterClip = points;\n if (startSymbol.visible) {\n const startSize = startSymbol.clip ? startSymbol.size || 10 : 0;\n const pointsStart = {\n x: points[0].x - (startSize / 2) * (Math.cos(this._startAngle) || 0),\n y: points[0].y - (startSize / 2) * (Math.sin(this._startAngle) || 0)\n };\n pointsAfterClip = [pointsStart, ...pointsAfterClip.slice(1)];\n }\n if (endSymbol.visible) {\n const endSize = endSymbol.clip ? endSymbol.size || 10 : 0;\n const pointsEnd = {\n x: points[points.length - 1].x - (endSize / 2) * (Math.cos(this._endAngle) || 0),\n y: points[points.length - 1].y - (endSize / 2) * (Math.sin(this._endAngle) || 0)\n };\n pointsAfterClip = [...pointsAfterClip.slice(0, pointsAfterClip.length - 1), pointsEnd];\n }\n\n return pointsAfterClip;\n }\n\n private _computeLineAngle() {\n const points = this._getMainSegmentPoints();\n if (points.length <= 1) {\n return;\n }\n const start = points[0];\n const startInside = points[1];\n const endInside = points[points.length - 2];\n const end = points[points.length - 1];\n const startVector = [start.x - startInside.x, start.y - startInside.y]; // 起点正方向向量\n const startAngle = Math.atan2(startVector[1], startVector[0]); // 起点正方向角度\n const endVector = [end.x - endInside.x, end.y - endInside.y]; // 终点正方向向量\n const endAngle = Math.atan2(endVector[1], endVector[0]); // 终点正方向角度\n\n this._startAngle = startAngle;\n this._endAngle = endAngle;\n }\n\n private _reset() {\n this.startSymbol = null;\n this.endSymbol = null;\n this._startAngle = null;\n this._endAngle = null;\n this._mainSegmentPoints = null;\n }\n}\n"]}
@@ -24,7 +24,6 @@ export interface SegmentAttributes extends IGroupGraphicAttribute {
24
24
  symbol?: State<Partial<ISymbolGraphicAttribute>>;
25
25
  };
26
26
  }
27
- interface ILineGraphicWithCornerRadius extends Partial<ILineGraphicAttribute> {
27
+ export interface ILineGraphicWithCornerRadius extends Partial<ILineGraphicAttribute> {
28
28
  cornerRadius?: number;
29
29
  }
30
- export {};
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/segment/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n IGraphicAttribute,\n IGroupGraphicAttribute,\n ILineGraphicAttribute,\n ISymbolGraphicAttribute,\n SymbolType\n} from '@visactor/vrender-core';\nimport type { Point, State } from '../core/type';\n\nexport type SymbolAttributes = {\n /** 是否展示 symbol */\n visible: boolean;\n /**\n * symbol 形状,默认为带左右方向的箭头\n */\n symbolType?: SymbolType;\n /**\n * symbol 大小\n */\n size?: number;\n /**\n * 自动旋转,沿着线的方向,默认 true\n */\n autoRotate?: boolean;\n /**\n * symbol 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * symbol 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * symbol 相对默认角度的偏移\n * @description (@chensiji: 默认角度为笛卡尔坐标系y正方向,即默认symbol包围盒的角度为笛卡尔坐标系y正方向, 做自动旋转时, 会在此基础上,将包围盒转换到line平行方向上。)\n */\n refAngle?: number;\n /**\n * symbol 是否clip line,即当symbol fill为false时,line在symbol内部的部分是否展示\n * @defalut false\n */\n clip?: boolean;\n /**\n * symbol 样式配置\n */\n style?: Partial<IGraphicAttribute>;\n};\n\nexport interface SegmentAttributes extends IGroupGraphicAttribute {\n /**\n * 可见性\n * @default true\n */\n visible?: boolean;\n /**\n * 是否对 points 进行多段处理,默认为 false,即直接将所有的点连接成线。\n * 如果需要进行多段处理,需要将 points 属性配置为 Point[][] 类型\n * @default false\n */\n multiSegment?: boolean;\n /**\n * 在 `multiSegment` 属性开启的前提下,用于声明那一段线段用来作为主线段,如果不声明,默认全段为主线段\n */\n mainSegmentIndex?: number;\n points: Point[] | Point[][];\n /** 轴线起始点 symbol 配置 */\n startSymbol?: SymbolAttributes;\n /** 轴线末端 symbol 配置 */\n endSymbol?: SymbolAttributes;\n /**\n * 线样式配置\n */\n lineStyle?: ILineGraphicWithCornerRadius | Partial<ILineGraphicAttribute>[];\n\n state?: {\n line?: State<ILineGraphicWithCornerRadius | Partial<ILineGraphicAttribute>[]>;\n symbol?: State<Partial<ISymbolGraphicAttribute>>;\n };\n}\n\ninterface ILineGraphicWithCornerRadius extends Partial<ILineGraphicAttribute> {\n /**\n * 折现拐角处的圆角配置\n */\n cornerRadius?: number;\n}\n"]}
1
+ {"version":3,"sources":["../src/segment/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n IGraphicAttribute,\n IGroupGraphicAttribute,\n ILineGraphicAttribute,\n ISymbolGraphicAttribute,\n SymbolType\n} from '@visactor/vrender-core';\nimport type { Point, State } from '../core/type';\n\nexport type SymbolAttributes = {\n /** 是否展示 symbol */\n visible: boolean;\n /**\n * symbol 形状,默认为带左右方向的箭头\n */\n symbolType?: SymbolType;\n /**\n * symbol 大小\n */\n size?: number;\n /**\n * 自动旋转,沿着线的方向,默认 true\n */\n autoRotate?: boolean;\n /**\n * symbol 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * symbol 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * symbol 相对默认角度的偏移\n * @description (@chensiji: 默认角度为笛卡尔坐标系y正方向,即默认symbol包围盒的角度为笛卡尔坐标系y正方向, 做自动旋转时, 会在此基础上,将包围盒转换到line平行方向上。)\n */\n refAngle?: number;\n /**\n * symbol 是否clip line,即当symbol fill为false时,line在symbol内部的部分是否展示\n * @defalut false\n */\n clip?: boolean;\n /**\n * symbol 样式配置\n */\n style?: Partial<IGraphicAttribute>;\n};\n\nexport interface SegmentAttributes extends IGroupGraphicAttribute {\n /**\n * 可见性\n * @default true\n */\n visible?: boolean;\n /**\n * 是否对 points 进行多段处理,默认为 false,即直接将所有的点连接成线。\n * 如果需要进行多段处理,需要将 points 属性配置为 Point[][] 类型\n * @default false\n */\n multiSegment?: boolean;\n /**\n * 在 `multiSegment` 属性开启的前提下,用于声明那一段线段用来作为主线段,如果不声明,默认全段为主线段\n */\n mainSegmentIndex?: number;\n points: Point[] | Point[][];\n /** 轴线起始点 symbol 配置 */\n startSymbol?: SymbolAttributes;\n /** 轴线末端 symbol 配置 */\n endSymbol?: SymbolAttributes;\n /**\n * 线样式配置\n */\n lineStyle?: ILineGraphicWithCornerRadius | Partial<ILineGraphicAttribute>[];\n\n state?: {\n line?: State<ILineGraphicWithCornerRadius | Partial<ILineGraphicAttribute>[]>;\n symbol?: State<Partial<ISymbolGraphicAttribute>>;\n };\n}\n\nexport interface ILineGraphicWithCornerRadius extends Partial<ILineGraphicAttribute> {\n /**\n * 折现拐角处的圆角配置\n */\n cornerRadius?: number;\n}\n"]}
@@ -1,12 +1,10 @@
1
- import { isEmpty, isNil, isValidNumber } from "@visactor/vutils";
2
-
3
- import { borderPoint } from "./util";
1
+ import { isEmpty, isNil, isNumberClose, isValidNumber } from "@visactor/vutils";
4
2
 
5
3
  export function autoLimit(labels, config) {
6
4
  const {limitLength: limitLength, verticalLimitLength: verticalLimitLength, ellipsis: ellipsis = "...", orient: orient, axisLength: axisLength} = config;
7
5
  !isEmpty(labels) && isValidNumber(limitLength) && labels.forEach((label => {
8
6
  var _a;
9
- const angle = label.attribute.angle, hasAngle = !isNil(angle), isHorizontal = !hasAngle || 0 === angle || angle === Math.PI, isVertical = hasAngle && (angle === Math.PI / 2 || angle === 2 * Math.PI / 3), isX = "top" === orient || "bottom" === orient;
7
+ const angle = label.attribute.angle, hasAngle = !isNil(angle), cos = hasAngle ? Math.cos(angle) : 1, sin = hasAngle ? Math.sin(angle) : 0, isHorizontal = !hasAngle || isNumberClose(sin, 0), isVertical = hasAngle && isNumberClose(cos, 0), isX = "top" === orient || "bottom" === orient;
10
8
  if (isX) {
11
9
  if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) return;
12
10
  if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) return;
@@ -20,20 +18,15 @@ export function autoLimit(labels, config) {
20
18
  }
21
19
  }
22
20
  let limitLabelLength = null;
23
- if (isHorizontal || isVertical) limitLabelLength = isX || "vertical" === direction ? verticalLimitLength : limitLength; else {
24
- const {x1: x, y1: y} = label.AABBBounds, intersection = borderPoint({
25
- width: isX ? axisLength : limitLength,
26
- height: isX ? limitLength : axisLength,
27
- left: 0,
28
- top: 0
29
- }, {
30
- x: x,
31
- y: y
32
- }, label.attribute.angle);
33
- if (intersection) {
34
- const {x: _x, y: _y} = intersection;
35
- limitLabelLength = Math.floor(Math.sqrt((_x - x) ** 2 + (_y - y) ** 2));
36
- } else limitLabelLength = Math.abs(limitLength / Math.sin(angle));
21
+ if (isHorizontal || isVertical) limitLabelLength = isX ? isHorizontal ? verticalLimitLength : limitLength : "vertical" === direction || isVertical ? verticalLimitLength : limitLength; else {
22
+ const cos = Math.cos(angle), sin = Math.sin(angle);
23
+ if (isX) {
24
+ const {x1: x1, x2: x2} = label.AABBBounds;
25
+ limitLabelLength = cos > 0 && x1 <= axisLength && cos * limitLength / Math.abs(sin) + x1 > axisLength ? (axisLength - x1) / cos : cos < 0 && x2 >= 0 && cos * limitLength / Math.abs(sin) + x2 < 0 ? -x2 / cos : Math.abs(limitLength / sin);
26
+ } else {
27
+ const {y1: y1, y2: y2} = label.AABBBounds;
28
+ limitLabelLength = sin > 0 && y2 >= 0 && y2 - sin * limitLength / Math.abs(cos) < 0 ? y2 / sin : sin < 0 && y1 <= axisLength && y1 - sin * limitLength / Math.abs(cos) > axisLength ? -(axisLength - y1) / sin : Math.abs(limitLength / cos);
29
+ }
37
30
  }
38
31
  isValidNumber(label.attribute.maxLineWidth) && (limitLabelLength = isValidNumber(limitLabelLength) ? Math.min(label.attribute.maxLineWidth, limitLabelLength) : label.attribute.maxLineWidth),
39
32
  label.setAttributes({
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/overlap/auto-limit.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAUrC,MAAM,UAAU,SAAS,CAAC,MAAe,EAAE,MAAmB;IAC5D,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,GAAG,KAAK,EAAE,MAAM,EAAE,UAAU,E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gB,GAAG,mBAAmB,CAAC;SACxC;aAAM;YACL,gBAAgB,GAAG,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,WAAW,CAAC;SACjF;QAED,IAAI,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE;YAC/C,gBAAgB,GAAG,aAAa,CAAC,gBAAgB,CAAC;gBAChD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,EAAE,gBAAgB,CAAC;gBAC1D,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC;SAClC;QACD,KAAK,CAAC,aAAa,CAAC;YAClB,YAAY,EAAE,gBAAgB;YAC9B,QAAQ,EAAE,MAAA,KAAK,CAAC,SAAS,CAAC,QAAQ,mCAAI,QAAQ;SAC/C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","file":"auto-limit.js","sourcesContent":["/**\n * 自动省略\n */\nimport type { IText } from '@visactor/vrender-core';\nimport { isEmpty, isNil, isValidNumber } from '@visactor/vutils';\nimport { borderPoint } from './util';\n\ntype LimitConfig = {\n orient: string;\n limitLength: number;\n axisLength: number;\n verticalLimitLength?: number;\n ellipsis?: string;\n};\n\nexport function autoLimit(labels: IText[], config: LimitConfig) {\n const { limitLength, verticalLimitLength, ellipsis = '...', orient, axisLength } = config;\n if (isEmpty(labels) || !isValidNumber(limitLength)) {\n return;\n }\n\n labels.forEach(label => {\n const angle = label.attribute.angle;\n\n const hasAngle = !isNil(angle);\n const isHorizontal = !hasAngle || angle === 0 || angle === Math.PI;\n const isVertical = hasAngle && (angle === Math.PI / 2 || angle === (Math.PI * 2) / 3);\n const isX = orient === 'top' || orient === 'bottom';\n\n if (isX) {\n if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {\n return;\n }\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) {\n return;\n }\n }\n\n const direction = label.attribute.direction;\n if (!isX) {\n if (direction === 'vertical' && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {\n return;\n }\n\n if (direction !== 'vertical') {\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) {\n return;\n }\n if (isVertical && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {\n return;\n }\n }\n }\n\n // 如果水平并且文本未发生旋转,则不配置 maxLineWidth\n let limitLabelLength = null;\n\n if (!isHorizontal && !isVertical) {\n const { x1: x, y1: y } = label.AABBBounds;\n\n const width = isX ? axisLength : limitLength;\n const height = isX ? limitLength : axisLength;\n\n const intersection = borderPoint({ width, height, left: 0, top: 0 }, { x, y }, label.attribute.angle);\n if (intersection) {\n const { x: _x, y: _y } = intersection;\n limitLabelLength = Math.floor(Math.sqrt((_x - x) ** 2 + (_y - y) ** 2));\n } else {\n limitLabelLength = Math.abs(limitLength / Math.sin(angle));\n }\n } else if (isX) {\n limitLabelLength = verticalLimitLength;\n } else {\n limitLabelLength = direction === 'vertical' ? verticalLimitLength : limitLength;\n }\n\n if (isValidNumber(label.attribute.maxLineWidth)) {\n limitLabelLength = isValidNumber(limitLabelLength)\n ? Math.min(label.attribute.maxLineWidth, limitLabelLength)\n : label.attribute.maxLineWidth;\n }\n label.setAttributes({\n maxLineWidth: limitLabelLength,\n ellipsis: label.attribute.ellipsis ?? ellipsis\n });\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/axis/overlap/auto-limit.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAUhF,MAAM,UAAU,SAAS,CAAC,MAAe,EAAE,MAAmB;IAC5D,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,GAAG,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC1F,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW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CAAC","file":"auto-limit.js","sourcesContent":["/**\n * 自动省略\n */\nimport type { IText } from '@visactor/vrender-core';\nimport { isEmpty, isNil, isNumberClose, isValidNumber } from '@visactor/vutils';\n\ntype LimitConfig = {\n orient: string;\n limitLength: number;\n axisLength: number;\n verticalLimitLength?: number;\n ellipsis?: string;\n};\n\nexport function autoLimit(labels: IText[], config: LimitConfig) {\n const { limitLength, verticalLimitLength, ellipsis = '...', orient, axisLength } = config;\n if (isEmpty(labels) || !isValidNumber(limitLength)) {\n return;\n }\n\n labels.forEach(label => {\n const angle = label.attribute.angle;\n\n const hasAngle = !isNil(angle);\n const cos = hasAngle ? Math.cos(angle) : 1;\n const sin = hasAngle ? Math.sin(angle) : 0;\n const isHorizontal = !hasAngle || isNumberClose(sin, 0);\n const isVertical = hasAngle && isNumberClose(cos, 0);\n const isX = orient === 'top' || orient === 'bottom';\n\n if (isX) {\n if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {\n return;\n }\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) {\n return;\n }\n }\n\n const direction = label.attribute.direction;\n if (!isX) {\n if (direction === 'vertical' && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {\n return;\n }\n\n if (direction !== 'vertical') {\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) {\n return;\n }\n if (isVertical && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {\n return;\n }\n }\n }\n\n // 如果水平并且文本未发生旋转,则不配置 maxLineWidth\n let limitLabelLength = null;\n\n if (!isHorizontal && !isVertical) {\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n if (isX) {\n const { x1, x2 } = label.AABBBounds;\n\n if (cos > 0 && x1 <= axisLength && (cos * limitLength) / Math.abs(sin) + x1 > axisLength) {\n limitLabelLength = (axisLength - x1) / cos;\n } else if (cos < 0 && x2 >= 0 && (cos * limitLength) / Math.abs(sin) + x2 < 0) {\n limitLabelLength = -x2 / cos;\n } else {\n limitLabelLength = Math.abs(limitLength / sin);\n }\n } else {\n const { y1, y2 } = label.AABBBounds;\n\n if (sin > 0 && y2 >= 0 && y2 - (sin * limitLength) / Math.abs(cos) < 0) {\n limitLabelLength = y2 / sin;\n } else if (sin < 0 && y1 <= axisLength && y1 - (sin * limitLength) / Math.abs(cos) > axisLength) {\n limitLabelLength = -(axisLength - y1) / sin;\n } else {\n limitLabelLength = Math.abs(limitLength / cos);\n }\n }\n } else if (isX) {\n limitLabelLength = isHorizontal ? verticalLimitLength : limitLength;\n } else {\n limitLabelLength = direction === 'vertical' || isVertical ? verticalLimitLength : limitLength;\n }\n\n if (isValidNumber(label.attribute.maxLineWidth)) {\n limitLabelLength = isValidNumber(limitLabelLength)\n ? Math.min(label.attribute.maxLineWidth, limitLabelLength)\n : label.attribute.maxLineWidth;\n }\n label.setAttributes({\n maxLineWidth: limitLabelLength,\n ellipsis: label.attribute.ellipsis ?? ellipsis\n });\n });\n}\n"]}
@@ -1,15 +1,3 @@
1
1
  import type { IText } from '@visactor/vrender-core';
2
2
  export declare function genRotateBounds(items: IText[]): void;
3
3
  export declare function itemIntersect(item1: IText, item2: IText): boolean;
4
- export declare function borderPoint(rect: {
5
- left: number;
6
- top: number;
7
- width: number;
8
- height: number;
9
- }, pt: {
10
- x: number;
11
- y: number;
12
- }, angle: number): {
13
- x: number;
14
- y: number;
15
- };
@@ -32,41 +32,4 @@ export function genRotateBounds(items) {
32
32
  export function itemIntersect(item1, item2) {
33
33
  return isRectIntersect(item1.AABBBounds, item2.AABBBounds, !1) && (!item1.rotatedBounds || !item2.rotatedBounds || isRotateAABBIntersect(item1.rotatedBounds, item2.rotatedBounds, !0));
34
34
  }
35
-
36
- export function borderPoint(rect, pt, angle) {
37
- if (pt.x < rect.left) return null;
38
- if (pt.x > rect.left + rect.width) return null;
39
- if (pt.y < rect.top) return null;
40
- if (pt.y > rect.top + rect.height) return null;
41
- const dx = Math.cos(angle), dy = Math.sin(angle);
42
- if (dx < 1e-16) {
43
- const y = (rect.left - pt.x) * dy / dx + pt.y;
44
- if (y >= rect.top && y <= rect.top + rect.height) return {
45
- x: rect.left,
46
- y: y
47
- };
48
- }
49
- if (dx > 1e-16) {
50
- const y = (rect.left + rect.width - pt.x) * dy / dx + pt.y;
51
- if (y >= rect.top && y <= rect.top + rect.height) return {
52
- x: rect.left + rect.width,
53
- y: y
54
- };
55
- }
56
- if (dy < 1e-16) {
57
- const x = (rect.top - pt.y) * dx / dy + pt.x;
58
- if (x >= rect.left && x <= rect.left + rect.width) return {
59
- x: x,
60
- y: rect.top
61
- };
62
- }
63
- if (dy > 1e-16) {
64
- const x = (rect.top + rect.height - pt.y) * dx / dy + pt.x;
65
- if (x >= rect.left && x <= rect.left + rect.width) return {
66
- x: x,
67
- y: rect.top + rect.height
68
- };
69
- }
70
- return null;
71
- }
72
35
  //# sourceMappingURL=util.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/overlap/util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE1E,SAAS,MAAM,CAAC,CAAS,EAAE,CAAS,EAAE,GAAW,EAAE,OAAe,EAAE,OAAe;IACjF,OAAO;QACL,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO;QAC1E,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO;KAC3E,CAAC;AACJ,CAAC;AAGD,SAAS,eAAe,CAAC,IAAW;IAClC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;IAE/B,OAAO;Q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EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;SAC5C;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC","file":"util.js","sourcesContent":["import type { IText } from '@visactor/vrender-core';\nimport { isRectIntersect, isRotateAABBIntersect } from '@visactor/vutils';\n\nfunction rotate(x: number, y: number, deg: number, originX: number, originY: number) {\n return {\n x: (x - originX) * Math.cos(deg) + (y - originY) * Math.sin(deg) + originX,\n y: (x - originX) * Math.sin(deg) + (originY - y) * Math.cos(deg) + originY\n };\n}\n\n// 计算水平情况下的包围盒\nfunction genNormalBounds(item: IText) {\n const bounds = item.AABBBounds;\n\n return {\n x1: bounds.x1,\n x2: bounds.x2,\n y1: bounds.y1,\n y2: bounds.y2,\n centerX: item.attribute.x,\n centerY: item.attribute.y,\n angle: item.attribute.angle\n };\n}\n\nexport function genRotateBounds(items: IText[]) {\n items.forEach(item => {\n if (item.rotatedBounds || !item.attribute.angle) {\n return;\n }\n // 计算水平情况下的包围盒\n const bounds = genNormalBounds(item);\n // 旋转\n const rotatedCenter = rotate(bounds.centerX, bounds.centerY, bounds.angle, item.attribute.x, item.attribute.y);\n const deltaX = rotatedCenter.x - bounds.centerX;\n const deltaY = rotatedCenter.y - bounds.centerY;\n bounds.x1 += deltaX;\n bounds.x2 += deltaX;\n bounds.y1 += deltaY;\n bounds.y2 += deltaY;\n bounds.centerX += deltaX;\n bounds.centerY += deltaY;\n item.rotatedBounds = bounds;\n });\n}\n\nexport function itemIntersect(item1: IText, item2: IText) {\n return (\n isRectIntersect(item1.AABBBounds, item2.AABBBounds, false) &&\n (item1.rotatedBounds && item2.rotatedBounds\n ? isRotateAABBIntersect(item1.rotatedBounds, item2.rotatedBounds, true)\n : true)\n );\n}\n\n// 计算矩形内的点与矩形边的交点\nexport function borderPoint(\n rect: { left: number; top: number; width: number; height: number },\n pt: { x: number; y: number },\n angle: number\n) {\n // catch cases where point is outside rectangle\n if (pt.x < rect.left) {\n return null;\n }\n if (pt.x > rect.left + rect.width) {\n return null;\n }\n if (pt.y < rect.top) {\n return null;\n }\n if (pt.y > rect.top + rect.height) {\n return null;\n }\n\n const dx = Math.cos(angle);\n const dy = Math.sin(angle);\n\n if (dx < 1.0e-16) {\n // left border\n const y = ((rect.left - pt.x) * dy) / dx + pt.y;\n\n if (y >= rect.top && y <= rect.top + rect.height) {\n return { x: rect.left, y: y };\n }\n }\n\n if (dx > 1.0e-16) {\n // right border\n const y = ((rect.left + rect.width - pt.x) * dy) / dx + pt.y;\n\n if (y >= rect.top && y <= rect.top + rect.height) {\n return { x: rect.left + rect.width, y: y };\n }\n }\n\n if (dy < 1.0e-16) {\n // top border\n const x = ((rect.top - pt.y) * dx) / dy + pt.x;\n\n if (x >= rect.left && x <= rect.left + rect.width) {\n return { x: x, y: rect.top };\n }\n }\n\n if (dy > 1.0e-16) {\n // bottom border\n const x = ((rect.top + rect.height - pt.y) * dx) / dy + pt.x;\n if (x >= rect.left && x <= rect.left + rect.width) {\n return { x: x, y: rect.top + rect.height };\n }\n }\n\n return null;\n}\n"]}
1
+ {"version":3,"sources":["../src/axis/overlap/util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE1E,SAAS,MAAM,CAAC,CAAS,EAAE,CAAS,EAAE,GAAW,EAAE,OAAe,EAAE,OAAe;IACjF,OAAO;QACL,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO;QAC1E,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GA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O,IAAI,MAAM,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAY,EAAE,KAAY;IACtD,OAAO,CACL,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC;QAC1D,CAAC,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,aAAa;YACzC,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC;YACvE,CAAC,CAAC,IAAI,CAAC,CACV,CAAC;AACJ,CAAC","file":"util.js","sourcesContent":["import type { IText } from '@visactor/vrender-core';\nimport { isRectIntersect, isRotateAABBIntersect } from '@visactor/vutils';\n\nfunction rotate(x: number, y: number, deg: number, originX: number, originY: number) {\n return {\n x: (x - originX) * Math.cos(deg) + (y - originY) * Math.sin(deg) + originX,\n y: (x - originX) * Math.sin(deg) + (originY - y) * Math.cos(deg) + originY\n };\n}\n\n// 计算水平情况下的包围盒\nfunction genNormalBounds(item: IText) {\n const bounds = item.AABBBounds;\n\n return {\n x1: bounds.x1,\n x2: bounds.x2,\n y1: bounds.y1,\n y2: bounds.y2,\n centerX: item.attribute.x,\n centerY: item.attribute.y,\n angle: item.attribute.angle\n };\n}\n\nexport function genRotateBounds(items: IText[]) {\n items.forEach(item => {\n if (item.rotatedBounds || !item.attribute.angle) {\n return;\n }\n // 计算水平情况下的包围盒\n const bounds = genNormalBounds(item);\n // 旋转\n const rotatedCenter = rotate(bounds.centerX, bounds.centerY, bounds.angle, item.attribute.x, item.attribute.y);\n const deltaX = rotatedCenter.x - bounds.centerX;\n const deltaY = rotatedCenter.y - bounds.centerY;\n bounds.x1 += deltaX;\n bounds.x2 += deltaX;\n bounds.y1 += deltaY;\n bounds.y2 += deltaY;\n bounds.centerX += deltaX;\n bounds.centerY += deltaY;\n item.rotatedBounds = bounds;\n });\n}\n\nexport function itemIntersect(item1: IText, item2: IText) {\n return (\n isRectIntersect(item1.AABBBounds, item2.AABBBounds, false) &&\n (item1.rotatedBounds && item2.rotatedBounds\n ? isRotateAABBIntersect(item1.rotatedBounds, item2.rotatedBounds, true)\n : true)\n );\n}\n"]}
package/es/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "0.18.6";
1
+ export declare const version = "0.18.7-alpha.1";
2
2
  export * from './core/base';
3
3
  export * from './core/type';
4
4
  export * from './scrollbar';
package/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = "0.18.6";
1
+ export const version = "0.18.7-alpha.1";
2
2
 
3
3
  export * from "./core/base";
4
4
 
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.18.6\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './util';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAExC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.18.7-alpha.1\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './util';\n"]}
@@ -45,7 +45,9 @@ export class Segment extends AbstractComponent {
45
45
  this.add(line);
46
46
  }));
47
47
  } else {
48
- const line = graphicCreator.polygon(Object.assign(Object.assign({
48
+ let lineCreator = graphicCreator.line;
49
+ array(lineStyle)[0].cornerRadius && (lineCreator = graphicCreator.polygon);
50
+ const line = lineCreator(Object.assign(Object.assign({
49
51
  points: this._clipPoints(this.attribute.points)
50
52
  }, array(lineStyle)[0]), {
51
53
  fill: !1,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/segment/segment.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE/F,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAIjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,oBAAoB,EAAE,CAAC;AACvB,MAAM,OAAO,OAAQ,SAAQ,iBAA8C;IAUzE,aAAa;QACX,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAMD,WAAW;QACT,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAGD,oBAAoB;QAClB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAoCD,YAAY,UAA6B,EAAE,OAA0B;QACnE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,i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IAEO,MAAM;QACZ,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;IACjC,CAAC;;AA7OM,yBAAiB,GAA+B;IACrD,OAAO,EAAE,IAAI;IACb,SAAS,EAAE;QACT,SAAS,EAAE,CAAC;QACZ,MAAM,EAAE,MAAM;KACf;IACD,WAAW,EAAE;QACX,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,UAAU;QACtB,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,CAAC;SACV;KACF;IACD,SAAS,EAAE;QACT,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,UAAU;QACtB,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,CAAC;SACV;KACF;CACF,CAAC","file":"segment.js","sourcesContent":["/**\n * @description 标签组件\n */\nimport { array, flattenArray, isArray, isEmpty, isValidNumber, merge } from '@visactor/vutils';\nimport type { ISymbol } from '@visactor/vrender-core';\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../core/base';\nimport type { SegmentAttributes, SymbolAttributes } from './type';\nimport type { Point } from '../core/type';\nimport type { ComponentOptions } from '../interface';\nimport { loadSegmentComponent } from './register';\n\nloadSegmentComponent();\nexport class Segment extends AbstractComponent<Required<SegmentAttributes>> {\n name = 'segment';\n\n startSymbol?: ISymbol;\n endSymbol?: ISymbol;\n\n private _startAngle!: number;\n /**\n * 外部获取segment起点正方向\n */\n getStartAngle() {\n return this._startAngle;\n }\n\n private _endAngle!: number;\n /**\n * 外部获取segment终点正方向\n */\n getEndAngle() {\n return this._endAngle;\n }\n\n private _mainSegmentPoints: Point[]; // 组成主线段的点\n getMainSegmentPoints() {\n return this._mainSegmentPoints;\n }\n\n static defaultAttributes: Partial<SegmentAttributes> = {\n visible: true,\n lineStyle: {\n lineWidth: 1,\n stroke: '#000'\n },\n startSymbol: {\n visible: false,\n autoRotate: true,\n symbolType: 'triangle',\n size: 12,\n refX: 0,\n refY: 0,\n refAngle: 0,\n style: {\n fill: '#000',\n zIndex: 1 // 默认 symbol 绘制在 line 上面\n }\n },\n endSymbol: {\n visible: false,\n autoRotate: true,\n symbolType: 'triangle',\n size: 12,\n refX: 0,\n refY: 0,\n refAngle: 0,\n style: {\n fill: '#000',\n zIndex: 1 // 默认 symbol 绘制在 line 上面\n }\n }\n };\n\n constructor(attributes: SegmentAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Segment.defaultAttributes, attributes));\n }\n\n protected render() {\n this.removeAllChild(true);\n this._reset();\n const {\n // points,\n startSymbol,\n endSymbol,\n lineStyle,\n state,\n visible = true,\n multiSegment,\n mainSegmentIndex\n } = this.attribute as SegmentAttributes;\n\n if (!visible) {\n return;\n }\n\n // 计算线的起点和终点角度\n // 计算角度的原因:\n // 1. segment symbol的自动旋转提供参数\n // 2. 使用segment时,需要根据line的角度对附加元素进行自动旋转(比如:markLine的标签, markPoint的装饰线)\n this._computeLineAngle();\n\n // 绘制start和end symbol\n const startSymbolShape = this._renderSymbol(startSymbol as SymbolAttributes, 'start');\n const endSymbolShape = this._renderSymbol(endSymbol as SymbolAttributes, 'end');\n\n this.startSymbol = startSymbolShape;\n this.endSymbol = endSymbolShape;\n\n if (multiSegment) {\n const points = [...this.attribute.points];\n if (isValidNumber(mainSegmentIndex)) {\n points[mainSegmentIndex] = this._clipPoints(points[mainSegmentIndex] as Point[]);\n } else {\n const clipPoints = this._clipPoints(flattenArray(points) as Point[]);\n points[0][0] = clipPoints[0];\n (points[points.length - 1] as Point[])[(points[points.length - 1] as Point[]).length - 1] =\n clipPoints[clipPoints.length - 1];\n }\n points.forEach((point: Point[], index) => {\n const line = graphicCreator.line({\n points: point,\n ...(isArray(lineStyle) ? lineStyle[index] ?? lineStyle[lineStyle.length - 1] : lineStyle),\n fill: false\n });\n\n line.name = `${this.name}-line`;\n line.id = this._getNodeId('line' + index);\n if (!isEmpty(state?.line)) {\n line.states = isArray(state.line) ? state.line[index] ?? state.line[state.line.length - 1] : state.line;\n }\n this.add(line);\n });\n } else {\n const line = graphicCreator.polygon({\n points: this._clipPoints(this.attribute.points as Point[]),\n ...array(lineStyle)[0],\n fill: false,\n closePath: false\n });\n\n line.name = `${this.name}-line`;\n line.id = this._getNodeId('line');\n if (!isEmpty(state?.line)) {\n line.states = [].concat(state.line)[0];\n }\n this.add(line);\n }\n }\n\n private _renderSymbol(attribute: SymbolAttributes, dim: string): ISymbol | undefined {\n const points = this._getMainSegmentPoints();\n if (!points.length) {\n return;\n }\n\n const { autoRotate = true } = attribute;\n let symbol;\n if (attribute && attribute.visible) {\n const startAngle = this._startAngle;\n const endAngle = this._endAngle;\n const { state } = this.attribute as SegmentAttributes;\n const start = points[0];\n const end = points[points.length - 1];\n const { refX = 0, refY = 0, refAngle = 0, style, symbolType, size = 12 } = attribute;\n let position;\n let rotate;\n if (dim === 'start') {\n position = {\n x:\n start.x +\n (isValidNumber(startAngle) ? refX * Math.cos(startAngle) + refY * Math.cos(startAngle - Math.PI / 2) : 0),\n y:\n start.y +\n (isValidNumber(startAngle) ? refX * Math.sin(startAngle) + refY * Math.sin(startAngle - Math.PI / 2) : 0)\n };\n rotate = startAngle + Math.PI / 2; // @chensiji - 加Math.PI / 2是因为:默认symbol的包围盒垂直于line,所以在做自动旋转时需要在line正方向基础上做90度偏移\n } else {\n position = {\n x:\n end.x + (isValidNumber(endAngle) ? refX * Math.cos(endAngle) + refY * Math.cos(endAngle - Math.PI / 2) : 0),\n y: end.y + (isValidNumber(endAngle) ? refX * Math.sin(endAngle) + refY * Math.sin(endAngle - Math.PI / 2) : 0)\n };\n rotate = endAngle + Math.PI / 2;\n }\n\n symbol = graphicCreator.symbol({\n ...position,\n symbolType: symbolType as string,\n size,\n angle: autoRotate ? rotate + refAngle : 0,\n strokeBoundsBuffer: 0,\n ...style\n });\n symbol.name = `${this.name}-${dim}-symbol`;\n symbol.id = this._getNodeId(`${dim}-symbol`);\n\n if (!isEmpty(state?.symbol)) {\n symbol.states = state.symbol;\n }\n\n this.add(symbol);\n }\n return symbol;\n }\n\n private _getMainSegmentPoints(): Point[] {\n if (this._mainSegmentPoints) {\n return this._mainSegmentPoints;\n }\n const { points: originPoints, multiSegment, mainSegmentIndex } = this.attribute as SegmentAttributes;\n\n let points: Point[];\n // 需要做下约束判断\n if (multiSegment) {\n if (isValidNumber(mainSegmentIndex)) {\n points = originPoints[mainSegmentIndex] as Point[];\n } else {\n points = flattenArray(originPoints);\n }\n } else {\n points = originPoints as Point[];\n }\n this._mainSegmentPoints = points;\n\n return points;\n }\n\n private _clipPoints(points: Point[]) {\n const { startSymbol = {} as SegmentAttributes['startSymbol'], endSymbol = {} as SegmentAttributes['endSymbol'] } =\n this.attribute as SegmentAttributes;\n // 通过改变line起点和终点的方式达到symbol在fill为false的情况下,也可以遮盖line的效果\n let pointsAfterClip = points;\n if (startSymbol.visible) {\n const startSize = startSymbol.clip ? startSymbol.size || 10 : 0;\n const pointsStart = {\n x: points[0].x - (startSize / 2) * (Math.cos(this._startAngle) || 0),\n y: points[0].y - (startSize / 2) * (Math.sin(this._startAngle) || 0)\n };\n pointsAfterClip = [pointsStart, ...pointsAfterClip.slice(1)];\n }\n if (endSymbol.visible) {\n const endSize = endSymbol.clip ? endSymbol.size || 10 : 0;\n const pointsEnd = {\n x: points[points.length - 1].x - (endSize / 2) * (Math.cos(this._endAngle) || 0),\n y: points[points.length - 1].y - (endSize / 2) * (Math.sin(this._endAngle) || 0)\n };\n pointsAfterClip = [...pointsAfterClip.slice(0, pointsAfterClip.length - 1), pointsEnd];\n }\n\n return pointsAfterClip;\n }\n\n private _computeLineAngle() {\n const points = this._getMainSegmentPoints();\n if (points.length <= 1) {\n return;\n }\n const start = points[0];\n const startInside = points[1];\n const endInside = points[points.length - 2];\n const end = points[points.length - 1];\n const startVector = [start.x - startInside.x, start.y - startInside.y]; // 起点正方向向量\n const startAngle = Math.atan2(startVector[1], startVector[0]); // 起点正方向角度\n const endVector = [end.x - endInside.x, end.y - endInside.y]; // 终点正方向向量\n const endAngle = Math.atan2(endVector[1], endVector[0]); // 终点正方向角度\n\n this._startAngle = startAngle;\n this._endAngle = endAngle;\n }\n\n private _reset() {\n this.startSymbol = null;\n this.endSymbol = null;\n this._startAngle = null;\n this._endAngle = null;\n this._mainSegmentPoints = null;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/segment/segment.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE/F,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAIjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,oBAAoB,EAAE,CAAC;AACvB,MAAM,OAAO,OAAQ,SAAQ,iBAA8C;IAUzE,aAAa;QACX,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAMD,WAAW;QACT,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAGD,oBAAoB;QAClB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAoCD,YAAY,UAA6B,EAAE,OAA0B;QACnE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAA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CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAC7D,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAExD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAEO,MAAM;QACZ,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;IACjC,CAAC;;AAlPM,yBAAiB,GAA+B;IACrD,OAAO,EAAE,IAAI;IACb,SAAS,EAAE;QACT,SAAS,EAAE,CAAC;QACZ,MAAM,EAAE,MAAM;KACf;IACD,WAAW,EAAE;QACX,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,UAAU;QACtB,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,CAAC;SACV;KACF;IACD,SAAS,EAAE;QACT,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,UAAU;QACtB,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,CAAC;SACV;KACF;CACF,CAAC","file":"segment.js","sourcesContent":["/**\n * @description 标签组件\n */\nimport { array, flattenArray, isArray, isEmpty, isValidNumber, merge } from '@visactor/vutils';\nimport type { ISymbol } from '@visactor/vrender-core';\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../core/base';\nimport type { ILineGraphicWithCornerRadius, SegmentAttributes, SymbolAttributes } from './type';\nimport type { Point } from '../core/type';\nimport type { ComponentOptions } from '../interface';\nimport { loadSegmentComponent } from './register';\n\nloadSegmentComponent();\nexport class Segment extends AbstractComponent<Required<SegmentAttributes>> {\n name = 'segment';\n\n startSymbol?: ISymbol;\n endSymbol?: ISymbol;\n\n private _startAngle!: number;\n /**\n * 外部获取segment起点正方向\n */\n getStartAngle() {\n return this._startAngle;\n }\n\n private _endAngle!: number;\n /**\n * 外部获取segment终点正方向\n */\n getEndAngle() {\n return this._endAngle;\n }\n\n private _mainSegmentPoints: Point[]; // 组成主线段的点\n getMainSegmentPoints() {\n return this._mainSegmentPoints;\n }\n\n static defaultAttributes: Partial<SegmentAttributes> = {\n visible: true,\n lineStyle: {\n lineWidth: 1,\n stroke: '#000'\n },\n startSymbol: {\n visible: false,\n autoRotate: true,\n symbolType: 'triangle',\n size: 12,\n refX: 0,\n refY: 0,\n refAngle: 0,\n style: {\n fill: '#000',\n zIndex: 1 // 默认 symbol 绘制在 line 上面\n }\n },\n endSymbol: {\n visible: false,\n autoRotate: true,\n symbolType: 'triangle',\n size: 12,\n refX: 0,\n refY: 0,\n refAngle: 0,\n style: {\n fill: '#000',\n zIndex: 1 // 默认 symbol 绘制在 line 上面\n }\n }\n };\n\n constructor(attributes: SegmentAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Segment.defaultAttributes, attributes));\n }\n\n protected render() {\n this.removeAllChild(true);\n this._reset();\n const {\n // points,\n startSymbol,\n endSymbol,\n lineStyle,\n state,\n visible = true,\n multiSegment,\n mainSegmentIndex\n } = this.attribute as SegmentAttributes;\n\n if (!visible) {\n return;\n }\n\n // 计算线的起点和终点角度\n // 计算角度的原因:\n // 1. segment symbol的自动旋转提供参数\n // 2. 使用segment时,需要根据line的角度对附加元素进行自动旋转(比如:markLine的标签, markPoint的装饰线)\n this._computeLineAngle();\n\n // 绘制start和end symbol\n const startSymbolShape = this._renderSymbol(startSymbol as SymbolAttributes, 'start');\n const endSymbolShape = this._renderSymbol(endSymbol as SymbolAttributes, 'end');\n\n this.startSymbol = startSymbolShape;\n this.endSymbol = endSymbolShape;\n\n if (multiSegment) {\n const points = [...this.attribute.points];\n if (isValidNumber(mainSegmentIndex)) {\n points[mainSegmentIndex] = this._clipPoints(points[mainSegmentIndex] as Point[]);\n } else {\n const clipPoints = this._clipPoints(flattenArray(points) as Point[]);\n points[0][0] = clipPoints[0];\n (points[points.length - 1] as Point[])[(points[points.length - 1] as Point[]).length - 1] =\n clipPoints[clipPoints.length - 1];\n }\n points.forEach((point: Point[], index) => {\n const line = graphicCreator.line({\n points: point,\n ...(isArray(lineStyle) ? lineStyle[index] ?? lineStyle[lineStyle.length - 1] : lineStyle),\n fill: false\n });\n\n line.name = `${this.name}-line`;\n line.id = this._getNodeId('line' + index);\n if (!isEmpty(state?.line)) {\n line.states = isArray(state.line) ? state.line[index] ?? state.line[state.line.length - 1] : state.line;\n }\n this.add(line);\n });\n } else {\n // 如果配置了cornerRadius, 则绘制polygon, 否则绘制line\n let lineCreator = graphicCreator.line;\n if ((array(lineStyle)[0] as ILineGraphicWithCornerRadius).cornerRadius) {\n lineCreator = graphicCreator.polygon;\n }\n const line = lineCreator({\n points: this._clipPoints(this.attribute.points as Point[]),\n ...array(lineStyle)[0],\n fill: false,\n closePath: false\n });\n\n line.name = `${this.name}-line`;\n line.id = this._getNodeId('line');\n if (!isEmpty(state?.line)) {\n line.states = [].concat(state.line)[0];\n }\n this.add(line);\n }\n }\n\n private _renderSymbol(attribute: SymbolAttributes, dim: string): ISymbol | undefined {\n const points = this._getMainSegmentPoints();\n if (!points.length) {\n return;\n }\n\n const { autoRotate = true } = attribute;\n let symbol;\n if (attribute && attribute.visible) {\n const startAngle = this._startAngle;\n const endAngle = this._endAngle;\n const { state } = this.attribute as SegmentAttributes;\n const start = points[0];\n const end = points[points.length - 1];\n const { refX = 0, refY = 0, refAngle = 0, style, symbolType, size = 12 } = attribute;\n let position;\n let rotate;\n if (dim === 'start') {\n position = {\n x:\n start.x +\n (isValidNumber(startAngle) ? refX * Math.cos(startAngle) + refY * Math.cos(startAngle - Math.PI / 2) : 0),\n y:\n start.y +\n (isValidNumber(startAngle) ? refX * Math.sin(startAngle) + refY * Math.sin(startAngle - Math.PI / 2) : 0)\n };\n rotate = startAngle + Math.PI / 2; // @chensiji - 加Math.PI / 2是因为:默认symbol的包围盒垂直于line,所以在做自动旋转时需要在line正方向基础上做90度偏移\n } else {\n position = {\n x:\n end.x + (isValidNumber(endAngle) ? refX * Math.cos(endAngle) + refY * Math.cos(endAngle - Math.PI / 2) : 0),\n y: end.y + (isValidNumber(endAngle) ? refX * Math.sin(endAngle) + refY * Math.sin(endAngle - Math.PI / 2) : 0)\n };\n rotate = endAngle + Math.PI / 2;\n }\n\n symbol = graphicCreator.symbol({\n ...position,\n symbolType: symbolType as string,\n size,\n angle: autoRotate ? rotate + refAngle : 0,\n strokeBoundsBuffer: 0,\n ...style\n });\n symbol.name = `${this.name}-${dim}-symbol`;\n symbol.id = this._getNodeId(`${dim}-symbol`);\n\n if (!isEmpty(state?.symbol)) {\n symbol.states = state.symbol;\n }\n\n this.add(symbol);\n }\n return symbol;\n }\n\n private _getMainSegmentPoints(): Point[] {\n if (this._mainSegmentPoints) {\n return this._mainSegmentPoints;\n }\n const { points: originPoints, multiSegment, mainSegmentIndex } = this.attribute as SegmentAttributes;\n\n let points: Point[];\n // 需要做下约束判断\n if (multiSegment) {\n if (isValidNumber(mainSegmentIndex)) {\n points = originPoints[mainSegmentIndex] as Point[];\n } else {\n points = flattenArray(originPoints);\n }\n } else {\n points = originPoints as Point[];\n }\n this._mainSegmentPoints = points;\n\n return points;\n }\n\n private _clipPoints(points: Point[]) {\n const { startSymbol = {} as SegmentAttributes['startSymbol'], endSymbol = {} as SegmentAttributes['endSymbol'] } =\n this.attribute as SegmentAttributes;\n // 通过改变line起点和终点的方式达到symbol在fill为false的情况下,也可以遮盖line的效果\n let pointsAfterClip = points;\n if (startSymbol.visible) {\n const startSize = startSymbol.clip ? startSymbol.size || 10 : 0;\n const pointsStart = {\n x: points[0].x - (startSize / 2) * (Math.cos(this._startAngle) || 0),\n y: points[0].y - (startSize / 2) * (Math.sin(this._startAngle) || 0)\n };\n pointsAfterClip = [pointsStart, ...pointsAfterClip.slice(1)];\n }\n if (endSymbol.visible) {\n const endSize = endSymbol.clip ? endSymbol.size || 10 : 0;\n const pointsEnd = {\n x: points[points.length - 1].x - (endSize / 2) * (Math.cos(this._endAngle) || 0),\n y: points[points.length - 1].y - (endSize / 2) * (Math.sin(this._endAngle) || 0)\n };\n pointsAfterClip = [...pointsAfterClip.slice(0, pointsAfterClip.length - 1), pointsEnd];\n }\n\n return pointsAfterClip;\n }\n\n private _computeLineAngle() {\n const points = this._getMainSegmentPoints();\n if (points.length <= 1) {\n return;\n }\n const start = points[0];\n const startInside = points[1];\n const endInside = points[points.length - 2];\n const end = points[points.length - 1];\n const startVector = [start.x - startInside.x, start.y - startInside.y]; // 起点正方向向量\n const startAngle = Math.atan2(startVector[1], startVector[0]); // 起点正方向角度\n const endVector = [end.x - endInside.x, end.y - endInside.y]; // 终点正方向向量\n const endAngle = Math.atan2(endVector[1], endVector[0]); // 终点正方向角度\n\n this._startAngle = startAngle;\n this._endAngle = endAngle;\n }\n\n private _reset() {\n this.startSymbol = null;\n this.endSymbol = null;\n this._startAngle = null;\n this._endAngle = null;\n this._mainSegmentPoints = null;\n }\n}\n"]}
@@ -24,7 +24,6 @@ export interface SegmentAttributes extends IGroupGraphicAttribute {
24
24
  symbol?: State<Partial<ISymbolGraphicAttribute>>;
25
25
  };
26
26
  }
27
- interface ILineGraphicWithCornerRadius extends Partial<ILineGraphicAttribute> {
27
+ export interface ILineGraphicWithCornerRadius extends Partial<ILineGraphicAttribute> {
28
28
  cornerRadius?: number;
29
29
  }
30
- export {};
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/segment/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n IGraphicAttribute,\n IGroupGraphicAttribute,\n ILineGraphicAttribute,\n ISymbolGraphicAttribute,\n SymbolType\n} from '@visactor/vrender-core';\nimport type { Point, State } from '../core/type';\n\nexport type SymbolAttributes = {\n /** 是否展示 symbol */\n visible: boolean;\n /**\n * symbol 形状,默认为带左右方向的箭头\n */\n symbolType?: SymbolType;\n /**\n * symbol 大小\n */\n size?: number;\n /**\n * 自动旋转,沿着线的方向,默认 true\n */\n autoRotate?: boolean;\n /**\n * symbol 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * symbol 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * symbol 相对默认角度的偏移\n * @description (@chensiji: 默认角度为笛卡尔坐标系y正方向,即默认symbol包围盒的角度为笛卡尔坐标系y正方向, 做自动旋转时, 会在此基础上,将包围盒转换到line平行方向上。)\n */\n refAngle?: number;\n /**\n * symbol 是否clip line,即当symbol fill为false时,line在symbol内部的部分是否展示\n * @defalut false\n */\n clip?: boolean;\n /**\n * symbol 样式配置\n */\n style?: Partial<IGraphicAttribute>;\n};\n\nexport interface SegmentAttributes extends IGroupGraphicAttribute {\n /**\n * 可见性\n * @default true\n */\n visible?: boolean;\n /**\n * 是否对 points 进行多段处理,默认为 false,即直接将所有的点连接成线。\n * 如果需要进行多段处理,需要将 points 属性配置为 Point[][] 类型\n * @default false\n */\n multiSegment?: boolean;\n /**\n * 在 `multiSegment` 属性开启的前提下,用于声明那一段线段用来作为主线段,如果不声明,默认全段为主线段\n */\n mainSegmentIndex?: number;\n points: Point[] | Point[][];\n /** 轴线起始点 symbol 配置 */\n startSymbol?: SymbolAttributes;\n /** 轴线末端 symbol 配置 */\n endSymbol?: SymbolAttributes;\n /**\n * 线样式配置\n */\n lineStyle?: ILineGraphicWithCornerRadius | Partial<ILineGraphicAttribute>[];\n\n state?: {\n line?: State<ILineGraphicWithCornerRadius | Partial<ILineGraphicAttribute>[]>;\n symbol?: State<Partial<ISymbolGraphicAttribute>>;\n };\n}\n\ninterface ILineGraphicWithCornerRadius extends Partial<ILineGraphicAttribute> {\n /**\n * 折现拐角处的圆角配置\n */\n cornerRadius?: number;\n}\n"]}
1
+ {"version":3,"sources":["../src/segment/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n IGraphicAttribute,\n IGroupGraphicAttribute,\n ILineGraphicAttribute,\n ISymbolGraphicAttribute,\n SymbolType\n} from '@visactor/vrender-core';\nimport type { Point, State } from '../core/type';\n\nexport type SymbolAttributes = {\n /** 是否展示 symbol */\n visible: boolean;\n /**\n * symbol 形状,默认为带左右方向的箭头\n */\n symbolType?: SymbolType;\n /**\n * symbol 大小\n */\n size?: number;\n /**\n * 自动旋转,沿着线的方向,默认 true\n */\n autoRotate?: boolean;\n /**\n * symbol 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * symbol 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * symbol 相对默认角度的偏移\n * @description (@chensiji: 默认角度为笛卡尔坐标系y正方向,即默认symbol包围盒的角度为笛卡尔坐标系y正方向, 做自动旋转时, 会在此基础上,将包围盒转换到line平行方向上。)\n */\n refAngle?: number;\n /**\n * symbol 是否clip line,即当symbol fill为false时,line在symbol内部的部分是否展示\n * @defalut false\n */\n clip?: boolean;\n /**\n * symbol 样式配置\n */\n style?: Partial<IGraphicAttribute>;\n};\n\nexport interface SegmentAttributes extends IGroupGraphicAttribute {\n /**\n * 可见性\n * @default true\n */\n visible?: boolean;\n /**\n * 是否对 points 进行多段处理,默认为 false,即直接将所有的点连接成线。\n * 如果需要进行多段处理,需要将 points 属性配置为 Point[][] 类型\n * @default false\n */\n multiSegment?: boolean;\n /**\n * 在 `multiSegment` 属性开启的前提下,用于声明那一段线段用来作为主线段,如果不声明,默认全段为主线段\n */\n mainSegmentIndex?: number;\n points: Point[] | Point[][];\n /** 轴线起始点 symbol 配置 */\n startSymbol?: SymbolAttributes;\n /** 轴线末端 symbol 配置 */\n endSymbol?: SymbolAttributes;\n /**\n * 线样式配置\n */\n lineStyle?: ILineGraphicWithCornerRadius | Partial<ILineGraphicAttribute>[];\n\n state?: {\n line?: State<ILineGraphicWithCornerRadius | Partial<ILineGraphicAttribute>[]>;\n symbol?: State<Partial<ISymbolGraphicAttribute>>;\n };\n}\n\nexport interface ILineGraphicWithCornerRadius extends Partial<ILineGraphicAttribute> {\n /**\n * 折现拐角处的圆角配置\n */\n cornerRadius?: number;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-components",
3
- "version": "0.18.6",
3
+ "version": "0.18.7-alpha.1",
4
4
  "description": "components library for dp visualization",
5
5
  "sideEffects": false,
6
6
  "main": "cjs/index.js",
@@ -12,8 +12,8 @@
12
12
  "dist"
13
13
  ],
14
14
  "dependencies": {
15
- "@visactor/vrender-core": "0.18.6",
16
- "@visactor/vrender-kits": "0.18.6",
15
+ "@visactor/vrender-core": "0.18.7-alpha.1",
16
+ "@visactor/vrender-kits": "0.18.7-alpha.1",
17
17
  "@visactor/vutils": "~0.18.1",
18
18
  "@visactor/vscale": "~0.17.3"
19
19
  },