@visactor/vrender-components 0.20.0-alpha.0 → 0.20.0-alpha.2
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/animate/index.d.ts +0 -1
- package/cjs/axis/animate/index.js +1 -1
- package/cjs/axis/animate/index.js.map +1 -1
- package/cjs/axis/grid/base.d.ts +4 -0
- package/cjs/axis/grid/base.js +19 -0
- package/cjs/axis/grid/base.js.map +1 -1
- package/cjs/axis/grid/circle.js +3 -16
- package/cjs/axis/grid/circle.js.map +1 -1
- package/cjs/axis/grid/line.js +3 -17
- package/cjs/axis/grid/line.js.map +1 -1
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +5 -4
- package/cjs/index.js.map +1 -1
- package/cjs/indicator/indicator.d.ts +3 -1
- package/cjs/indicator/indicator.js +19 -41
- package/cjs/indicator/indicator.js.map +1 -1
- package/cjs/indicator/type.d.ts +1 -0
- package/cjs/indicator/type.js.map +1 -1
- package/cjs/interface.d.ts +2 -1
- package/cjs/interface.js.map +1 -1
- package/cjs/label/arc.js +20 -7
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/base.d.ts +1 -1
- package/cjs/label/base.js +30 -10
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/type.d.ts +3 -1
- package/cjs/label/type.js.map +1 -1
- package/cjs/label/util.d.ts +1 -5
- package/cjs/label/util.js +1 -34
- package/cjs/label/util.js.map +1 -1
- package/cjs/legend/discrete/discrete.js +6 -4
- package/cjs/legend/discrete/discrete.js.map +1 -1
- package/cjs/marker/point.js +4 -3
- package/cjs/marker/point.js.map +1 -1
- package/cjs/player/base-player.js +3 -22
- package/cjs/player/base-player.js.map +1 -1
- package/cjs/poptip/poptip-plugin.d.ts +10 -11
- package/cjs/poptip/poptip-plugin.js +32 -27
- package/cjs/poptip/poptip-plugin.js.map +1 -1
- package/cjs/tag/tag.d.ts +1 -1
- package/cjs/tag/tag.js +11 -3
- package/cjs/tag/tag.js.map +1 -1
- package/cjs/timeline/index.d.ts +2 -0
- package/cjs/timeline/index.js +21 -0
- package/cjs/timeline/index.js.map +1 -0
- package/cjs/timeline/register.d.ts +1 -0
- package/cjs/timeline/register.js +15 -0
- package/cjs/timeline/register.js.map +1 -0
- package/cjs/timeline/timeline.d.ts +30 -0
- package/cjs/timeline/timeline.js +178 -0
- package/cjs/timeline/timeline.js.map +1 -0
- package/cjs/timeline/type.d.ts +18 -0
- package/cjs/timeline/type.js +6 -0
- package/cjs/timeline/type.js.map +1 -0
- package/cjs/tooltip/tooltip.d.ts +1 -1
- package/cjs/tooltip/tooltip.js +4 -4
- package/cjs/tooltip/tooltip.js.map +1 -1
- package/cjs/util/index.d.ts +1 -0
- package/cjs/util/index.js +1 -1
- package/cjs/util/index.js.map +1 -1
- package/dist/index.es.js +3963 -4284
- package/es/axis/animate/index.d.ts +0 -1
- package/es/axis/animate/index.js +0 -2
- package/es/axis/animate/index.js.map +1 -1
- package/es/axis/grid/base.d.ts +4 -0
- package/es/axis/grid/base.js +19 -0
- package/es/axis/grid/base.js.map +1 -1
- package/es/axis/grid/circle.js +3 -16
- package/es/axis/grid/circle.js.map +1 -1
- package/es/axis/grid/line.js +3 -17
- package/es/axis/grid/line.js.map +1 -1
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -1
- package/es/index.js.map +1 -1
- package/es/indicator/indicator.d.ts +3 -1
- package/es/indicator/indicator.js +19 -40
- package/es/indicator/indicator.js.map +1 -1
- package/es/indicator/type.d.ts +1 -0
- package/es/indicator/type.js.map +1 -1
- package/es/interface.d.ts +2 -1
- package/es/interface.js.map +1 -1
- package/es/label/arc.js +21 -8
- package/es/label/arc.js.map +1 -1
- package/es/label/base.d.ts +1 -1
- package/es/label/base.js +31 -11
- package/es/label/base.js.map +1 -1
- package/es/label/type.d.ts +3 -1
- package/es/label/type.js.map +1 -1
- package/es/label/util.d.ts +1 -5
- package/es/label/util.js +0 -31
- package/es/label/util.js.map +1 -1
- package/es/legend/discrete/discrete.js +6 -4
- package/es/legend/discrete/discrete.js.map +1 -1
- package/es/marker/point.js +4 -3
- package/es/marker/point.js.map +1 -1
- package/es/player/base-player.js +2 -22
- package/es/player/base-player.js.map +1 -1
- package/es/poptip/poptip-plugin.d.ts +10 -11
- package/es/poptip/poptip-plugin.js +28 -26
- package/es/poptip/poptip-plugin.js.map +1 -1
- package/es/tag/tag.d.ts +1 -1
- package/es/tag/tag.js +12 -2
- package/es/tag/tag.js.map +1 -1
- package/es/timeline/index.d.ts +2 -0
- package/es/timeline/index.js +4 -0
- package/es/timeline/index.js.map +1 -0
- package/es/timeline/register.d.ts +1 -0
- package/es/timeline/register.js +6 -0
- package/es/timeline/register.js.map +1 -0
- package/es/timeline/timeline.d.ts +30 -0
- package/es/timeline/timeline.js +175 -0
- package/es/timeline/timeline.js.map +1 -0
- package/es/timeline/type.d.ts +18 -0
- package/es/timeline/type.js +2 -0
- package/es/timeline/type.js.map +1 -0
- package/es/tooltip/tooltip.d.ts +1 -1
- package/es/tooltip/tooltip.js +4 -4
- package/es/tooltip/tooltip.js.map +1 -1
- package/es/util/index.d.ts +1 -0
- package/es/util/index.js +2 -0
- package/es/util/index.js.map +1 -1
- package/package.json +4 -4
- package/cjs/axis/animate/group-fade.d.ts +0 -18
- package/cjs/axis/animate/group-fade.js +0 -72
- package/cjs/axis/animate/group-fade.js.map +0 -1
- package/es/axis/animate/group-fade.d.ts +0 -18
- package/es/axis/animate/group-fade.js +0 -62
- package/es/axis/animate/group-fade.js.map +0 -1
|
@@ -17,5 +17,5 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
17
17
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
|
-
}), __exportStar(require("./group-transition"), exports)
|
|
20
|
+
}), __exportStar(require("./group-transition"), exports);
|
|
21
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/axis/animate/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC
|
|
1
|
+
{"version":3,"sources":["../src/axis/animate/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC","file":"index.js","sourcesContent":["export * from './group-transition';\n"]}
|
package/cjs/axis/grid/base.d.ts
CHANGED
|
@@ -25,5 +25,9 @@ export declare abstract class BaseGrid<T extends GridBaseAttributes> extends Abs
|
|
|
25
25
|
private _renderGrid;
|
|
26
26
|
private _renderGridByType;
|
|
27
27
|
protected _getNodeId(id: string): string;
|
|
28
|
+
protected _parseTickSegment(): number;
|
|
29
|
+
protected _getPointsOfSubGrid(tickSegment: number, alignWithLabel: boolean): {
|
|
30
|
+
value: number;
|
|
31
|
+
}[];
|
|
28
32
|
release(): void;
|
|
29
33
|
}
|
package/cjs/axis/grid/base.js
CHANGED
|
@@ -124,6 +124,25 @@ class BaseGrid extends base_1.AbstractComponent {
|
|
|
124
124
|
_getNodeId(id) {
|
|
125
125
|
return `${this.id}-${id}`;
|
|
126
126
|
}
|
|
127
|
+
_parseTickSegment() {
|
|
128
|
+
let tickSegment = 1;
|
|
129
|
+
return this.data.length >= 2 && (tickSegment = this.data[1].value - this.data[0].value),
|
|
130
|
+
tickSegment;
|
|
131
|
+
}
|
|
132
|
+
_getPointsOfSubGrid(tickSegment, alignWithLabel) {
|
|
133
|
+
const tickLineCount = this.data.length, points = [];
|
|
134
|
+
return tickLineCount >= 2 && this.data.forEach((item => {
|
|
135
|
+
let tickValue = item.value;
|
|
136
|
+
if (!alignWithLabel) {
|
|
137
|
+
const value = item.value - tickSegment / 2;
|
|
138
|
+
if (this.isInValidValue(value)) return;
|
|
139
|
+
tickValue = value;
|
|
140
|
+
}
|
|
141
|
+
points.push({
|
|
142
|
+
value: tickValue
|
|
143
|
+
});
|
|
144
|
+
})), points;
|
|
145
|
+
}
|
|
127
146
|
release() {
|
|
128
147
|
super.release(), this._prevInnerView = null, this._innerView = null;
|
|
129
148
|
}
|
|
@@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CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;gBACpE,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;gBAClD,MAAM,KAAK,GAAG,6BAAc,CAAC,IAAI,CAAC;oBAChC,IAAI;oBACJ,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC;iBACtB,CAAS,CAAC;gBACX,KAAK,CAAC,IAAI,GAAG,GAAG,IAAI,SAAS,CAAC;gBAC9B,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,WAAW,KAAK,EAAE,CAAC,CAAC;gBACtD,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;aACtB;SACF;IACH,CAAC;IAOS,UAAU,CAAC,EAAU;QAC7B,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;IAC5B,CAAC;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;;AA/KH,4BAgLC;AA7KQ,0BAAiB,GAAgC;IACtD,KAAK,EAAE;QACL,SAAS,EAAE,CAAC;QACZ,MAAM,EAAE,MAAM;QACd,aAAa,EAAE,CAAC;QAChB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KACjB;IACD,OAAO,EAAE;QACP,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,MAAM;YACd,aAAa,EAAE,CAAC;YAChB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACjB;KACF;CACF,CAAC","file":"base.js","sourcesContent":["/**\n * @description 网格线\n */\nimport { isFunction, isArray, merge, PointService, abs, pi } from '@visactor/vutils';\nimport type { IGraphic, IGroup, Path } from '@visactor/vrender-core';\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../../core/base';\nimport type { Point } from '../../core/type';\nimport type { GridItem, CircleGridAttributes, GridBaseAttributes, GridAttributes, LineGridAttributes } from './type';\nimport type { AxisItem, TransformedAxisItem } from '../type';\nimport { AXIS_ELEMENT_NAME } from '../constant';\nimport { getElMap, getVerticalCoord } from '../util';\n\nfunction getLinePath(points: Point[], closed: boolean) {\n let path = '';\n if (points.length === 0) {\n return path;\n }\n points.forEach((point, index) => {\n if (index === 0) {\n path = `M${point.x},${point.y}`;\n } else {\n path += `L${point.x},${point.y}`;\n }\n });\n if (closed) {\n path += 'Z';\n }\n\n return path;\n}\n\nfunction getArcPath(center: Point, points: Point[], reverse: boolean, closed: boolean) {\n let path = '';\n if (!center || points.length === 0) {\n return path;\n }\n const firstPoint = points[0];\n const radius = PointService.distancePP(center, firstPoint);\n const sweepFlag = reverse ? 0 : 1; // 顺时针还是逆时针\n if (closed) {\n // 封闭时,绘制整个圆\n path += `M${center.x},${center.y - radius}A${radius},${radius},0,0,${sweepFlag},${center.x},${\n center.y + radius\n }A${radius},${radius},0,0,${sweepFlag},${center.x},${center.y - radius}Z`;\n } else {\n points.forEach((point, index) => {\n if (index === 0) {\n path = `M${point.x},${point.y}`;\n } else {\n path += `A${radius},${radius},0,0,${sweepFlag},${point.x},${point.y}`;\n }\n });\n }\n\n return path;\n}\n\nfunction getRegionPath(from: Point[], to: Point[], attribute: GridAttributes) {\n const { type, closed } = attribute;\n const reversePoints = to.slice(0).reverse();\n\n let regionPath = '';\n let nextPath = '';\n\n if (type === 'line' && (attribute as LineGridAttributes).smoothLink && (attribute as LineGridAttributes).center) {\n const fromStart = from[0];\n const toEnd = reversePoints[0];\n const center = (attribute as LineGridAttributes).center as Point;\n\n regionPath = getLinePath(from, !!closed);\n nextPath = getLinePath(reversePoints, !!closed);\n const toEndRadius = PointService.distancePP(toEnd, center);\n const fromStartRadius = PointService.distancePP(fromStart, center);\n regionPath += `A${toEndRadius},${toEndRadius},0,0,1,${toEnd.x},${toEnd.y}L${toEnd.x},${toEnd.y}`;\n nextPath += `A${fromStartRadius},${fromStartRadius},0,0,0,${fromStart.x},${fromStart.y}`;\n } else if (type === 'circle') {\n const { center } = attribute as CircleGridAttributes;\n regionPath = getArcPath(center, from, false, !!closed);\n nextPath = getArcPath(center, reversePoints, true, !!closed);\n } else if (type === 'line' || type === 'polygon') {\n regionPath = getLinePath(from, !!closed);\n nextPath = getLinePath(reversePoints, !!closed);\n }\n\n if (closed) {\n regionPath += nextPath;\n } else {\n nextPath = 'L' + nextPath.substring(1); // 更新第一个节点\n regionPath += nextPath;\n regionPath += 'Z';\n }\n return regionPath;\n}\n\nexport abstract class BaseGrid<T extends GridBaseAttributes> extends AbstractComponent<Required<T>> {\n name = 'axis-grid';\n\n static defaultAttributes: Partial<GridBaseAttributes> = {\n style: {\n lineWidth: 1,\n stroke: '#999',\n strokeOpacity: 1,\n lineDash: [4, 4]\n },\n subGrid: {\n visible: false,\n style: {\n lineWidth: 1,\n stroke: '#999',\n strokeOpacity: 1,\n lineDash: [4, 4]\n }\n }\n };\n\n protected _innerView: IGroup;\n getInnerView() {\n return this._innerView;\n }\n\n protected _prevInnerView: { [key: string]: IGraphic }; // 缓存旧场景树,用于自定义动画\n /**\n * 获取更新前的旧场景树\n * @returns 返回更新前的旧场景树\n */\n getPrevInnerView() {\n return this._prevInnerView;\n }\n\n // 经过处理后的坐标轴点数据\n protected data: TransformedAxisItem[] = [];\n abstract getTickCoord(value: number): Point;\n abstract isInValidValue(value: number): boolean;\n abstract getVerticalVector(offset: number, inside: boolean, point: Point): [number, number];\n protected abstract getGridAttribute(isSubGrid: boolean): T;\n\n protected render(): void {\n this._prevInnerView = this._innerView && getElMap(this._innerView);\n\n this.removeAllChild(true);\n this._innerView = graphicCreator.group({ x: 0, y: 0, pickable: false });\n this.add(this._innerView);\n\n const { items, visible } = this.attribute;\n if (items && items.length && visible !== false) {\n this.data = this._transformItems(items);\n this._renderGrid(this._innerView);\n }\n }\n\n protected getVerticalCoord(point: Point, offset: number, inside: boolean): Point {\n return getVerticalCoord(point, this.getVerticalVector(offset, inside, point));\n }\n\n private _transformItems(items: AxisItem[]) {\n const data: TransformedAxisItem[] = [];\n items.forEach((item: AxisItem) => {\n data.push({\n ...item,\n point: this.getTickCoord(item.value),\n id: item.id ?? item.label\n });\n });\n return data;\n }\n private _renderGrid(container: any) {\n // 渲染 subGrid\n const { visible } = this.attribute.subGrid || {};\n if (visible) {\n this._renderGridByType(true, container);\n }\n\n // 渲染 Grid,Grid 需要在 subGrid 上层渲染\n this._renderGridByType(false, container);\n }\n\n private _renderGridByType(isSubGrid: boolean, container: IGroup) {\n const gridAttrs = merge({}, this.attribute, this.getGridAttribute(isSubGrid));\n\n const { type, items, style, closed, alternateColor, depth = 0 } = gridAttrs;\n const name = isSubGrid ? `${AXIS_ELEMENT_NAME.grid}-sub` : `${AXIS_ELEMENT_NAME.grid}`;\n\n // 绘制网格线\n items.forEach((item: GridItem, index: number) => {\n const { id, points } = item;\n let path = '';\n if (type === 'line' || type === 'polygon') {\n path = getLinePath(points, !!closed);\n } else if (type === 'circle') {\n const { center } = this.attribute as unknown as CircleGridAttributes;\n path = getArcPath(center, points, false, !!closed);\n }\n const shape = graphicCreator.path({\n path,\n z: depth,\n ...(isFunction(style)\n ? merge({}, this.skipDefault ? null : BaseGrid.defaultAttributes.style, style(item, index))\n : style)\n }) as Path;\n shape.name = `${name}-line`;\n shape.id = this._getNodeId(`${name}-path-${id}`);\n container.add(shape);\n });\n\n // 添加额外的3d线段\n if (depth && type === 'line') {\n items.forEach((item: GridItem, index: number) => {\n const { id, points } = item;\n // 重新计算points,使其长度为depth\n const nextPoints = [];\n nextPoints.push(points[0]);\n const dir = { x: points[1].x - points[0].x, y: points[1].y - points[0].y };\n const dirLen = Math.sqrt(dir.x * dir.x + dir.y * dir.y);\n const ratio = depth / dirLen;\n nextPoints.push({ x: points[0].x + dir.x * ratio, y: points[0].y + dir.y * ratio });\n const path = getLinePath(nextPoints, !!closed);\n const deltaX = abs(nextPoints[0].x - nextPoints[1].x);\n const deltaY = abs(nextPoints[0].y - nextPoints[1].y);\n const shape = graphicCreator.path({\n path,\n z: 0,\n alpha: deltaX > deltaY ? ((points[1].x - points[0].x > 0 ? -1 : 1) * pi) / 2 : 0,\n beta: deltaX < deltaY ? -pi / 2 : 0,\n anchor3d: deltaX > deltaY ? [nextPoints[0].x, 0] : [0, nextPoints[0].y],\n ...(isFunction(style)\n ? merge({}, this.skipDefault ? null : BaseGrid.defaultAttributes.style, style(item, index))\n : style)\n }) as Path;\n shape.name = `${name}-line`;\n shape.id = this._getNodeId(`${name}-path-${id}`);\n container.add(shape);\n });\n }\n\n // 绘制填充区域\n if (items.length > 1 && alternateColor) {\n const colors: string[] = isArray(alternateColor)\n ? (alternateColor as string[])\n : [alternateColor as string, 'transparent'];\n const getColor = (index: number) => colors[index % colors.length];\n\n // const regions: any[] = [];\n for (let index = 0; index < items.length - 1; index++) {\n const [prev, curr] = [items[index].points, items[index + 1].points];\n const path = getRegionPath(prev, curr, gridAttrs);\n const shape = graphicCreator.path({\n path,\n fill: getColor(index)\n }) as Path;\n shape.name = `${name}-region`;\n shape.id = this._getNodeId(`${name}-region-${index}`);\n container.add(shape);\n }\n }\n }\n\n /**\n * @override 覆写\n * @param id\n * @returns\n */\n protected _getNodeId(id: string) {\n return `${this.id}-${id}`;\n }\n\n release(): void {\n super.release();\n this._prevInnerView = null;\n this._innerView = null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/axis/grid/base.ts"],"names":[],"mappings":";;;AAGA,6CAAqF;AAErF,yDAAwD;AACxD,0CAAoD;AAIpD,0CAAgD;AAChD,kCAAqD;AAErD,SAAS,WAAW,CAAC,MAAe,EAAE,MAAe;IACnD,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,OAAO,IAAI,CAAC;KACb;IACD,MAAM,CAA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;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;;AAjNH,4BAkNC;AA/MQ,0BAAiB,GAAgC;IACtD,KAAK,EAAE;QACL,SAAS,EAAE,CAAC;QACZ,MAAM,EAAE,MAAM;QACd,aAAa,EAAE,CAAC;QAChB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KACjB;IACD,OAAO,EAAE;QACP,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,MAAM;YACd,aAAa,EAAE,CAAC;YAChB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACjB;KACF;CACF,CAAC","file":"base.js","sourcesContent":["/**\n * @description 网格线\n */\nimport { isFunction, isArray, merge, PointService, abs, pi } from '@visactor/vutils';\nimport type { IGraphic, IGroup, Path } from '@visactor/vrender-core';\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../../core/base';\nimport type { Point } from '../../core/type';\nimport type { GridItem, CircleGridAttributes, GridBaseAttributes, GridAttributes, LineGridAttributes } from './type';\nimport type { AxisItem, TransformedAxisItem } from '../type';\nimport { AXIS_ELEMENT_NAME } from '../constant';\nimport { getElMap, getVerticalCoord } from '../util';\n\nfunction getLinePath(points: Point[], closed: boolean) {\n let path = '';\n if (points.length === 0) {\n return path;\n }\n points.forEach((point, index) => {\n if (index === 0) {\n path = `M${point.x},${point.y}`;\n } else {\n path += `L${point.x},${point.y}`;\n }\n });\n if (closed) {\n path += 'Z';\n }\n\n return path;\n}\n\nfunction getArcPath(center: Point, points: Point[], reverse: boolean, closed: boolean) {\n let path = '';\n if (!center || points.length === 0) {\n return path;\n }\n const firstPoint = points[0];\n const radius = PointService.distancePP(center, firstPoint);\n const sweepFlag = reverse ? 0 : 1; // 顺时针还是逆时针\n if (closed) {\n // 封闭时,绘制整个圆\n path += `M${center.x},${center.y - radius}A${radius},${radius},0,0,${sweepFlag},${center.x},${\n center.y + radius\n }A${radius},${radius},0,0,${sweepFlag},${center.x},${center.y - radius}Z`;\n } else {\n points.forEach((point, index) => {\n if (index === 0) {\n path = `M${point.x},${point.y}`;\n } else {\n path += `A${radius},${radius},0,0,${sweepFlag},${point.x},${point.y}`;\n }\n });\n }\n\n return path;\n}\n\nfunction getRegionPath(from: Point[], to: Point[], attribute: GridAttributes) {\n const { type, closed } = attribute;\n const reversePoints = to.slice(0).reverse();\n\n let regionPath = '';\n let nextPath = '';\n\n if (type === 'line' && (attribute as LineGridAttributes).smoothLink && (attribute as LineGridAttributes).center) {\n const fromStart = from[0];\n const toEnd = reversePoints[0];\n const center = (attribute as LineGridAttributes).center as Point;\n\n regionPath = getLinePath(from, !!closed);\n nextPath = getLinePath(reversePoints, !!closed);\n const toEndRadius = PointService.distancePP(toEnd, center);\n const fromStartRadius = PointService.distancePP(fromStart, center);\n regionPath += `A${toEndRadius},${toEndRadius},0,0,1,${toEnd.x},${toEnd.y}L${toEnd.x},${toEnd.y}`;\n nextPath += `A${fromStartRadius},${fromStartRadius},0,0,0,${fromStart.x},${fromStart.y}`;\n } else if (type === 'circle') {\n const { center } = attribute as CircleGridAttributes;\n regionPath = getArcPath(center, from, false, !!closed);\n nextPath = getArcPath(center, reversePoints, true, !!closed);\n } else if (type === 'line' || type === 'polygon') {\n regionPath = getLinePath(from, !!closed);\n nextPath = getLinePath(reversePoints, !!closed);\n }\n\n if (closed) {\n regionPath += nextPath;\n } else {\n nextPath = 'L' + nextPath.substring(1); // 更新第一个节点\n regionPath += nextPath;\n regionPath += 'Z';\n }\n return regionPath;\n}\n\nexport abstract class BaseGrid<T extends GridBaseAttributes> extends AbstractComponent<Required<T>> {\n name = 'axis-grid';\n\n static defaultAttributes: Partial<GridBaseAttributes> = {\n style: {\n lineWidth: 1,\n stroke: '#999',\n strokeOpacity: 1,\n lineDash: [4, 4]\n },\n subGrid: {\n visible: false,\n style: {\n lineWidth: 1,\n stroke: '#999',\n strokeOpacity: 1,\n lineDash: [4, 4]\n }\n }\n };\n\n protected _innerView: IGroup;\n getInnerView() {\n return this._innerView;\n }\n\n protected _prevInnerView: { [key: string]: IGraphic }; // 缓存旧场景树,用于自定义动画\n /**\n * 获取更新前的旧场景树\n * @returns 返回更新前的旧场景树\n */\n getPrevInnerView() {\n return this._prevInnerView;\n }\n\n // 经过处理后的坐标轴点数据\n protected data: TransformedAxisItem[] = [];\n abstract getTickCoord(value: number): Point;\n abstract isInValidValue(value: number): boolean;\n abstract getVerticalVector(offset: number, inside: boolean, point: Point): [number, number];\n protected abstract getGridAttribute(isSubGrid: boolean): T;\n\n protected render(): void {\n this._prevInnerView = this._innerView && getElMap(this._innerView);\n\n this.removeAllChild(true);\n this._innerView = graphicCreator.group({ x: 0, y: 0, pickable: false });\n this.add(this._innerView);\n\n const { items, visible } = this.attribute;\n if (items && items.length && visible !== false) {\n this.data = this._transformItems(items);\n this._renderGrid(this._innerView);\n }\n }\n\n protected getVerticalCoord(point: Point, offset: number, inside: boolean): Point {\n return getVerticalCoord(point, this.getVerticalVector(offset, inside, point));\n }\n\n private _transformItems(items: AxisItem[]) {\n const data: TransformedAxisItem[] = [];\n items.forEach((item: AxisItem) => {\n data.push({\n ...item,\n point: this.getTickCoord(item.value),\n id: item.id ?? item.label\n });\n });\n return data;\n }\n private _renderGrid(container: any) {\n // 渲染 subGrid\n const { visible } = this.attribute.subGrid || {};\n if (visible) {\n this._renderGridByType(true, container);\n }\n\n // 渲染 Grid,Grid 需要在 subGrid 上层渲染\n this._renderGridByType(false, container);\n }\n\n private _renderGridByType(isSubGrid: boolean, container: IGroup) {\n const gridAttrs = merge({}, this.attribute, this.getGridAttribute(isSubGrid));\n\n const { type, items, style, closed, alternateColor, depth = 0 } = gridAttrs;\n const name = isSubGrid ? `${AXIS_ELEMENT_NAME.grid}-sub` : `${AXIS_ELEMENT_NAME.grid}`;\n\n // 绘制网格线\n items.forEach((item: GridItem, index: number) => {\n const { id, points } = item;\n let path = '';\n if (type === 'line' || type === 'polygon') {\n path = getLinePath(points, !!closed);\n } else if (type === 'circle') {\n const { center } = this.attribute as unknown as CircleGridAttributes;\n path = getArcPath(center, points, false, !!closed);\n }\n const shape = graphicCreator.path({\n path,\n z: depth,\n ...(isFunction(style)\n ? merge({}, this.skipDefault ? null : BaseGrid.defaultAttributes.style, style(item, index))\n : style)\n }) as Path;\n shape.name = `${name}-line`;\n shape.id = this._getNodeId(`${name}-path-${id}`);\n container.add(shape);\n });\n\n // 添加额外的3d线段\n if (depth && type === 'line') {\n items.forEach((item: GridItem, index: number) => {\n const { id, points } = item;\n // 重新计算points,使其长度为depth\n const nextPoints = [];\n nextPoints.push(points[0]);\n const dir = { x: points[1].x - points[0].x, y: points[1].y - points[0].y };\n const dirLen = Math.sqrt(dir.x * dir.x + dir.y * dir.y);\n const ratio = depth / dirLen;\n nextPoints.push({ x: points[0].x + dir.x * ratio, y: points[0].y + dir.y * ratio });\n const path = getLinePath(nextPoints, !!closed);\n const deltaX = abs(nextPoints[0].x - nextPoints[1].x);\n const deltaY = abs(nextPoints[0].y - nextPoints[1].y);\n const shape = graphicCreator.path({\n path,\n z: 0,\n alpha: deltaX > deltaY ? ((points[1].x - points[0].x > 0 ? -1 : 1) * pi) / 2 : 0,\n beta: deltaX < deltaY ? -pi / 2 : 0,\n anchor3d: deltaX > deltaY ? [nextPoints[0].x, 0] : [0, nextPoints[0].y],\n ...(isFunction(style)\n ? merge({}, this.skipDefault ? null : BaseGrid.defaultAttributes.style, style(item, index))\n : style)\n }) as Path;\n shape.name = `${name}-line`;\n shape.id = this._getNodeId(`${name}-path-${id}`);\n container.add(shape);\n });\n }\n\n // 绘制填充区域\n if (items.length > 1 && alternateColor) {\n const colors: string[] = isArray(alternateColor)\n ? (alternateColor as string[])\n : [alternateColor as string, 'transparent'];\n const getColor = (index: number) => colors[index % colors.length];\n\n // const regions: any[] = [];\n for (let index = 0; index < items.length - 1; index++) {\n const [prev, curr] = [items[index].points, items[index + 1].points];\n const path = getRegionPath(prev, curr, gridAttrs);\n const shape = graphicCreator.path({\n path,\n fill: getColor(index)\n }) as Path;\n shape.name = `${name}-region`;\n shape.id = this._getNodeId(`${name}-region-${index}`);\n container.add(shape);\n }\n }\n }\n\n /**\n * @override 覆写\n * @param id\n * @returns\n */\n protected _getNodeId(id: string) {\n return `${this.id}-${id}`;\n }\n\n protected _parseTickSegment() {\n let tickSegment = 1;\n const count = this.data.length;\n if (count >= 2) {\n tickSegment = this.data[1].value - this.data[0].value;\n }\n\n return tickSegment;\n }\n\n protected _getPointsOfSubGrid(tickSegment: number, alignWithLabel: boolean) {\n const tickLineCount = this.data.length;\n // 刻度线的数量大于 2 时,才绘制子刻度\n const points: { value: number }[] = [];\n if (tickLineCount >= 2) {\n this.data.forEach((item: TransformedAxisItem) => {\n let tickValue = item.value;\n if (!alignWithLabel) {\n // tickLine 不同 tick 对齐时需要调整 point\n const value = item.value - tickSegment / 2;\n if (this.isInValidValue(value)) {\n return;\n }\n tickValue = value;\n }\n points.push({\n value: tickValue\n });\n });\n }\n\n return points;\n }\n\n release(): void {\n super.release();\n this._prevInnerView = null;\n this._innerView = null;\n }\n}\n"]}
|
package/cjs/axis/grid/circle.js
CHANGED
|
@@ -24,25 +24,12 @@ class CircleAxisGrid extends base_1.BaseGrid {
|
|
|
24
24
|
}
|
|
25
25
|
getGridAttribute(isSubGrid) {
|
|
26
26
|
let gridAttribute, items = [];
|
|
27
|
-
const _a = this.attribute, {radius: radius, innerRadius: innerRadius = 0, startAngle: startAngle = constant_1.POLAR_START_ANGLE, endAngle: endAngle = constant_1.POLAR_END_ANGLE, center: center, subGrid: subGrid} = _a, grid = __rest(_a, [ "radius", "innerRadius", "startAngle", "endAngle", "center", "subGrid" ]), {alignWithLabel: alignWithLabel = !0} = grid || {}, length = radius - innerRadius;
|
|
28
|
-
|
|
29
|
-
if (this.data.length >= 2 && (tickSegment = this.data[1].value - this.data[0].value),
|
|
30
|
-
isSubGrid) {
|
|
27
|
+
const _a = this.attribute, {radius: radius, innerRadius: innerRadius = 0, startAngle: startAngle = constant_1.POLAR_START_ANGLE, endAngle: endAngle = constant_1.POLAR_END_ANGLE, center: center, subGrid: subGrid} = _a, grid = __rest(_a, [ "radius", "innerRadius", "startAngle", "endAngle", "center", "subGrid" ]), {alignWithLabel: alignWithLabel = !0} = grid || {}, length = radius - innerRadius, tickSegment = this._parseTickSegment();
|
|
28
|
+
if (isSubGrid) {
|
|
31
29
|
gridAttribute = (0, vutils_1.merge)({}, grid, subGrid);
|
|
32
30
|
const subGridItems = [], {count: subCount = 4} = subGrid || {}, tickLineCount = this.data.length;
|
|
33
31
|
if (tickLineCount >= 2) {
|
|
34
|
-
const points =
|
|
35
|
-
this.data.forEach((item => {
|
|
36
|
-
let tickValue = item.value;
|
|
37
|
-
if (!alignWithLabel) {
|
|
38
|
-
const value = item.value - tickSegment / 2;
|
|
39
|
-
if (this.isInValidValue(value)) return;
|
|
40
|
-
tickValue = value;
|
|
41
|
-
}
|
|
42
|
-
points.push({
|
|
43
|
-
value: tickValue
|
|
44
|
-
});
|
|
45
|
-
}));
|
|
32
|
+
const points = this._getPointsOfSubGrid(tickSegment, alignWithLabel);
|
|
46
33
|
for (let i = 0; i < tickLineCount; i++) {
|
|
47
34
|
const pre = points[i], next = points[i + 1];
|
|
48
35
|
subGridItems.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/axis/grid/circle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,6CAAgD;AAChD,iCAAkC;AAElC,6CAAoE;
|
|
1
|
+
{"version":3,"sources":["../src/axis/grid/circle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,6CAAgD;AAChD,iCAAkC;AAElC,6CAAoE;AACpE,4CAAkD;AAElD,0CAA0D;AAM1D,IAAA,sCAA2B,GAAE,CAAC;AAC9B,MAAa,cAAe,SAAQ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AC,CAAC,CAAC,CAAC,CAAC;iBACpC;gBAED,KAAK,GAAG,YAAY,CAAC;aACtB;SACF;QACD,uCACK,aAAa,KAChB,KAAK;YACL,MAAM,EACN,IAAI,EAAE,MAAM,IACZ;IACJ,CAAC;CACF;AAlGD,wCAkGC;AAED,IAAA,cAAK,EAAC,cAAc,EAAE,wBAAe,CAAC,CAAC","file":"circle.js","sourcesContent":["/**\n * @description 圆弧型坐标轴的网格线\n */\n\nimport { merge, mixin } from '@visactor/vutils';\nimport { BaseGrid } from './base';\nimport type { CircleAxisGridAttributes, GridItem } from './type';\nimport { POLAR_END_ANGLE, POLAR_START_ANGLE } from '../../constant';\nimport { CircleAxisMixin } from '../mixin/circle';\nimport type { ComponentOptions } from '../../interface';\nimport { loadCircleAxisGridComponent } from '../register';\n\nexport interface CircleAxisGrid\n extends Pick<CircleAxisMixin, 'isInValidValue' | 'getTickCoord' | 'getVerticalVector'>,\n BaseGrid<CircleAxisGridAttributes> {}\n\nloadCircleAxisGridComponent();\nexport class CircleAxisGrid extends BaseGrid<CircleAxisGridAttributes> {\n constructor(attributes: CircleAxisGridAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, BaseGrid.defaultAttributes, attributes), options);\n }\n\n protected getGridAttribute(isSubGrid: boolean) {\n let gridAttribute;\n let items: GridItem[] = [];\n const {\n radius,\n innerRadius = 0,\n startAngle = POLAR_START_ANGLE,\n endAngle = POLAR_END_ANGLE,\n center,\n subGrid,\n ...grid\n } = this.attribute;\n const { alignWithLabel = true } = grid || {};\n\n const length = radius - innerRadius;\n const tickSegment = this._parseTickSegment();\n if (!isSubGrid) {\n gridAttribute = grid as CircleAxisGridAttributes;\n // 计算 grid Items\n const gridItems: GridItem[] = [];\n let data;\n if (Math.abs(endAngle - startAngle) % (Math.PI * 2) === 0) {\n data = [...this.data].concat(this.data[0]);\n } else {\n data = this.data;\n }\n\n data.forEach(item => {\n let { point } = item;\n if (!alignWithLabel) {\n // tickLine 不同 tick 对齐时需要调整 point\n const value = item.value - tickSegment / 2;\n if (this.isInValidValue(value)) {\n return;\n }\n point = this.getTickCoord(value);\n }\n const endPoint = this.getVerticalCoord(point, length as number, true);\n gridItems.push({\n id: item.id,\n points: [point, endPoint],\n datum: item\n });\n });\n items = gridItems;\n } else {\n // 渲染 subGrid\n gridAttribute = merge({}, grid, subGrid);\n // 计算 grid Items\n const subGridItems: GridItem[] = [];\n const { count: subCount = 4 } = subGrid || {};\n const tickLineCount = this.data.length;\n // 刻度线的数量大于 2 时,才绘制子刻度\n if (tickLineCount >= 2) {\n const points = this._getPointsOfSubGrid(tickSegment, alignWithLabel);\n\n for (let i = 0; i < tickLineCount; i++) {\n const pre = points[i];\n const next = points[i + 1];\n subGridItems.push({\n id: `sub-${i}-${0}`,\n points: [this.getTickCoord(pre.value), this.getVerticalCoord(this.getTickCoord(pre.value), length, true)],\n datum: {}\n });\n for (let j = 0; j < subCount; j++) {\n const percent = (j + 1) / (subCount + 1);\n const value =\n (1 - percent) * pre.value + percent * (next ? next.value : alignWithLabel ? 1 : pre.value + tickSegment);\n const point = this.getTickCoord(value);\n const endPoint = this.getVerticalCoord(point, length, true);\n subGridItems.push({\n id: `sub-${i}-${j + 1}`,\n points: [point, endPoint],\n // TODO: 这里也需要,后续考虑如何加上\n datum: {}\n });\n }\n }\n\n if (Math.abs(endAngle - startAngle) % (Math.PI * 2) === 0) {\n subGridItems.push(subGridItems[0]);\n }\n\n items = subGridItems;\n }\n }\n return {\n ...gridAttribute,\n items,\n center,\n type: 'line'\n };\n }\n}\n\nmixin(CircleAxisGrid, CircleAxisMixin);\n"]}
|
package/cjs/axis/grid/line.js
CHANGED
|
@@ -33,27 +33,13 @@ class LineAxisGrid extends base_1.BaseGrid {
|
|
|
33
33
|
return gridPoints;
|
|
34
34
|
}
|
|
35
35
|
getGridAttribute(isSubGrid) {
|
|
36
|
-
const {type: gridType, alignWithLabel: alignWithLabel = !0} = this.attribute;
|
|
37
|
-
let
|
|
38
|
-
let gridAttribute;
|
|
39
|
-
this.data.length >= 2 && (tickSegment = this.data[1].value - this.data[0].value);
|
|
40
|
-
let items = [];
|
|
36
|
+
const {type: gridType, alignWithLabel: alignWithLabel = !0} = this.attribute, tickSegment = this._parseTickSegment();
|
|
37
|
+
let gridAttribute, items = [];
|
|
41
38
|
if (isSubGrid) {
|
|
42
39
|
gridAttribute = (0, vutils_1.merge)({}, this.attribute, this.attribute.subGrid);
|
|
43
40
|
const subGridItems = [], {count: subCount = 4} = this.attribute.subGrid || {};
|
|
44
41
|
if (this.data.length >= 2) {
|
|
45
|
-
const points =
|
|
46
|
-
this.data.forEach((item => {
|
|
47
|
-
let tickValue = item.value;
|
|
48
|
-
if (!alignWithLabel) {
|
|
49
|
-
const value = item.value - tickSegment / 2;
|
|
50
|
-
if (this.isInValidValue(value)) return;
|
|
51
|
-
tickValue = value;
|
|
52
|
-
}
|
|
53
|
-
points.push({
|
|
54
|
-
value: tickValue
|
|
55
|
-
});
|
|
56
|
-
}));
|
|
42
|
+
const points = this._getPointsOfSubGrid(tickSegment, alignWithLabel);
|
|
57
43
|
for (let i = 0; i < points.length - 1; i++) {
|
|
58
44
|
const pre = points[i], next = points[i + 1];
|
|
59
45
|
subGridItems.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/axis/grid/line.ts"],"names":[],"mappings":";;;AAMA,6CAAgF;AAChF,iCAAkC;AAQlC,6CAAoE;
|
|
1
|
+
{"version":3,"sources":["../src/axis/grid/line.ts"],"names":[],"mappings":";;;AAMA,6CAAgF;AAChF,iCAAkC;AAQlC,6CAAoE;AACpE,wCAA8C;AAE9C,0CAAwD;AAExD,SAAS,eAAe,CAAC,MAAa,EAAE,KAAa,EAAE,MAAc,EAAE,UAAkB,EAAE,QAAgB;IACzG,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,MAAM,KAAK,GAAG,QAAQ,GAAG,UAAU,CAAC;IACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CA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,KAAK,CAAC;4BAE3C,KAAK,EAAE,EAAE;yBACV,CAAC,CAAC;qBACJ;oBACD,IAAI,CAAC,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;wBAC3B,YAAY,CAAC,IAAI,CAAC;4BAChB,EAAE,EAAE,OAAO,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE;4BAC9B,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;4BAEnE,KAAK,EAAE,EAAE;yBACV,CAAC,CAAC;qBACJ;iBACF;gBACD,KAAK,GAAG,YAAY,CAAC;aACtB;SACF;QAED,uCACK,aAAa,KAChB,KAAK,IACL;IACJ,CAAC;CACF;AAzGD,oCAyGC;AAED,IAAA,cAAK,EAAC,YAAY,EAAE,oBAAa,CAAC,CAAC","file":"line.js","sourcesContent":["/**\n * @description 直线型坐标轴的网格线\n * - `type: 'line'` 用于直角坐标系下的坐标轴网格线绘制\n * - `type: 'circle'` 或者 `type: 'polygon'` 用于极坐标半径轴的网格线绘制\n */\nimport type { IPointLike } from '@visactor/vutils';\nimport { PointService, merge, polarToCartesian, mixin } from '@visactor/vutils';\nimport { BaseGrid } from './base';\nimport type {\n GridItem,\n LineAxisGridAttributes,\n LineGridOfLineAxisAttributes,\n PolarGridOfLineAxisAttributes\n} from './type';\nimport type { Point } from '../../core/type';\nimport { POLAR_START_ANGLE, POLAR_END_ANGLE } from '../../constant';\nimport { LineAxisMixin } from '../mixin/line';\nimport type { ComponentOptions } from '../../interface';\nimport { loadLineAxisGridComponent } from '../register';\n\nfunction getCirclePoints(center: Point, count: number, radius: number, startAngle: number, endAngle: number) {\n const points: Point[] = [];\n const range = endAngle - startAngle;\n for (let i = 0; i < count; i++) {\n const angle = startAngle + (i * range) / count;\n points.push(polarToCartesian(center, radius, angle));\n }\n return points;\n}\n\nexport interface LineAxisGrid\n extends Pick<LineAxisMixin, 'isInValidValue' | 'getTickCoord' | 'getVerticalVector'>,\n BaseGrid<LineAxisGridAttributes> {}\n\nloadLineAxisGridComponent();\nexport class LineAxisGrid extends BaseGrid<LineAxisGridAttributes> {\n constructor(attributes: LineAxisGridAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, BaseGrid.defaultAttributes, attributes), options);\n }\n\n private _getGridPoint(gridType: string, point: IPointLike): Point[] {\n let gridPoints;\n if (gridType === 'line') {\n const { length } = this.attribute as LineGridOfLineAxisAttributes;\n const endPoint = this.getVerticalCoord(point, length as number, true);\n\n gridPoints = [point, endPoint];\n } else if (gridType === 'circle' || gridType === 'polygon') {\n const {\n center,\n sides = 6,\n startAngle = POLAR_START_ANGLE,\n endAngle = POLAR_END_ANGLE\n } = this.attribute as PolarGridOfLineAxisAttributes;\n const distance = PointService.distancePP(center as Point, point);\n gridPoints = getCirclePoints(center as Point, sides as number, distance, startAngle, endAngle);\n }\n\n return gridPoints;\n }\n\n protected getGridAttribute(isSubGrid: boolean) {\n const { type: gridType, alignWithLabel = true } = this.attribute;\n\n const tickSegment = this._parseTickSegment();\n\n let gridAttribute;\n let items: GridItem[] = [];\n if (!isSubGrid) {\n gridAttribute = this.attribute;\n // 计算 grid Items\n const gridItems: GridItem[] = [];\n this.data.forEach(item => {\n let { point } = item;\n\n if (!alignWithLabel) {\n // tickLine 不同 tick 对齐时需要调整 point\n const value = item.value - tickSegment / 2;\n if (this.isInValidValue(value)) {\n return;\n }\n point = this.getTickCoord(value);\n }\n\n gridItems.push({\n id: item.label,\n datum: item,\n points: this._getGridPoint(gridType, point)\n });\n });\n items = gridItems;\n } else {\n // 渲染 subGrid\n gridAttribute = merge({}, this.attribute, this.attribute.subGrid);\n // 计算 grid Items\n const subGridItems: GridItem[] = [];\n const { count: subCount = 4 } = this.attribute.subGrid || {};\n const tickLineCount = this.data.length;\n // 刻度线的数量大于 2 时,才绘制子刻度\n if (tickLineCount >= 2) {\n const points = this._getPointsOfSubGrid(tickSegment, alignWithLabel);\n\n for (let i = 0; i < points.length - 1; i++) {\n const pre = points[i];\n const next = points[i + 1];\n subGridItems.push({\n id: `sub-${i}-0`,\n points: this._getGridPoint(gridType, this.getTickCoord(pre.value)),\n // TODO: 其实这里也需要,后续需要考虑怎么挂上 data\n datum: {}\n });\n for (let j = 0; j < subCount; j++) {\n const percent = (j + 1) / (subCount + 1);\n const value = (1 - percent) * pre.value + percent * next.value;\n const point = this.getTickCoord(value);\n subGridItems.push({\n id: `sub-${i}-${j + 1}`,\n points: this._getGridPoint(gridType, point),\n // TODO: 其实这里也需要,后续需要考虑怎么挂上 data\n datum: {}\n });\n }\n if (i === points.length - 2) {\n subGridItems.push({\n id: `sub-${i}-${subCount + 1}`,\n points: this._getGridPoint(gridType, this.getTickCoord(next.value)),\n // TODO: 其实这里也需要,后续需要考虑怎么挂上 data\n datum: {}\n });\n }\n }\n items = subGridItems;\n }\n }\n\n return {\n ...gridAttribute,\n items\n };\n }\n}\n\nmixin(LineAxisGrid, LineAxisMixin);\n"]}
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const version = "0.20.0-alpha.
|
|
1
|
+
export declare const version = "0.20.0-alpha.2";
|
|
2
2
|
export * from './core/base';
|
|
3
3
|
export * from './core/type';
|
|
4
4
|
export * from './scrollbar';
|
|
@@ -20,6 +20,7 @@ export * from './link-path';
|
|
|
20
20
|
export * from './player';
|
|
21
21
|
export * from './brush';
|
|
22
22
|
export * from './tooltip';
|
|
23
|
+
export * from './timeline';
|
|
23
24
|
export * from './interface';
|
|
24
25
|
export * from './jsx';
|
|
25
26
|
export * from './checkbox';
|
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.20.0-alpha.
|
|
20
|
+
}), exports.version = void 0, exports.version = "0.20.0-alpha.2", __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),
|
|
@@ -28,7 +28,8 @@ __exportStar(require("./legend"), exports), __exportStar(require("./title"), exp
|
|
|
28
28
|
__exportStar(require("./indicator"), exports), __exportStar(require("./slider"), exports),
|
|
29
29
|
__exportStar(require("./link-path"), exports), __exportStar(require("./player"), exports),
|
|
30
30
|
__exportStar(require("./brush"), exports), __exportStar(require("./tooltip"), exports),
|
|
31
|
-
__exportStar(require("./
|
|
32
|
-
__exportStar(require("./
|
|
33
|
-
__exportStar(require("./
|
|
31
|
+
__exportStar(require("./timeline"), exports), __exportStar(require("./interface"), exports),
|
|
32
|
+
__exportStar(require("./jsx"), exports), __exportStar(require("./checkbox"), exports),
|
|
33
|
+
__exportStar(require("./radio"), exports), __exportStar(require("./empty-tip"), exports),
|
|
34
|
+
__exportStar(require("./util"), exports);
|
|
34
35
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,0CAAwB;AACxB,8CAA4B;AAC5B,yCAAuB","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.20.0-alpha.
|
|
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,6CAA2B;AAC3B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,0CAAwB;AACxB,8CAA4B;AAC5B,yCAAuB","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.20.0-alpha.2\";\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 './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './util';\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { IGroup, IRichText, IText } from '@visactor/vrender-core';
|
|
1
2
|
import { AbstractComponent } from '../core/base';
|
|
2
|
-
import type { IndicatorAttributes } from './type';
|
|
3
|
+
import type { IndicatorAttributes, IndicatorItemSpec } from './type';
|
|
3
4
|
export declare class Indicator extends AbstractComponent<Required<IndicatorAttributes>> {
|
|
4
5
|
name: string;
|
|
5
6
|
private _title?;
|
|
6
7
|
private _content?;
|
|
8
|
+
protected _renderText(group: IGroup, title: IndicatorItemSpec, limit: number, limitRatio: number, themePath: string, graphicName: string): IRichText | IText;
|
|
7
9
|
protected render(): void;
|
|
8
10
|
private _setLocalAutoFit;
|
|
9
11
|
private _setGlobalAutoFit;
|
|
@@ -12,55 +12,33 @@ class Indicator extends base_1.AbstractComponent {
|
|
|
12
12
|
constructor() {
|
|
13
13
|
super(...arguments), this.name = "indicator";
|
|
14
14
|
}
|
|
15
|
+
_renderText(group, title, limit, limitRatio, themePath, graphicName) {
|
|
16
|
+
if (!1 !== title.visible) {
|
|
17
|
+
const titleStyle = (0, vutils_1.merge)({}, (0, vutils_1.get)(config_1.DEFAULT_INDICATOR_THEME, themePath), title.style, {
|
|
18
|
+
visible: title.visible
|
|
19
|
+
});
|
|
20
|
+
titleStyle.lineHeight = (0, vutils_1.isValid)(titleStyle.lineHeight) ? titleStyle.lineHeight : titleStyle.fontSize,
|
|
21
|
+
title.formatMethod && (titleStyle._originText = titleStyle.text, titleStyle.text = title.formatMethod(titleStyle.text, titleStyle));
|
|
22
|
+
const textGraphic = (0, util_1.createTextGraphicByType)(titleStyle);
|
|
23
|
+
return textGraphic.name = graphicName, group.appendChild(textGraphic), title.autoFit && (0,
|
|
24
|
+
vutils_1.isValidNumber)(limit) && this._setLocalAutoFit(limit, textGraphic, title),
|
|
25
|
+
title.autoLimit && (0, vutils_1.isValidNumber)(limitRatio) && textGraphic.setAttribute("maxLineWidth", limit),
|
|
26
|
+
textGraphic;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
15
29
|
render() {
|
|
16
30
|
var _a;
|
|
17
|
-
|
|
31
|
+
if (this.removeAllChild(!0), !0 !== this.attribute.visible) return;
|
|
32
|
+
const {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", {
|
|
18
33
|
x: 0,
|
|
19
34
|
y: 0,
|
|
20
35
|
zIndex: 1
|
|
21
36
|
}, "group");
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
const titleStyle = (0, vutils_1.merge)({}, (0, vutils_1.get)(config_1.DEFAULT_INDICATOR_THEME, "title.style"), title.style);
|
|
25
|
-
(0, util_1.isRichText)(titleStyle) ? this._title = group.createOrUpdateChild("indicator-title", Object.assign(Object.assign({}, (0,
|
|
26
|
-
util_1.richTextAttributeTransform)(titleStyle)), {
|
|
27
|
-
visible: title.visible,
|
|
28
|
-
x: 0,
|
|
29
|
-
y: 0
|
|
30
|
-
}), "richtext") : this._title = group.createOrUpdateChild("indicator-title", Object.assign(Object.assign({}, titleStyle), {
|
|
31
|
-
lineHeight: (0, vutils_1.isValid)(titleStyle.lineHeight) ? titleStyle.lineHeight : titleStyle.fontSize,
|
|
32
|
-
visible: title.visible,
|
|
33
|
-
x: 0,
|
|
34
|
-
y: 0
|
|
35
|
-
}), "text"), title.autoFit && (0, vutils_1.isValidNumber)(limit) && this._setLocalAutoFit(limit, this._title, title),
|
|
36
|
-
title.autoLimit && (0, vutils_1.isValidNumber)(limitRatio) && this._title.setAttribute("maxLineWidth", limit);
|
|
37
|
-
} else {
|
|
38
|
-
const titleNode = group.find((node => "indicator-title" === node.name), !1);
|
|
39
|
-
titleNode && group.removeChild(titleNode), this._title = void 0;
|
|
40
|
-
}
|
|
41
|
-
if ((0, vutils_1.isValid)(content)) {
|
|
37
|
+
if ((0, vutils_1.isValid)(title) && (this._title = this._renderText(group, title, limit, limitRatio, "title.style", "indicator-title")),
|
|
38
|
+
(0, vutils_1.isValid)(content)) {
|
|
42
39
|
const contents = (0, vutils_1.array)(content), contentComponents = [];
|
|
43
40
|
contents.forEach(((contentItem, i) => {
|
|
44
|
-
|
|
45
|
-
const contentStyle = (0, vutils_1.merge)({}, (0, vutils_1.get)(config_1.DEFAULT_INDICATOR_THEME, "content.style"), contentItem.style);
|
|
46
|
-
let contentComponent;
|
|
47
|
-
contentComponent = (0, util_1.isRichText)(contentStyle) ? group.createOrUpdateChild("indicator-content-" + i, Object.assign(Object.assign({}, (0,
|
|
48
|
-
util_1.richTextAttributeTransform)(contentStyle)), {
|
|
49
|
-
visible: title.visible,
|
|
50
|
-
x: 0,
|
|
51
|
-
y: 0
|
|
52
|
-
}), "richtext") : group.createOrUpdateChild("indicator-content-" + i, Object.assign(Object.assign({}, contentStyle), {
|
|
53
|
-
lineHeight: (0, vutils_1.isValid)(contentStyle.lineHeight) ? contentStyle.lineHeight : contentStyle.fontSize,
|
|
54
|
-
visible: contentItem.visible,
|
|
55
|
-
x: 0,
|
|
56
|
-
y: 0
|
|
57
|
-
}), "text"), contentItem.autoFit && (0, vutils_1.isValidNumber)(limit) && this._setLocalAutoFit(limit, contentComponent, contentItem),
|
|
58
|
-
contentItem.autoLimit && (0, vutils_1.isValidNumber)(limitRatio) && contentComponent.setAttribute("maxLineWidth", limit),
|
|
59
|
-
contentComponents.push(contentComponent);
|
|
60
|
-
} else {
|
|
61
|
-
const contentItemNode = group.find((node => node.name === "indicator-content-" + i), !1);
|
|
62
|
-
contentItemNode && group.removeChild(contentItemNode);
|
|
63
|
-
}
|
|
41
|
+
!1 !== contentItem.visible && contentComponents.push(this._renderText(group, contentItem, limit, limitRatio, "content.style", "indicator-content-" + i));
|
|
64
42
|
})), this._content = contentComponents;
|
|
65
43
|
}
|
|
66
44
|
this._setGlobalAutoFit(limit), this._setYPosition();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/indicator/indicator.ts"],"names":[],"mappings":";;;AAIA,6CAA6E;AAC7E,uCAAiD;AACjD,kCAAkF;AAElF,qCAAmD;AACnD,yCAAoD;AAEpD,IAAA,iCAAsB,GAAE,CAAC;AACzB,MAAa,SAAU,SAAQ,wBAAgD;IAA/E;;QACE,SAAI,GAAG,WAAW,CAAC;I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,WAAW,CAAC,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,UAAU,GAAG,iBAAiB,CAAC,CAAC;YAC5E,MAAM,YAAY,GAAG,MAAA,WAAW,CAAC,KAAK,mCAAI,CAAC,CAAC;YAC5C,iBAAiB,IAAI,WAAW,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,YAAY,CAAC;QACtE,CAAC,CAAC,CAAC;IACP,CAAC;CACF;AA7OD,8BA6OC","file":"indicator.js","sourcesContent":["/**\n * @description 指标卡组件\n */\nimport type { IGroup, INode, IText, ITextGraphicAttribute } from '@visactor/vrender-core';\nimport { merge, isValid, array, isValidNumber, get } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { isRichText, measureTextSize, richTextAttributeTransform } from '../util';\nimport type { IndicatorAttributes, IndicatorItemSpec } from './type';\nimport { DEFAULT_INDICATOR_THEME } from './config';\nimport { loadIndicatorComponent } from './register';\n\nloadIndicatorComponent();\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 (isRichText(titleStyle)) {\n this._title = group.createOrUpdateChild(\n 'indicator-title',\n {\n ...richTextAttributeTransform(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._setLocalAutoFit(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 if (isValid(content)) {\n const contents: IndicatorItemSpec[] = array(content);\n const contentComponents: IText[] = [];\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 (isRichText(contentStyle)) {\n contentComponent = group.createOrUpdateChild(\n 'indicator-content-' + i,\n {\n ...richTextAttributeTransform(contentStyle),\n visible: title.visible,\n x: 0,\n y: 0\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: 0\n },\n 'text'\n ) as IText;\n }\n\n // auto-fit\n if (contentItem.autoFit && isValidNumber(limit)) {\n this._setLocalAutoFit(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 } 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 this._setGlobalAutoFit(limit);\n this._setYPosition();\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 _setLocalAutoFit(limit: number, indicatorItem: IText, indicatorItemSpec: IndicatorItemSpec) {\n // only apply local auto fit for default auto fit text\n if ((indicatorItemSpec.fitStrategy ?? 'default') !== 'default') {\n return;\n }\n const originWidth = measureTextSize(\n (indicatorItemSpec.style?.text ?? '') as string | number | number[] | string[],\n (indicatorItemSpec.style ?? {}) as Partial<ITextGraphicAttribute>,\n this.stage?.getTheme()?.text\n ).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 private _setGlobalAutoFit(limit: number) {\n // compute the inscribed rect width & height for all texts\n // the font size will be determined by the longest text\n // 1. hx^2 + hy^2 = r^2\n // 2. hy = ra * hx + h\n // -> (ra^2 + 1) * x^2 + (2 * h * ra) * x + (h^2 - r^2) = 0\n\n const r = limit / 2;\n\n // unify the initial font size for auto fit texts\n const singleHeight = 12;\n const autoFitTexts: { text: IText; spec: IndicatorItemSpec }[] = [];\n // other text height\n let otherHeight = 0;\n // non auto fit title height\n const titleSpec = this.attribute.title ?? {};\n if (titleSpec.autoFit && titleSpec.fitStrategy === 'inscribed') {\n this._title.setAttribute('fontSize', singleHeight);\n autoFitTexts.push({ text: this._title, spec: this.attribute.title ?? {} });\n } else {\n otherHeight += this._title?.AABBBounds?.height?.() ?? 0;\n }\n const titleSpace = titleSpec.space ?? 0;\n otherHeight += titleSpace;\n // non auto fit content height\n array(this.attribute.content)\n .filter(contentSpec => contentSpec.visible !== false)\n .forEach((contentSpec, index) => {\n const contentText = this._content[index];\n if (contentSpec.autoFit && contentSpec.fitStrategy === 'inscribed') {\n contentText.setAttribute('fontSize', singleHeight);\n autoFitTexts.push({ text: contentText, spec: contentSpec });\n } else {\n otherHeight += contentText?.AABBBounds?.height?.() ?? 0;\n }\n const contentSpace = contentSpec.space ?? 0;\n otherHeight += contentSpace;\n });\n if (autoFitTexts.length <= 0) {\n return;\n }\n\n // max width for all auto fit texts\n const maxWidth = autoFitTexts.reduce((width, textItem) => {\n return Math.max(width, textItem.text.AABBBounds.width());\n }, 0);\n\n // y = x * (singleHeight / maxWidth * textCount) + otherHeight\n // hy = hx * (singleHeight / maxWidth * textCount) + otherHeight / 2\n const ra = (singleHeight / maxWidth) * autoFitTexts.length;\n const h = otherHeight / 2;\n const a = ra ** 2 + 1;\n const b = 2 * h * ra;\n const c = h ** 2 - r ** 2;\n const hx = (-b + Math.sqrt(b ** 2 - 4 * a * c)) / (2 * a);\n const hy = ra * hx + h;\n const y = 2 * hy;\n const lineHeight = (y - otherHeight) / autoFitTexts.length;\n if (isValidNumber(y)) {\n autoFitTexts.forEach(textItem => {\n const specLineHeight = textItem.spec.style?.lineHeight;\n textItem.text.setAttribute('fontSize', lineHeight);\n textItem.text.setAttribute('lineHeight', isValid(specLineHeight) ? specLineHeight : lineHeight);\n });\n }\n }\n\n private _setYPosition() {\n let lastContentHeight = 0;\n\n const titleHeight = this._title?.AABBBounds?.height?.() ?? 0;\n const titleSpace = this.attribute.title?.space ?? 0;\n array(this.attribute.content)\n .filter(contentSpec => contentSpec.visible !== false)\n .forEach((contentSpec, index) => {\n const contentText = this._content[index];\n contentText.setAttribute('y', titleHeight + titleSpace + lastContentHeight);\n const contentSpace = contentSpec.space ?? 0;\n lastContentHeight += contentText.AABBBounds.height() + contentSpace;\n });\n }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,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;aAC1B,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,KAAK,KAAK,CAAC;aACpD,OAAO,CAAC,CAAC,WAAW,EAAE,KAAK,EAAE,EAAE;;YAC9B,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACzC,WAAW,CAAC,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,UAAU,GAAG,iBAAiB,CAAC,CAAC;YAC5E,MAAM,YAAY,GAAG,MAAA,WAAW,CAAC,KAAK,mCAAI,CAAC,CAAC;YAC5C,iBAAiB,IAAI,WAAW,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,YAAY,CAAC;QACtE,CAAC,CAAC,CAAC;IACP,CAAC;CACF;AAxLD,8BAwLC","file":"indicator.js","sourcesContent":["/**\n * @description 指标卡组件\n */\nimport type { IGroup, IRichText, IText, ITextGraphicAttribute } from '@visactor/vrender-core';\nimport { merge, isValid, array, isValidNumber, get } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { createTextGraphicByType, measureTextSize } from '../util';\nimport type { IndicatorAttributes, IndicatorItemSpec } from './type';\nimport { DEFAULT_INDICATOR_THEME } from './config';\nimport { loadIndicatorComponent } from './register';\n\nloadIndicatorComponent();\nexport class Indicator extends AbstractComponent<Required<IndicatorAttributes>> {\n name = 'indicator';\n\n private _title?: IText | IRichText;\n private _content?: (IText | IRichText)[];\n\n protected _renderText(\n group: IGroup,\n title: IndicatorItemSpec,\n limit: number,\n limitRatio: number,\n themePath: string,\n graphicName: string\n ) {\n if (title.visible !== false) {\n const titleStyle = merge({}, get(DEFAULT_INDICATOR_THEME, themePath), title.style, {\n visible: title.visible\n });\n titleStyle.lineHeight = isValid(titleStyle.lineHeight) ? titleStyle.lineHeight : titleStyle.fontSize;\n\n if (title.formatMethod) {\n titleStyle._originText = titleStyle.text;\n titleStyle.text = title.formatMethod(titleStyle.text, titleStyle);\n }\n const textGraphic = createTextGraphicByType(titleStyle);\n textGraphic.name = graphicName;\n group.appendChild(textGraphic);\n\n // auto-fit\n if (title.autoFit && isValidNumber(limit)) {\n this._setLocalAutoFit(limit, textGraphic as IText, title);\n }\n\n //auto-limit\n if (title.autoLimit && isValidNumber(limitRatio)) {\n textGraphic.setAttribute('maxLineWidth', limit);\n }\n\n return textGraphic;\n }\n\n return undefined;\n }\n\n protected render() {\n this.removeAllChild(true);\n\n if (this.attribute.visible !== true) {\n return;\n }\n const { 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 if (isValid(title)) {\n this._title = this._renderText(group, title, limit, limitRatio, 'title.style', 'indicator-title');\n }\n\n if (isValid(content)) {\n const contents: IndicatorItemSpec[] = array(content);\n const contentComponents: (IText | IRichText)[] = [];\n contents.forEach((contentItem, i) => {\n if (contentItem.visible !== false) {\n contentComponents.push(\n this._renderText(group, contentItem, limit, limitRatio, 'content.style', 'indicator-content-' + i)\n );\n } else {\n }\n });\n this._content = contentComponents;\n }\n\n this._setGlobalAutoFit(limit);\n this._setYPosition();\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 _setLocalAutoFit(limit: number, indicatorItem: IText, indicatorItemSpec: IndicatorItemSpec) {\n // only apply local auto fit for default auto fit text\n if ((indicatorItemSpec.fitStrategy ?? 'default') !== 'default') {\n return;\n }\n const originWidth = measureTextSize(\n (indicatorItemSpec.style?.text ?? '') as string | number | number[] | string[],\n (indicatorItemSpec.style ?? {}) as Partial<ITextGraphicAttribute>,\n this.stage?.getTheme()?.text\n ).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 private _setGlobalAutoFit(limit: number) {\n // compute the inscribed rect width & height for all texts\n // the font size will be determined by the longest text\n // 1. hx^2 + hy^2 = r^2\n // 2. hy = ra * hx + h\n // -> (ra^2 + 1) * x^2 + (2 * h * ra) * x + (h^2 - r^2) = 0\n\n const r = limit / 2;\n\n // unify the initial font size for auto fit texts\n const singleHeight = 12;\n const autoFitTexts: { text: IText; spec: IndicatorItemSpec }[] = [];\n // other text height\n let otherHeight = 0;\n // non auto fit title height\n const titleSpec = this.attribute.title ?? {};\n if (titleSpec.autoFit && titleSpec.fitStrategy === 'inscribed') {\n this._title.setAttribute('fontSize', singleHeight);\n autoFitTexts.push({ text: this._title as IText, spec: this.attribute.title ?? {} });\n } else {\n otherHeight += this._title?.AABBBounds?.height?.() ?? 0;\n }\n const titleSpace = titleSpec.space ?? 0;\n otherHeight += titleSpace;\n // non auto fit content height\n array(this.attribute.content)\n .filter(contentSpec => contentSpec.visible !== false)\n .forEach((contentSpec, index) => {\n const contentText = this._content[index];\n if (contentSpec.autoFit && contentSpec.fitStrategy === 'inscribed') {\n contentText.setAttribute('fontSize', singleHeight);\n autoFitTexts.push({ text: contentText as IText, spec: contentSpec });\n } else {\n otherHeight += contentText?.AABBBounds?.height?.() ?? 0;\n }\n const contentSpace = contentSpec.space ?? 0;\n otherHeight += contentSpace;\n });\n if (autoFitTexts.length <= 0) {\n return;\n }\n\n // max width for all auto fit texts\n const maxWidth = autoFitTexts.reduce((width, textItem) => {\n return Math.max(width, textItem.text.AABBBounds.width());\n }, 0);\n\n // y = x * (singleHeight / maxWidth * textCount) + otherHeight\n // hy = hx * (singleHeight / maxWidth * textCount) + otherHeight / 2\n const ra = (singleHeight / maxWidth) * autoFitTexts.length;\n const h = otherHeight / 2;\n const a = ra ** 2 + 1;\n const b = 2 * h * ra;\n const c = h ** 2 - r ** 2;\n const hx = (-b + Math.sqrt(b ** 2 - 4 * a * c)) / (2 * a);\n const hy = ra * hx + h;\n const y = 2 * hy;\n const lineHeight = (y - otherHeight) / autoFitTexts.length;\n if (isValidNumber(y)) {\n autoFitTexts.forEach(textItem => {\n const specLineHeight = textItem.spec.style?.lineHeight;\n textItem.text.setAttribute('fontSize', lineHeight);\n textItem.text.setAttribute('lineHeight', isValid(specLineHeight) ? specLineHeight : lineHeight);\n });\n }\n }\n\n private _setYPosition() {\n let lastContentHeight = 0;\n\n const titleHeight = this._title?.AABBBounds?.height?.() ?? 0;\n const titleSpace = this.attribute.title?.space ?? 0;\n array(this.attribute.content)\n .filter(contentSpec => contentSpec.visible !== false)\n .forEach((contentSpec, index) => {\n const contentText = this._content[index];\n contentText.setAttribute('y', titleHeight + titleSpace + lastContentHeight);\n const contentSpace = contentSpec.space ?? 0;\n lastContentHeight += contentText.AABBBounds.height() + contentSpace;\n });\n }\n}\n"]}
|
package/cjs/indicator/type.d.ts
CHANGED
|
@@ -19,5 +19,6 @@ export interface IndicatorItemSpec {
|
|
|
19
19
|
autoFit?: boolean;
|
|
20
20
|
fitPercent?: number;
|
|
21
21
|
fitStrategy?: 'default' | 'inscribed';
|
|
22
|
+
formatMethod?: (text: string | number, textStyle: ITextGraphicAttribute) => TextContent;
|
|
22
23
|
style?: Omit<ITextGraphicAttribute, 'text'> & TextContent;
|
|
23
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/indicator/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { IGroupGraphicAttribute, ITextGraphicAttribute, IRichTextCharacter } from '@visactor/vrender-core';\nimport type { TextContent } from '../core/type';\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 * @default 'local'\n */\n fitStrategy?: 'default' | 'inscribed';\n /**\n * 文字样式\n */\n style?: Omit<ITextGraphicAttribute, 'text'> & TextContent;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/indicator/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { IGroupGraphicAttribute, ITextGraphicAttribute, IRichTextCharacter } from '@visactor/vrender-core';\nimport type { TextContent } from '../core/type';\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 * @default 'local'\n */\n fitStrategy?: 'default' | 'inscribed';\n /**\n * 格式化方法\n * @since 0.20.0\n * @param text 文本\n * @returns\n */\n formatMethod?: (text: string | number, textStyle: ITextGraphicAttribute) => TextContent;\n /**\n * 文字样式\n */\n style?: Omit<ITextGraphicAttribute, 'text'> & TextContent;\n}\n"]}
|
package/cjs/interface.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { IRectGraphicAttribute } from '@visactor/vrender-core';
|
|
1
|
+
import type { ICustomPath2D, IGraphicAttribute, IRectGraphicAttribute, IRichTextAttribute, ITextGraphicAttribute } from '@visactor/vrender-core';
|
|
2
2
|
export type Direction = 'horizontal' | 'vertical';
|
|
3
3
|
export type OrientType = 'top' | 'right' | 'bottom' | 'left';
|
|
4
4
|
export type BackgroundAttributes = {
|
|
5
5
|
visible: boolean;
|
|
6
|
+
customShape?: (text: ITextGraphicAttribute | IRichTextAttribute, attrs: Partial<IGraphicAttribute>, path: ICustomPath2D) => ICustomPath2D;
|
|
6
7
|
} & Partial<IRectGraphicAttribute>;
|
|
7
8
|
export type IDelayType = 'debounce' | 'throttle';
|
|
8
9
|
export interface ComponentOptions {
|
package/cjs/interface.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../src/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type {\n ICustomPath2D,\n IGraphicAttribute,\n IRectGraphicAttribute,\n IRichTextAttribute,\n ITextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { TextContent } from './core/type';\n\nexport type Direction = 'horizontal' | 'vertical';\n\nexport type OrientType = 'top' | 'right' | 'bottom' | 'left';\n\nexport type BackgroundAttributes = {\n /**\n * 是否绘制背景层\n */\n visible: boolean;\n /**\n * 自定义路径\n * @since 0.19.19\n */\n customShape?: (\n text: ITextGraphicAttribute | IRichTextAttribute,\n attrs: Partial<IGraphicAttribute>,\n path: ICustomPath2D\n ) => ICustomPath2D;\n} & Partial<IRectGraphicAttribute>;\n\nexport type IDelayType = 'debounce' | 'throttle';\n\nexport interface ComponentOptions {\n /** skip default attributes of component */\n skipDefault?: boolean;\n /** the mode of component, only axis support 3d mode now */\n mode?: '2d' | '3d';\n}\n"]}
|