@visactor/vrender-components 0.16.14-alpha.7 → 0.16.14
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/base.js +11 -22
- package/cjs/axis/base.js.map +1 -1
- package/cjs/axis/line.js +1 -1
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/type.d.ts +3 -6
- package/cjs/axis/type.js.map +1 -1
- package/cjs/brush/index.js +2 -1
- package/cjs/checkbox/index.js +1 -2
- package/cjs/data-zoom/config.d.ts +0 -6
- package/cjs/data-zoom/config.js +1 -7
- package/cjs/data-zoom/config.js.map +1 -1
- package/cjs/data-zoom/data-zoom.d.ts +3 -2
- package/cjs/data-zoom/data-zoom.js +19 -15
- package/cjs/data-zoom/data-zoom.js.map +1 -1
- package/cjs/data-zoom/type.d.ts +6 -0
- package/cjs/data-zoom/type.js +6 -1
- package/cjs/data-zoom/type.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/cjs/indicator/indicator.js +6 -50
- package/cjs/indicator/indicator.js.map +1 -1
- package/cjs/indicator/type.d.ts +2 -5
- package/cjs/indicator/type.js.map +1 -1
- package/cjs/label/animate/animate.d.ts +8 -2
- package/cjs/label/animate/animate.js +37 -3
- package/cjs/label/animate/animate.js.map +1 -1
- package/cjs/label/arc.d.ts +3 -4
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/area.d.ts +15 -0
- package/cjs/label/area.js +41 -0
- package/cjs/label/area.js.map +1 -0
- package/cjs/label/base.d.ts +17 -14
- package/cjs/label/base.js +38 -61
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/dataLabel.js +8 -5
- package/cjs/label/dataLabel.js.map +1 -1
- package/cjs/label/line.d.ts +1 -1
- package/cjs/label/line.js +2 -9
- package/cjs/label/line.js.map +1 -1
- package/cjs/label/type.d.ts +26 -10
- package/cjs/label/type.js +1 -2
- package/cjs/label/type.js.map +1 -1
- package/cjs/label/util.d.ts +4 -0
- package/cjs/label/util.js +14 -2
- package/cjs/label/util.js.map +1 -1
- package/cjs/link-path/type.js +1 -1
- package/cjs/marker/point.d.ts +1 -1
- package/cjs/marker/type.js.map +1 -1
- package/cjs/scrollbar/scrollbar.js.map +1 -1
- package/cjs/tag/tag.js +40 -90
- package/cjs/tag/tag.js.map +1 -1
- package/cjs/tag/type.d.ts +3 -4
- package/cjs/tag/type.js.map +1 -1
- package/cjs/title/title.js +47 -111
- package/cjs/title/title.js.map +1 -1
- package/cjs/title/type.d.ts +5 -10
- package/cjs/title/type.js.map +1 -1
- package/cjs/tooltip/tooltip.js +1 -26
- package/cjs/tooltip/tooltip.js.map +1 -1
- package/cjs/tooltip/type.d.ts +1 -3
- package/cjs/tooltip/type.js.map +1 -1
- package/dist/index.js +290 -311
- package/dist/index.min.js +1 -1
- package/es/axis/base.js +11 -23
- package/es/axis/base.js.map +1 -1
- package/es/axis/line.js +1 -1
- package/es/axis/line.js.map +1 -1
- package/es/axis/type.d.ts +3 -6
- package/es/axis/type.js.map +1 -1
- package/es/brush/index.js +2 -1
- package/es/checkbox/index.js +1 -2
- package/es/data-zoom/config.d.ts +0 -6
- package/es/data-zoom/config.js +0 -7
- package/es/data-zoom/config.js.map +1 -1
- package/es/data-zoom/data-zoom.d.ts +3 -2
- package/es/data-zoom/data-zoom.js +10 -4
- package/es/data-zoom/data-zoom.js.map +1 -1
- package/es/data-zoom/type.d.ts +6 -0
- package/es/data-zoom/type.js +6 -1
- package/es/data-zoom/type.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/es/indicator/indicator.js +6 -50
- package/es/indicator/indicator.js.map +1 -1
- package/es/indicator/type.d.ts +2 -5
- package/es/indicator/type.js.map +1 -1
- package/es/label/animate/animate.d.ts +8 -2
- package/es/label/animate/animate.js +35 -0
- package/es/label/animate/animate.js.map +1 -1
- package/es/label/arc.d.ts +3 -4
- package/es/label/arc.js.map +1 -1
- package/es/label/area.d.ts +15 -0
- package/es/label/area.js +39 -0
- package/es/label/area.js.map +1 -0
- package/es/label/base.d.ts +17 -14
- package/es/label/base.js +40 -63
- package/es/label/base.js.map +1 -1
- package/es/label/dataLabel.js +11 -4
- package/es/label/dataLabel.js.map +1 -1
- package/es/label/line.d.ts +1 -1
- package/es/label/line.js +3 -8
- package/es/label/line.js.map +1 -1
- package/es/label/type.d.ts +26 -10
- package/es/label/type.js +1 -2
- package/es/label/type.js.map +1 -1
- package/es/label/util.d.ts +4 -0
- package/es/label/util.js +13 -1
- package/es/label/util.js.map +1 -1
- package/es/link-path/type.js +1 -1
- package/es/marker/point.d.ts +1 -1
- package/es/marker/type.js.map +1 -1
- package/es/scrollbar/scrollbar.js.map +1 -1
- package/es/tag/tag.js +38 -88
- package/es/tag/tag.js.map +1 -1
- package/es/tag/type.d.ts +3 -4
- package/es/tag/type.js.map +1 -1
- package/es/title/title.js +45 -111
- package/es/title/title.js.map +1 -1
- package/es/title/type.d.ts +5 -10
- package/es/title/type.js.map +1 -1
- package/es/tooltip/tooltip.js +1 -26
- package/es/tooltip/tooltip.js.map +1 -1
- package/es/tooltip/type.d.ts +1 -3
- package/es/tooltip/type.js.map +1 -1
- package/package.json +6 -6
|
@@ -11,7 +11,7 @@ class Indicator extends base_1.AbstractComponent {
|
|
|
11
11
|
super(...arguments), this.name = "indicator";
|
|
12
12
|
}
|
|
13
13
|
render() {
|
|
14
|
-
var _a
|
|
14
|
+
var _a;
|
|
15
15
|
const {visible: visible, title: title, content: content, size: size, limitRatio: limitRatio = 1 / 0} = this.attribute, limit = Math.min(size.width, size.height) * limitRatio, group = this.createOrUpdateChild("indicator-container", {
|
|
16
16
|
x: 0,
|
|
17
17
|
y: 0,
|
|
@@ -20,28 +20,7 @@ class Indicator extends base_1.AbstractComponent {
|
|
|
20
20
|
if (!0 !== visible) return void (group && group.hideAll());
|
|
21
21
|
if ((0, vutils_1.isValid)(title)) if (!1 !== title.visible) {
|
|
22
22
|
const titleStyle = (0, vutils_1.merge)({}, (0, vutils_1.get)(config_1.DEFAULT_INDICATOR_THEME, "title.style"), title.style);
|
|
23
|
-
|
|
24
|
-
textConfig: titleStyle.text
|
|
25
|
-
}, titleStyle), {
|
|
26
|
-
visible: title.visible,
|
|
27
|
-
x: 0,
|
|
28
|
-
y: 0,
|
|
29
|
-
width: null !== (_a = titleStyle.width) && void 0 !== _a ? _a : 0,
|
|
30
|
-
height: null !== (_b = titleStyle.height) && void 0 !== _b ? _b : 0
|
|
31
|
-
}), "richtext") : "html" === titleStyle.type ? this._title = group.createOrUpdateChild("indicator-title", Object.assign(Object.assign({
|
|
32
|
-
textConfig: [],
|
|
33
|
-
html: Object.assign({
|
|
34
|
-
dom: titleStyle.text,
|
|
35
|
-
container: "",
|
|
36
|
-
width: 30,
|
|
37
|
-
height: 30,
|
|
38
|
-
style: {}
|
|
39
|
-
}, titleStyle)
|
|
40
|
-
}, titleStyle), {
|
|
41
|
-
visible: title.visible,
|
|
42
|
-
x: 0,
|
|
43
|
-
y: 0
|
|
44
|
-
}), "richtext") : this._title = group.createOrUpdateChild("indicator-title", Object.assign(Object.assign({}, titleStyle), {
|
|
23
|
+
this._title = group.createOrUpdateChild("indicator-title", Object.assign(Object.assign({}, titleStyle), {
|
|
45
24
|
lineHeight: (0, vutils_1.isValid)(titleStyle.lineHeight) ? titleStyle.lineHeight : titleStyle.fontSize,
|
|
46
25
|
visible: title.visible,
|
|
47
26
|
x: 0,
|
|
@@ -58,37 +37,14 @@ class Indicator extends base_1.AbstractComponent {
|
|
|
58
37
|
vutils_1.array)(content), contentComponents = [];
|
|
59
38
|
let lastContentHeight = 0;
|
|
60
39
|
contents.forEach(((contentItem, i) => {
|
|
61
|
-
var _a, _b;
|
|
62
40
|
if (!1 !== contentItem.visible) {
|
|
63
|
-
const contentStyle = (0, vutils_1.merge)({}, (0, vutils_1.get)(config_1.DEFAULT_INDICATOR_THEME, "content.style"), contentItem.style)
|
|
64
|
-
let contentComponent;
|
|
65
|
-
contentComponent = "rich" === contentStyle.type ? group.createOrUpdateChild("indicator-content-" + i, Object.assign(Object.assign({
|
|
66
|
-
textConfig: contentStyle.text
|
|
67
|
-
}, contentStyle), {
|
|
68
|
-
visible: title.visible,
|
|
69
|
-
x: 0,
|
|
70
|
-
y: titleHeight + titleSpace + lastContentHeight,
|
|
71
|
-
width: null !== (_a = contentStyle.width) && void 0 !== _a ? _a : 0,
|
|
72
|
-
height: null !== (_b = contentStyle.height) && void 0 !== _b ? _b : 0
|
|
73
|
-
}), "richtext") : "html" === contentStyle.type ? group.createOrUpdateChild("indicator-content-" + i, Object.assign(Object.assign({
|
|
74
|
-
textConfig: [],
|
|
75
|
-
html: Object.assign({
|
|
76
|
-
dom: contentStyle.text,
|
|
77
|
-
container: "",
|
|
78
|
-
width: 30,
|
|
79
|
-
height: 30,
|
|
80
|
-
style: {}
|
|
81
|
-
}, contentStyle)
|
|
82
|
-
}, contentStyle), {
|
|
83
|
-
visible: title.visible,
|
|
84
|
-
x: 0,
|
|
85
|
-
y: titleHeight + titleSpace + lastContentHeight
|
|
86
|
-
}), "richtext") : group.createOrUpdateChild("indicator-content-" + i, Object.assign(Object.assign({}, contentStyle), {
|
|
41
|
+
const contentStyle = (0, vutils_1.merge)({}, (0, vutils_1.get)(config_1.DEFAULT_INDICATOR_THEME, "content.style"), contentItem.style), contentComponent = group.createOrUpdateChild("indicator-content-" + i, Object.assign(Object.assign({}, contentStyle), {
|
|
87
42
|
lineHeight: (0, vutils_1.isValid)(contentStyle.lineHeight) ? contentStyle.lineHeight : contentStyle.fontSize,
|
|
88
43
|
visible: contentItem.visible,
|
|
89
44
|
x: 0,
|
|
90
45
|
y: titleHeight + titleSpace + lastContentHeight
|
|
91
|
-
}), "text")
|
|
46
|
+
}), "text");
|
|
47
|
+
contentItem.autoFit && (0, vutils_1.isValidNumber)(limit) && this._setAutoFit(limit, contentComponent, contentItem),
|
|
92
48
|
contentItem.autoLimit && (0, vutils_1.isValidNumber)(limitRatio) && contentComponent.setAttribute("maxLineWidth", limit),
|
|
93
49
|
contentComponents.push(contentComponent);
|
|
94
50
|
const contentSpace = (null == contentItem ? void 0 : contentItem.space) ? contentItem.space : 0;
|
|
@@ -99,7 +55,7 @@ class Indicator extends base_1.AbstractComponent {
|
|
|
99
55
|
}
|
|
100
56
|
})), this._content = contentComponents;
|
|
101
57
|
}
|
|
102
|
-
const totalHeight = null !== (
|
|
58
|
+
const totalHeight = null !== (_a = null == group ? void 0 : group.AABBBounds.height()) && void 0 !== _a ? _a : 0;
|
|
103
59
|
group.setAttribute("y", size.height / 2 - totalHeight / 2), group.setAttribute("x", size.width / 2);
|
|
104
60
|
}
|
|
105
61
|
_setAutoFit(limit, indicatorItem, indicatorItemSpec) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/indicator/indicator.ts"],"names":[],"mappings":";;;AAIA,6CAA6E;AAC7E,uCAAiD;AACjD,kCAA0C;AAE1C,qCAAmD;AAEnD,MAAa,SAAU,SAAQ,wBAAgD;IAA/E;;QACE,SAAI,GAAG,WAAW,CAAC;IAmMrB,CAAC;IA9LW,MAAM;;QACd,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAgC,CAAC;QAEvG,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC;QAE7D,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,qBAAqB,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,OAAO,CAAW,CAAC;QAG5G,IAAI,OAAO,KAAK,IAAI,EAAE;YACpB,KAAK,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO;SACR;QAED,IAAI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aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,CAAC,MAAM,EAAE,mCAAI,CAAC,CAAC;QACpD,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC;QAC3D,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAC1C,CAAC;IAEO,WAAW,CAAC,KAAa,EAAE,aAAoB,EAAE,iBAAoC;;QAC3F,MAAM,WAAW,GAAG,IAAA,sBAAe,EAAC,MAAA,MAAA,iBAAiB,CAAC,KAAK,0CAAE,IAAI,mCAAI,EAAE,EAAE,MAAA,iBAAiB,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC,KAAK,CAAC;QAC9G,IAAI,WAAW,GAAG,CAAC,EAAE;YACnB,MAAM,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,MAAA,iBAAiB,CAAC,UAAU,mCAAI,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC;YAC5E,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,MAAA,MAAA,iBAAiB,CAAC,KAAK,0CAAE,QAAQ,mCAAI,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC;YAC/E,aAAa,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YACjD,aAAa,CAAC,YAAY,CACxB,YAAY,EACZ,IAAA,gBAAO,EAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAC5F,CAAC;SACH;IACH,CAAC;CACF;AApMD,8BAoMC","file":"indicator.js","sourcesContent":["/**\n * @description 指标卡组件\n */\nimport type { IGroup, INode, IText } from '@visactor/vrender-core';\nimport { merge, isValid, array, isValidNumber, get } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { measureTextSize } from '../util';\nimport type { IndicatorAttributes, IndicatorItemSpec } from './type';\nimport { DEFAULT_INDICATOR_THEME } from './config';\n\nexport class Indicator extends AbstractComponent<Required<IndicatorAttributes>> {\n name = 'indicator';\n\n private _title?: IText;\n private _content?: IText | IText[];\n\n protected render() {\n const { visible, title, content, size, limitRatio = Infinity } = this.attribute as IndicatorAttributes;\n\n const limit = Math.min(size.width, size.height) * limitRatio;\n\n const group = this.createOrUpdateChild('indicator-container', { x: 0, y: 0, zIndex: 1 }, 'group') as IGroup;\n\n // 指标卡全部隐藏\n if (visible !== true) {\n group && group.hideAll();\n return;\n }\n\n if (isValid(title)) {\n if (title.visible !== false) {\n const titleStyle = merge({}, get(DEFAULT_INDICATOR_THEME, 'title.style'), title.style);\n if (titleStyle.type === 'rich') {\n this._title = group.createOrUpdateChild(\n 'indicator-title',\n {\n textConfig: titleStyle.text,\n ...titleStyle,\n visible: title.visible,\n x: 0,\n y: 0,\n width: titleStyle.width ?? 0,\n height: titleStyle.height ?? 0\n },\n 'richtext'\n ) as IText;\n } else if (titleStyle.type === 'html') {\n this._title = group.createOrUpdateChild(\n 'indicator-title',\n {\n textConfig: [],\n html: {\n dom: titleStyle.text as string,\n container: '',\n width: 30,\n height: 30,\n style: {},\n ...titleStyle\n },\n ...titleStyle,\n visible: title.visible,\n x: 0,\n y: 0\n },\n 'richtext'\n ) as IText;\n } else {\n this._title = group.createOrUpdateChild(\n 'indicator-title',\n {\n ...titleStyle,\n /**\n * 加入以下逻辑:如果没有声明lineHeight,默认 lineHeight 等于 fontSize\n * 因为如果不声明 vrender 底层会默认给文本加上 2px 的高度,会影响布局计算\n * 注意:在autoFit改变fontsize时,lineHeight也要同步修改\n */\n lineHeight: isValid(titleStyle.lineHeight) ? titleStyle.lineHeight : titleStyle.fontSize,\n visible: title.visible,\n x: 0,\n y: 0\n },\n 'text'\n ) as IText;\n }\n\n // auto-fit\n if (title.autoFit && isValidNumber(limit)) {\n this._setAutoFit(limit, this._title, title);\n }\n\n //auto-limit\n if (title.autoLimit && isValidNumber(limitRatio)) {\n this._title.setAttribute('maxLineWidth', limit);\n }\n } else {\n /**\n * indicator部分隐藏\n * 例如title隐藏了,content还保留。直接设置visible:false 计算group.AABBounts是错的,影响上下居中。\n * 这里把隐藏的nodes删除后,group.AABBounts计算才正确。\n */\n const titleNode = group.find(node => node.name === 'indicator-title', false);\n titleNode && group.removeChild(titleNode as INode);\n this._title = undefined;\n }\n }\n\n const titleHeight = this._title ? this._title.AABBBounds.height() : 0;\n\n if (isValid(content)) {\n const titleSpace = this._title ? (title?.space ? title.space : 0) : 0;\n const contents: IndicatorItemSpec[] = array(content);\n const contentComponents: IText[] = [];\n let lastContentHeight = 0;\n contents.forEach((contentItem, i) => {\n if (contentItem.visible !== false) {\n const contentStyle = merge({}, get(DEFAULT_INDICATOR_THEME, 'content.style'), contentItem.style);\n let contentComponent;\n if (contentStyle.type === 'rich') {\n contentComponent = group.createOrUpdateChild(\n 'indicator-content-' + i,\n {\n textConfig: contentStyle.text,\n ...contentStyle,\n visible: title.visible,\n x: 0,\n y: titleHeight + titleSpace + lastContentHeight,\n width: contentStyle.width ?? 0,\n height: contentStyle.height ?? 0\n },\n 'richtext'\n ) as IText;\n } else if (contentStyle.type === 'html') {\n contentComponent = group.createOrUpdateChild(\n 'indicator-content-' + i,\n {\n textConfig: [],\n html: {\n dom: contentStyle.text as string,\n container: '',\n width: 30,\n height: 30,\n style: {},\n ...contentStyle\n },\n ...contentStyle,\n visible: title.visible,\n x: 0,\n y: titleHeight + titleSpace + lastContentHeight\n },\n 'richtext'\n ) as IText;\n } else {\n contentComponent = group.createOrUpdateChild(\n 'indicator-content-' + i,\n {\n ...contentStyle,\n lineHeight: isValid(contentStyle.lineHeight) ? contentStyle.lineHeight : contentStyle.fontSize,\n visible: contentItem.visible,\n x: 0,\n y: titleHeight + titleSpace + lastContentHeight\n },\n 'text'\n ) as IText;\n }\n\n // auto-fit\n if (contentItem.autoFit && isValidNumber(limit)) {\n this._setAutoFit(limit, contentComponent, contentItem);\n }\n\n //auto-limit\n if (contentItem.autoLimit && isValidNumber(limitRatio)) {\n contentComponent.setAttribute('maxLineWidth', limit);\n }\n\n contentComponents.push(contentComponent);\n const contentSpace = contentItem?.space ? contentItem.space : 0;\n lastContentHeight += contentComponent.AABBBounds.height() + contentSpace;\n } else {\n /**\n * indicator部分隐藏\n */\n const contentItemNode = group.find(node => node.name === 'indicator-content-' + i, false);\n contentItemNode && group.removeChild(contentItemNode as INode);\n }\n });\n this._content = contentComponents;\n }\n\n const totalHeight = group?.AABBBounds.height() ?? 0;\n group.setAttribute('y', size.height / 2 - totalHeight / 2);\n group.setAttribute('x', size.width / 2);\n }\n\n private _setAutoFit(limit: number, indicatorItem: IText, indicatorItemSpec: IndicatorItemSpec) {\n const originWidth = measureTextSize(indicatorItemSpec.style?.text ?? '', indicatorItemSpec.style ?? {}).width;\n if (originWidth > 0) {\n const ratio = (limit * (indicatorItemSpec.fitPercent ?? 0.5)) / originWidth;\n const fontSize = Math.floor((indicatorItemSpec.style?.fontSize ?? 20) * ratio);\n indicatorItem.setAttribute('fontSize', fontSize);\n indicatorItem.setAttribute(\n 'lineHeight',\n isValid(indicatorItemSpec.style.lineHeight) ? indicatorItemSpec.style.lineHeight : fontSize\n );\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/indicator/indicator.ts"],"names":[],"mappings":";;;AAIA,6CAA6E;AAC7E,uCAAiD;AACjD,kCAA0C;AAE1C,qCAAmD;AAEnD,MAAa,SAAU,SAAQ,wBAAgD;IAA/E;;QACE,SAAI,GAAG,WAAW,CAAC;IA0HrB,CAAC;IArHW,MAAM;;QACd,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAgC,CAAC;QAEvG,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EA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,CAAC;QAC3D,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAC1C,CAAC;IAEO,WAAW,CAAC,KAAa,EAAE,aAAoB,EAAE,iBAAoC;;QAC3F,MAAM,WAAW,GAAG,IAAA,sBAAe,EAAC,MAAA,MAAA,iBAAiB,CAAC,KAAK,0CAAE,IAAI,mCAAI,EAAE,EAAE,MAAA,iBAAiB,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC,KAAK,CAAC;QAC9G,IAAI,WAAW,GAAG,CAAC,EAAE;YACnB,MAAM,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,MAAA,iBAAiB,CAAC,UAAU,mCAAI,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC;YAC5E,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,MAAA,MAAA,iBAAiB,CAAC,KAAK,0CAAE,QAAQ,mCAAI,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC;YAC/E,aAAa,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YACjD,aAAa,CAAC,YAAY,CACxB,YAAY,EACZ,IAAA,gBAAO,EAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAC5F,CAAC;SACH;IACH,CAAC;CACF;AA3HD,8BA2HC","file":"indicator.js","sourcesContent":["/**\n * @description 指标卡组件\n */\nimport type { IGroup, INode, IText } from '@visactor/vrender-core';\nimport { merge, isValid, array, isValidNumber, get } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { measureTextSize } from '../util';\nimport type { IndicatorAttributes, IndicatorItemSpec } from './type';\nimport { DEFAULT_INDICATOR_THEME } from './config';\n\nexport class Indicator extends AbstractComponent<Required<IndicatorAttributes>> {\n name = 'indicator';\n\n private _title?: IText;\n private _content?: IText | IText[];\n\n protected render() {\n const { visible, title, content, size, limitRatio = Infinity } = this.attribute as IndicatorAttributes;\n\n const limit = Math.min(size.width, size.height) * limitRatio;\n\n const group = this.createOrUpdateChild('indicator-container', { x: 0, y: 0, zIndex: 1 }, 'group') as IGroup;\n\n // 指标卡全部隐藏\n if (visible !== true) {\n group && group.hideAll();\n return;\n }\n\n if (isValid(title)) {\n if (title.visible !== false) {\n const titleStyle = merge({}, get(DEFAULT_INDICATOR_THEME, 'title.style'), title.style);\n this._title = group.createOrUpdateChild(\n 'indicator-title',\n {\n ...titleStyle,\n /**\n * 加入以下逻辑:如果没有声明lineHeight,默认 lineHeight 等于 fontSize\n * 因为如果不声明 vrender 底层会默认给文本加上 2px 的高度,会影响布局计算\n * 注意:在autoFit改变fontsize时,lineHeight也要同步修改\n */\n lineHeight: isValid(titleStyle.lineHeight) ? titleStyle.lineHeight : titleStyle.fontSize,\n visible: title.visible,\n x: 0,\n y: 0\n },\n 'text'\n ) as IText;\n\n // auto-fit\n if (title.autoFit && isValidNumber(limit)) {\n this._setAutoFit(limit, this._title, title);\n }\n\n //auto-limit\n if (title.autoLimit && isValidNumber(limitRatio)) {\n this._title.setAttribute('maxLineWidth', limit);\n }\n } else {\n /**\n * indicator部分隐藏\n * 例如title隐藏了,content还保留。直接设置visible:false 计算group.AABBounts是错的,影响上下居中。\n * 这里把隐藏的nodes删除后,group.AABBounts计算才正确。\n */\n const titleNode = group.find(node => node.name === 'indicator-title', false);\n titleNode && group.removeChild(titleNode as INode);\n this._title = undefined;\n }\n }\n\n const titleHeight = this._title ? this._title.AABBBounds.height() : 0;\n\n if (isValid(content)) {\n const titleSpace = this._title ? (title?.space ? title.space : 0) : 0;\n const contents: IndicatorItemSpec[] = array(content);\n const contentComponents: IText[] = [];\n let lastContentHeight = 0;\n contents.forEach((contentItem, i) => {\n if (contentItem.visible !== false) {\n const contentStyle = merge({}, get(DEFAULT_INDICATOR_THEME, 'content.style'), contentItem.style);\n const contentComponent = group.createOrUpdateChild(\n 'indicator-content-' + i,\n {\n ...contentStyle,\n lineHeight: isValid(contentStyle.lineHeight) ? contentStyle.lineHeight : contentStyle.fontSize,\n visible: contentItem.visible,\n x: 0,\n y: titleHeight + titleSpace + lastContentHeight\n },\n 'text'\n ) as IText;\n\n // auto-fit\n if (contentItem.autoFit && isValidNumber(limit)) {\n this._setAutoFit(limit, contentComponent, contentItem);\n }\n\n //auto-limit\n if (contentItem.autoLimit && isValidNumber(limitRatio)) {\n contentComponent.setAttribute('maxLineWidth', limit);\n }\n\n contentComponents.push(contentComponent);\n const contentSpace = contentItem?.space ? contentItem.space : 0;\n lastContentHeight += contentComponent.AABBBounds.height() + contentSpace;\n } else {\n /**\n * indicator部分隐藏\n */\n const contentItemNode = group.find(node => node.name === 'indicator-content-' + i, false);\n contentItemNode && group.removeChild(contentItemNode as INode);\n }\n });\n this._content = contentComponents;\n }\n\n const totalHeight = group?.AABBBounds.height() ?? 0;\n group.setAttribute('y', size.height / 2 - totalHeight / 2);\n group.setAttribute('x', size.width / 2);\n }\n\n private _setAutoFit(limit: number, indicatorItem: IText, indicatorItemSpec: IndicatorItemSpec) {\n const originWidth = measureTextSize(indicatorItemSpec.style?.text ?? '', indicatorItemSpec.style ?? {}).width;\n if (originWidth > 0) {\n const ratio = (limit * (indicatorItemSpec.fitPercent ?? 0.5)) / originWidth;\n const fontSize = Math.floor((indicatorItemSpec.style?.fontSize ?? 20) * ratio);\n indicatorItem.setAttribute('fontSize', fontSize);\n indicatorItem.setAttribute(\n 'lineHeight',\n isValid(indicatorItemSpec.style.lineHeight) ? indicatorItemSpec.style.lineHeight : fontSize\n );\n }\n }\n}\n"]}
|
package/cjs/indicator/type.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IGroupGraphicAttribute, ITextGraphicAttribute
|
|
1
|
+
import type { IGroupGraphicAttribute, ITextGraphicAttribute } from '@visactor/vrender-core';
|
|
2
2
|
export interface IndicatorAttributes extends IGroupGraphicAttribute {
|
|
3
3
|
visible?: boolean;
|
|
4
4
|
size: {
|
|
@@ -17,8 +17,5 @@ export interface IndicatorItemSpec {
|
|
|
17
17
|
autoLimit?: boolean;
|
|
18
18
|
autoFit?: boolean;
|
|
19
19
|
fitPercent?: number;
|
|
20
|
-
style?: ITextGraphicAttribute
|
|
21
|
-
type?: string;
|
|
22
|
-
text?: string | string[] | number | number[] | IRichTextCharacter[];
|
|
23
|
-
};
|
|
20
|
+
style?: ITextGraphicAttribute;
|
|
24
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/indicator/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { IGroupGraphicAttribute, ITextGraphicAttribute
|
|
1
|
+
{"version":3,"sources":["../src/indicator/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { IGroupGraphicAttribute, ITextGraphicAttribute } from '@visactor/vrender-core';\n\nexport interface IndicatorAttributes extends IGroupGraphicAttribute {\n /**\n * 是否显示指标卡组件\n * @default true\n */\n visible?: boolean;\n /**\n * 内容尺寸\n */\n size: { width: number; height: number };\n /**\n * 指标卡 x 方向偏移\n * @default 0\n */\n dx?: number;\n /**\n * 指标卡 y 方向偏移\n * @default 0\n */\n dy?: number;\n /**\n * 指标卡宽度占内容区域的最大比值(从0到1)\n */\n limitRatio?: number;\n /**\n * 指标卡标题文字配置\n */\n title?: IndicatorItemSpec;\n /**\n * 指标卡内容文字配置\n */\n content?: IndicatorItemSpec[] | IndicatorItemSpec;\n}\n\nexport interface IndicatorItemSpec {\n /**\n * 是否显示当前项\n * @default true\n */\n visible?: boolean;\n /**\n * title.space: title 和 content 之间的间距\n * contentItem.space: content 之间的间距\n */\n space?: number;\n /**\n * 是否自适应文字空间进行缩略\n * 按照原字体大小,根据空间大小缩略文字\n * @default false\n */\n autoLimit?: boolean;\n /**\n * 是否自适应文字空间缩放文字大小\n * 不缩略文字,改变字体大小以适应空间\n * @default false\n */\n autoFit?: boolean;\n /**\n * 自适应文字宽度与可用空间的比例\n * @default 0.5\n */\n fitPercent?: number;\n /**\n * 文字样式\n */\n style?: ITextGraphicAttribute;\n}\n"]}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import type { ITextGraphicAttribute } from '@visactor/vrender-core';
|
|
2
|
-
import type { ILabelAnimation } from '../type';
|
|
1
|
+
import type { IText, ITextGraphicAttribute, EasingType } from '@visactor/vrender-core';
|
|
2
|
+
import type { BaseLabelAttrs, ILabelAnimation, ILabelUpdateChannelAnimation } from '../type';
|
|
3
3
|
export declare function getAnimationAttributes(textAttribute: ITextGraphicAttribute, type: 'fadeIn' | 'fadeOut'): {
|
|
4
4
|
from: any;
|
|
5
5
|
to: any;
|
|
6
6
|
};
|
|
7
|
+
export declare function updateAnimation(prev: IText, next: IText, animationConfig: BaseLabelAttrs['animationUpdate']): void;
|
|
8
|
+
export declare const update: (prev: IText, next: IText, channel?: string[], options?: ILabelUpdateChannelAnimation['options']) => {
|
|
9
|
+
from: Partial<ITextGraphicAttribute>;
|
|
10
|
+
to: Partial<ITextGraphicAttribute>;
|
|
11
|
+
};
|
|
12
|
+
export declare function playIncreaseCount(prev: IText, next: IText, duration: number, easing: EasingType): void;
|
|
7
13
|
export declare const DefaultLabelAnimation: ILabelAnimation;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.DefaultLabelAnimation = exports.getAnimationAttributes = void 0;
|
|
5
|
+
}), exports.DefaultLabelAnimation = exports.playIncreaseCount = exports.update = exports.updateAnimation = exports.getAnimationAttributes = void 0;
|
|
6
6
|
|
|
7
|
-
const fadeIn = (textAttribute = {}) => {
|
|
7
|
+
const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), fadeIn = (textAttribute = {}) => {
|
|
8
8
|
var _a, _b, _c;
|
|
9
9
|
return {
|
|
10
10
|
from: {
|
|
@@ -45,7 +45,41 @@ function getAnimationAttributes(textAttribute, type) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
function updateAnimation(prev, next, animationConfig) {
|
|
49
|
+
if (!(0, vutils_1.isArray)(animationConfig)) {
|
|
50
|
+
const {duration: duration, easing: easing, increaseEffect: increaseEffect = !0} = animationConfig;
|
|
51
|
+
return prev.animate().to(next.attribute, duration, easing), void (increaseEffect && playIncreaseCount(prev, next, duration, easing));
|
|
52
|
+
}
|
|
53
|
+
animationConfig.forEach(((cfg, i) => {
|
|
54
|
+
const {duration: duration, easing: easing, increaseEffect: increaseEffect = !0, channel: channel} = cfg, {from: from, to: to} = (0,
|
|
55
|
+
exports.update)(prev, next, channel, cfg.options);
|
|
56
|
+
(0, vutils_1.isEmpty)(to) || prev.animate().to(to, duration, easing), "text" in from && "text" in to && increaseEffect && playIncreaseCount(prev, next, duration, easing);
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
exports.getAnimationAttributes = getAnimationAttributes, exports.updateAnimation = updateAnimation;
|
|
61
|
+
|
|
62
|
+
const update = (prev, next, channel, options) => {
|
|
63
|
+
const from = Object.assign({}, prev.attribute), to = Object.assign({}, next.attribute);
|
|
64
|
+
return (0, vutils_1.array)(null == options ? void 0 : options.excludeChannels).forEach((key => {
|
|
65
|
+
delete to[key];
|
|
66
|
+
})), Object.keys(to).forEach((key => {
|
|
67
|
+
channel && !channel.includes(key) && delete to[key];
|
|
68
|
+
})), {
|
|
69
|
+
from: from,
|
|
70
|
+
to: to
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
function playIncreaseCount(prev, next, duration, easing) {
|
|
75
|
+
prev.attribute.text !== next.attribute.text && (0, vutils_1.isValidNumber)(Number(prev.attribute.text) * Number(next.attribute.text)) && prev.animate().play(new vrender_core_1.IncreaseCount({
|
|
76
|
+
text: prev.attribute.text
|
|
77
|
+
}, {
|
|
78
|
+
text: next.attribute.text
|
|
79
|
+
}, duration, easing));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
exports.update = update, exports.playIncreaseCount = playIncreaseCount, exports.DefaultLabelAnimation = {
|
|
49
83
|
mode: "same-time",
|
|
50
84
|
duration: 300,
|
|
51
85
|
easing: "linear"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/label/animate/animate.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/label/animate/animate.ts"],"names":[],"mappings":";;;AACA,yDAAuD;AAEvD,6CAA0E;AAE1E,MAAM,MAAM,GAAG,CAAC,gBAAuC,EAAE,EAAE,EAAE;;IAC3D,OAAO;QACL,IAAI,EAAE;YACJ,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,CAAC;YACd,aAAa,EAAE,CAAC;SACjB;QACD,EAAE,EAAE;YACF,OAAO,EAAE,MAAA,aAAa,CAAC,OAAO,mCAAI,CAAC;YACnC,WAAW,EAAE,MAAA,aAAa,CAAC,WAAW,mCAAI,CAAC;YAC3C,aAAa,EAAE,MAAA,aAAa,CAAC,aAAa,mCAAI,CAAC;SAChD;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,gBAAuC,EAAE,EAAE,EAAE;;IAC5D,OAAO;QACL,IAAI,EAAE;YACJ,OAAO,EAAE,MAAA,aAAa,CAAC,OAAO,mCAAI,CAAC;YACnC,WAAW,EAAE,MAAA,aAAa,CAAC,WAAW,mCAAI,CAAC;YAC3C,aAAa,EAAE,MAAA,aAAa,CAAC,aAAa,mCAAI,CAAC;SAChD;QACD,EAAE,EAAE;YACF,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,CAAC;YACd,aAAa,EAAE,CAAC;SACjB;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAE7C,SAAgB,sBAAsB,CACpC,aAAoC,EACpC,IAA0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R,MAAM,CACP,CACF,CAAC;KACL;AACH,CAAC;AAhBD,8CAgBC;AAEY,QAAA,qBAAqB,GAAoB;IACpD,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,GAAG;IACb,MAAM,EAAE,QAAsB;CAC/B,CAAC","file":"animate.js","sourcesContent":["import type { IText, ITextGraphicAttribute, EasingType } from '@visactor/vrender-core';\nimport { IncreaseCount } from '@visactor/vrender-core';\nimport type { BaseLabelAttrs, ILabelAnimation, ILabelUpdateChannelAnimation } from '../type';\nimport { array, isArray, isEmpty, isValidNumber } from '@visactor/vutils';\n\nconst fadeIn = (textAttribute: ITextGraphicAttribute = {}) => {\n return {\n from: {\n opacity: 0,\n fillOpacity: 0,\n strokeOpacity: 0\n },\n to: {\n opacity: textAttribute.opacity ?? 1,\n fillOpacity: textAttribute.fillOpacity ?? 1,\n strokeOpacity: textAttribute.strokeOpacity ?? 1\n }\n };\n};\n\nconst fadeOut = (textAttribute: ITextGraphicAttribute = {}) => {\n return {\n from: {\n opacity: textAttribute.opacity ?? 1,\n fillOpacity: textAttribute.fillOpacity ?? 1,\n strokeOpacity: textAttribute.strokeOpacity ?? 1\n },\n to: {\n opacity: 0,\n fillOpacity: 0,\n strokeOpacity: 0\n }\n };\n};\n\nconst animationEffects = { fadeIn, fadeOut };\n\nexport function getAnimationAttributes(\n textAttribute: ITextGraphicAttribute,\n type: 'fadeIn' | 'fadeOut'\n): {\n from: any;\n to: any;\n} {\n return animationEffects[type]?.(textAttribute) ?? { from: {}, to: {} };\n}\n\nexport function updateAnimation(prev: IText, next: IText, animationConfig: BaseLabelAttrs['animationUpdate']) {\n if (!isArray(animationConfig)) {\n const { duration, easing, increaseEffect = true } = animationConfig;\n prev.animate().to(next.attribute, duration, easing);\n increaseEffect && playIncreaseCount(prev, next, duration, easing);\n return;\n }\n\n animationConfig.forEach((cfg, i) => {\n const { duration, easing, increaseEffect = true, channel } = cfg;\n const { from, to } = update(prev, next, channel, cfg.options);\n if (!isEmpty(to)) {\n prev.animate().to(to, duration, easing);\n }\n\n if ('text' in from && 'text' in to && increaseEffect) {\n playIncreaseCount(prev, next, duration, easing);\n }\n });\n}\n\nexport const update = (\n prev: IText,\n next: IText,\n channel?: string[],\n options?: ILabelUpdateChannelAnimation['options']\n) => {\n const from = Object.assign({}, prev.attribute);\n const to = Object.assign({}, next.attribute);\n array(options?.excludeChannels).forEach(key => {\n delete to[key];\n });\n Object.keys(to).forEach(key => {\n if (channel && !channel.includes(key)) {\n delete to[key];\n }\n });\n return { from, to };\n};\n\nexport function playIncreaseCount(prev: IText, next: IText, duration: number, easing: EasingType) {\n if (\n prev.attribute.text !== next.attribute.text &&\n isValidNumber(Number(prev.attribute.text) * Number(next.attribute.text))\n ) {\n prev\n .animate()\n .play(\n new IncreaseCount(\n { text: prev.attribute.text as string },\n { text: next.attribute.text as string },\n duration,\n easing\n )\n );\n }\n}\n\nexport const DefaultLabelAnimation: ILabelAnimation = {\n mode: 'same-time',\n duration: 300,\n easing: 'linear' as EasingType\n};\n"]}
|
package/cjs/label/arc.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { IAABBBounds, IBoundsLike } from '@visactor/vutils';
|
|
2
2
|
import { LabelBase } from './base';
|
|
3
3
|
import type { ArcLabelAttrs, IPoint, Quadrant, BaseLabelAttrs, LabelItem, IArcLabelLineSpec } from './type';
|
|
4
|
-
import type { IRichText } from '@visactor/vrender-core';
|
|
5
4
|
import { type IText, type IGraphic, type ILine } from '@visactor/vrender-core';
|
|
6
5
|
export declare class ArcInfo {
|
|
7
6
|
key: string;
|
|
@@ -40,12 +39,12 @@ export declare class ArcLabel extends LabelBase<ArcLabelAttrs> {
|
|
|
40
39
|
private _arcLeft;
|
|
41
40
|
private _arcRight;
|
|
42
41
|
constructor(attributes: ArcLabelAttrs);
|
|
43
|
-
protected _overlapping(labels:
|
|
42
|
+
protected _overlapping(labels: IText[]): IText[];
|
|
44
43
|
protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: string, offset?: number): {
|
|
45
44
|
x: number;
|
|
46
45
|
y: number;
|
|
47
46
|
} | undefined;
|
|
48
|
-
protected _layout(data?: LabelItem[]):
|
|
47
|
+
protected _layout(data?: LabelItem[]): IText[];
|
|
49
48
|
protected layoutArcLabels(position: BaseLabelAttrs['position'], attribute: any, currentMarks?: IGraphic[], data?: LabelItem[], textBoundsArray?: any, ellipsisWidth?: number): ArcInfo[];
|
|
50
49
|
private _layoutInsideLabels;
|
|
51
50
|
private _layoutOutsideLabels;
|
|
@@ -64,7 +63,7 @@ export declare class ArcLabel extends LabelBase<ArcLabelAttrs> {
|
|
|
64
63
|
private _restoreY;
|
|
65
64
|
private _checkYRange;
|
|
66
65
|
private _coverLabels;
|
|
67
|
-
protected _labelLine(text:
|
|
66
|
+
protected _labelLine(text: IText): ILine;
|
|
68
67
|
protected computeRadius(r: number, width?: number, height?: number, k?: number): number;
|
|
69
68
|
protected computeLayoutRadius(width: number, height: number): number;
|
|
70
69
|
protected _canPlaceInside(textBound: IBoundsLike, shapeBound: IAABBBounds): boolean;
|