@visactor/vrender-components 0.18.7-alpha.1 → 0.18.7
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/overlap/auto-limit.js +8 -13
- package/cjs/axis/overlap/auto-limit.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/es/axis/overlap/auto-limit.js +9 -13
- package/es/axis/overlap/auto-limit.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -8,10 +8,11 @@ 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
|
+
if ((0, vutils_1.isEmpty)(labels) || !(0, vutils_1.isValidNumber)(limitLength)) return;
|
|
12
|
+
const DELTA = Math.sin(Math.PI / 10);
|
|
13
|
+
labels.forEach((label => {
|
|
12
14
|
var _a;
|
|
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 || (
|
|
14
|
-
vutils_1.isNumberClose)(sin, 0), isVertical = hasAngle && (0, vutils_1.isNumberClose)(cos, 0), isX = "top" === orient || "bottom" === orient;
|
|
15
|
+
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 || Math.abs(sin) <= DELTA, isVertical = hasAngle && Math.abs(cos) <= DELTA, isX = "top" === orient || "bottom" === orient;
|
|
15
16
|
if (isX) {
|
|
16
17
|
if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) return;
|
|
17
18
|
if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) return;
|
|
@@ -25,16 +26,10 @@ function autoLimit(labels, config) {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
let limitLabelLength = null;
|
|
28
|
-
if (isHorizontal || isVertical) limitLabelLength = isX ? isHorizontal ? verticalLimitLength : limitLength : "vertical" === direction || isVertical ? verticalLimitLength : limitLength; else {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
}
|
|
37
|
-
}
|
|
29
|
+
if (isHorizontal || isVertical) limitLabelLength = isX ? isHorizontal ? verticalLimitLength : limitLength : "vertical" === direction || isVertical ? verticalLimitLength : limitLength; else if (isX) {
|
|
30
|
+
const {x1: x1, x2: x2} = label.AABBBounds, tan = sin / cos;
|
|
31
|
+
limitLabelLength = tan > 0 && x1 <= axisLength && limitLength / tan + x1 > axisLength ? (axisLength - x1) / Math.abs(cos) : tan < 0 && x2 >= 0 && limitLength / tan + x2 < 0 ? x2 / Math.abs(cos) : Math.abs(limitLength / sin);
|
|
32
|
+
} else limitLabelLength = Math.abs(limitLength / cos);
|
|
38
33
|
(0, vutils_1.isValidNumber)(label.attribute.maxLineWidth) && (limitLabelLength = (0,
|
|
39
34
|
vutils_1.isValidNumber)(limitLabelLength) ? Math.min(label.attribute.maxLineWidth, limitLabelLength) : label.attribute.maxLineWidth),
|
|
40
35
|
label.setAttributes({
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAErC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;;QACrB,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC;QAEpC,MAAM,QAAQ,GAAG,CAAC,IAAA,cAAK,EAAC,KAAK,CAAC,CAAC;QAC/B,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC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AAC,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;AAtFD,8BAsFC","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 const DELTA = Math.sin(Math.PI / 10);\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 || Math.abs(sin) <= DELTA;\n const isVertical = hasAngle && Math.abs(cos) <= DELTA;\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 if (isX) {\n const { x1, x2 } = label.AABBBounds;\n const tan = sin / cos;\n\n if (tan > 0 && x1 <= axisLength && limitLength / tan + x1 > axisLength) {\n limitLabelLength = (axisLength - x1) / Math.abs(cos);\n } else if (tan < 0 && x2 >= 0 && limitLength / tan + x2 < 0) {\n limitLabelLength = x2 / Math.abs(cos);\n } else {\n limitLabelLength = Math.abs(limitLength / sin);\n }\n } else {\n // y轴暂时不限制在平行于坐标轴的矩形内,后续可以考虑通过配置开启\n // const { y1, y2 } = label.AABBBounds;\n // const tan = sin / cos;\n\n // if (tan > 0 && y2 >= 0 && y2 - tan * limitLength < 0) {\n // limitLabelLength = y2 / Math.abs(sin);\n // } else if (tan < 0 && y1 <= axisLength && y1 - tan * limitLength > axisLength) {\n // limitLabelLength = (axisLength - y1) / Math.abs(sin);\n // } else {\n // }\n limitLabelLength = Math.abs(limitLength / cos);\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"]}
|
package/cjs/index.d.ts
CHANGED
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.7
|
|
20
|
+
}), exports.version = void 0, exports.version = "0.18.7", __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,
|
|
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.7\";\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,10 +1,12 @@
|
|
|
1
|
-
import { isEmpty, isNil,
|
|
1
|
+
import { isEmpty, isNil, isValidNumber } from "@visactor/vutils";
|
|
2
2
|
|
|
3
3
|
export function autoLimit(labels, config) {
|
|
4
4
|
const {limitLength: limitLength, verticalLimitLength: verticalLimitLength, ellipsis: ellipsis = "...", orient: orient, axisLength: axisLength} = config;
|
|
5
|
-
|
|
5
|
+
if (isEmpty(labels) || !isValidNumber(limitLength)) return;
|
|
6
|
+
const DELTA = Math.sin(Math.PI / 10);
|
|
7
|
+
labels.forEach((label => {
|
|
6
8
|
var _a;
|
|
7
|
-
const angle = label.attribute.angle, hasAngle = !isNil(angle), cos = hasAngle ? Math.cos(angle) : 1, sin = hasAngle ? Math.sin(angle) : 0, isHorizontal = !hasAngle ||
|
|
9
|
+
const angle = label.attribute.angle, hasAngle = !isNil(angle), cos = hasAngle ? Math.cos(angle) : 1, sin = hasAngle ? Math.sin(angle) : 0, isHorizontal = !hasAngle || Math.abs(sin) <= DELTA, isVertical = hasAngle && Math.abs(cos) <= DELTA, isX = "top" === orient || "bottom" === orient;
|
|
8
10
|
if (isX) {
|
|
9
11
|
if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) return;
|
|
10
12
|
if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) return;
|
|
@@ -18,16 +20,10 @@ export function autoLimit(labels, config) {
|
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
let limitLabelLength = null;
|
|
21
|
-
if (isHorizontal || isVertical) limitLabelLength = isX ? isHorizontal ? verticalLimitLength : limitLength : "vertical" === direction || isVertical ? verticalLimitLength : limitLength; else {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
}
|
|
30
|
-
}
|
|
23
|
+
if (isHorizontal || isVertical) limitLabelLength = isX ? isHorizontal ? verticalLimitLength : limitLength : "vertical" === direction || isVertical ? verticalLimitLength : limitLength; else if (isX) {
|
|
24
|
+
const {x1: x1, x2: x2} = label.AABBBounds, tan = sin / cos;
|
|
25
|
+
limitLabelLength = tan > 0 && x1 <= axisLength && limitLength / tan + x1 > axisLength ? (axisLength - x1) / Math.abs(cos) : tan < 0 && x2 >= 0 && limitLength / tan + x2 < 0 ? x2 / Math.abs(cos) : Math.abs(limitLength / sin);
|
|
26
|
+
} else limitLabelLength = Math.abs(limitLength / cos);
|
|
31
27
|
isValidNumber(label.attribute.maxLineWidth) && (limitLabelLength = isValidNumber(limitLabelLength) ? Math.min(label.attribute.maxLineWidth, limitLabelLength) : label.attribute.maxLineWidth),
|
|
32
28
|
label.setAttributes({
|
|
33
29
|
maxLineWidth: limitLabelLength,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/axis/overlap/auto-limit.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"sources":["../src/axis/overlap/auto-limit.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAiB,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,CAAC,EAAE;QAClD,OAAO;KACR;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,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,GAAG,SAAS,KAAK,UAAU,IAAI,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,WAAW,CAAC;SAC/F;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, 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 const DELTA = Math.sin(Math.PI / 10);\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 || Math.abs(sin) <= DELTA;\n const isVertical = hasAngle && Math.abs(cos) <= DELTA;\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 if (isX) {\n const { x1, x2 } = label.AABBBounds;\n const tan = sin / cos;\n\n if (tan > 0 && x1 <= axisLength && limitLength / tan + x1 > axisLength) {\n limitLabelLength = (axisLength - x1) / Math.abs(cos);\n } else if (tan < 0 && x2 >= 0 && limitLength / tan + x2 < 0) {\n limitLabelLength = x2 / Math.abs(cos);\n } else {\n limitLabelLength = Math.abs(limitLength / sin);\n }\n } else {\n // y轴暂时不限制在平行于坐标轴的矩形内,后续可以考虑通过配置开启\n // const { y1, y2 } = label.AABBBounds;\n // const tan = sin / cos;\n\n // if (tan > 0 && y2 >= 0 && y2 - tan * limitLength < 0) {\n // limitLabelLength = y2 / Math.abs(sin);\n // } else if (tan < 0 && y1 <= axisLength && y1 - tan * limitLength > axisLength) {\n // limitLabelLength = (axisLength - y1) / Math.abs(sin);\n // } else {\n // }\n limitLabelLength = Math.abs(limitLength / cos);\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"]}
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
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.7\";\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vrender-components",
|
|
3
|
-
"version": "0.18.7
|
|
3
|
+
"version": "0.18.7",
|
|
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.7
|
|
16
|
-
"@visactor/vrender-kits": "0.18.7
|
|
15
|
+
"@visactor/vrender-core": "0.18.7",
|
|
16
|
+
"@visactor/vrender-kits": "0.18.7",
|
|
17
17
|
"@visactor/vutils": "~0.18.1",
|
|
18
18
|
"@visactor/vscale": "~0.17.3"
|
|
19
19
|
},
|