@visactor/vrender-components 0.14.6 → 0.15.0-alpha.5
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/group-transition.d.ts +2 -1
- package/cjs/axis/animate/group-transition.js +3 -3
- package/cjs/axis/animate/group-transition.js.map +1 -1
- package/cjs/axis/base.d.ts +5 -8
- package/cjs/axis/base.js +16 -32
- package/cjs/axis/base.js.map +1 -1
- package/cjs/axis/circle.d.ts +3 -23
- package/cjs/axis/circle.js +3 -84
- package/cjs/axis/circle.js.map +1 -1
- package/cjs/axis/config.d.ts +0 -17
- package/cjs/axis/config.js +0 -17
- package/cjs/axis/config.js.map +1 -1
- package/cjs/axis/grid/base.d.ts +24 -0
- package/cjs/axis/{grid.js → grid/base.js} +67 -20
- package/cjs/axis/grid/base.js.map +1 -0
- package/cjs/axis/grid/circle.d.ts +9 -0
- package/cjs/axis/grid/circle.js +92 -0
- package/cjs/axis/grid/circle.js.map +1 -0
- package/cjs/axis/grid/index.d.ts +3 -0
- package/cjs/axis/grid/index.js +22 -0
- package/cjs/axis/grid/index.js.map +1 -0
- package/cjs/axis/grid/line.d.ts +10 -0
- package/cjs/axis/grid/line.js +103 -0
- package/cjs/axis/grid/line.js.map +1 -0
- package/cjs/axis/grid/type.d.ts +63 -0
- package/cjs/axis/grid/type.js +6 -0
- package/cjs/axis/grid/type.js.map +1 -0
- package/cjs/axis/index.d.ts +0 -1
- package/cjs/axis/index.js +3 -3
- package/cjs/axis/index.js.map +1 -1
- package/cjs/axis/line.d.ts +3 -24
- package/cjs/axis/line.js +17 -167
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/mixin/circle.d.ts +17 -0
- package/cjs/axis/mixin/circle.js +30 -0
- package/cjs/axis/mixin/circle.js.map +1 -0
- package/cjs/axis/mixin/line.d.ts +14 -0
- package/cjs/axis/mixin/line.js +32 -0
- package/cjs/axis/mixin/line.js.map +1 -0
- package/cjs/axis/overlap/auto-rotate.js +2 -2
- package/cjs/axis/overlap/auto-rotate.js.map +1 -1
- package/cjs/axis/type.d.ts +0 -56
- package/cjs/axis/type.js.map +1 -1
- package/cjs/brush/brush.d.ts +0 -1
- package/cjs/brush/brush.js +0 -5
- package/cjs/brush/brush.js.map +1 -1
- package/cjs/core/type.js +2 -1
- package/cjs/crosshair/base.js +1 -2
- package/cjs/index.d.ts +3 -1
- package/cjs/index.js +9 -8
- package/cjs/index.js.map +1 -1
- package/cjs/indicator/type.js +2 -1
- package/cjs/jsx/component-type.d.ts +4 -0
- package/cjs/jsx/component-type.js +13 -0
- package/cjs/jsx/component-type.js.map +1 -0
- package/cjs/jsx/index.d.ts +1 -0
- package/cjs/jsx/index.js +21 -0
- package/cjs/jsx/index.js.map +1 -0
- package/cjs/label/arc.d.ts +3 -6
- package/cjs/label/arc.js +1 -31
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/base.d.ts +9 -12
- package/cjs/label/base.js +134 -117
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/dataLabel.js +4 -4
- package/cjs/label/dataLabel.js.map +1 -1
- package/cjs/label/overlap/place.d.ts +2 -2
- package/cjs/label/overlap/place.js +8 -15
- package/cjs/label/overlap/place.js.map +1 -1
- package/cjs/label/rect.js.map +1 -1
- package/cjs/label/symbol.js.map +1 -1
- package/cjs/label/type.d.ts +2 -5
- package/cjs/label/type.js.map +1 -1
- package/cjs/util/labelSmartInvert.d.ts +0 -1
- package/cjs/util/labelSmartInvert.js +2 -20
- package/cjs/util/labelSmartInvert.js.map +1 -1
- package/cjs/util/matrix.d.ts +1 -1
- package/cjs/util/matrix.js.map +1 -1
- package/dist/index.js +734 -814
- package/dist/index.min.js +1 -1
- package/es/axis/animate/group-transition.d.ts +2 -1
- package/es/axis/animate/group-transition.js +3 -3
- package/es/axis/animate/group-transition.js.map +1 -1
- package/es/axis/base.d.ts +5 -8
- package/es/axis/base.js +15 -33
- package/es/axis/base.js.map +1 -1
- package/es/axis/circle.d.ts +3 -23
- package/es/axis/circle.js +4 -85
- package/es/axis/circle.js.map +1 -1
- package/es/axis/config.d.ts +0 -17
- package/es/axis/config.js +0 -17
- package/es/axis/config.js.map +1 -1
- package/es/axis/grid/base.d.ts +24 -0
- package/es/axis/{grid.js → grid/base.js} +69 -21
- package/es/axis/grid/base.js.map +1 -0
- package/es/axis/grid/circle.d.ts +9 -0
- package/es/axis/grid/circle.js +92 -0
- package/es/axis/grid/circle.js.map +1 -0
- package/es/axis/grid/index.d.ts +3 -0
- package/es/axis/grid/index.js +6 -0
- package/es/axis/grid/index.js.map +1 -0
- package/es/axis/grid/line.d.ts +10 -0
- package/es/axis/grid/line.js +102 -0
- package/es/axis/grid/line.js.map +1 -0
- package/es/axis/grid/type.d.ts +63 -0
- package/es/axis/grid/type.js +2 -0
- package/es/axis/grid/type.js.map +1 -0
- package/es/axis/index.d.ts +0 -1
- package/es/axis/index.js +0 -2
- package/es/axis/index.js.map +1 -1
- package/es/axis/line.d.ts +3 -24
- package/es/axis/line.js +9 -158
- package/es/axis/line.js.map +1 -1
- package/es/axis/mixin/circle.d.ts +17 -0
- package/es/axis/mixin/circle.js +25 -0
- package/es/axis/mixin/circle.js.map +1 -0
- package/es/axis/mixin/line.d.ts +14 -0
- package/es/axis/mixin/line.js +23 -0
- package/es/axis/mixin/line.js.map +1 -0
- package/es/axis/overlap/auto-rotate.js +2 -2
- package/es/axis/overlap/auto-rotate.js.map +1 -1
- package/es/axis/type.d.ts +0 -56
- package/es/axis/type.js.map +1 -1
- package/es/brush/brush.d.ts +0 -1
- package/es/brush/brush.js +0 -5
- package/es/brush/brush.js.map +1 -1
- package/es/core/type.js +2 -1
- package/es/crosshair/base.js +1 -2
- package/es/index.d.ts +3 -1
- package/es/index.js +5 -1
- package/es/index.js.map +1 -1
- package/es/indicator/type.js +2 -1
- package/es/jsx/component-type.d.ts +4 -0
- package/es/jsx/component-type.js +5 -0
- package/es/jsx/component-type.js.map +1 -0
- package/es/jsx/index.d.ts +1 -0
- package/es/jsx/index.js +2 -0
- package/es/jsx/index.js.map +1 -0
- package/es/label/arc.d.ts +3 -6
- package/es/label/arc.js +0 -31
- package/es/label/arc.js.map +1 -1
- package/es/label/base.d.ts +9 -12
- package/es/label/base.js +132 -118
- package/es/label/base.js.map +1 -1
- package/es/label/dataLabel.js +3 -5
- package/es/label/dataLabel.js.map +1 -1
- package/es/label/overlap/place.d.ts +2 -2
- package/es/label/overlap/place.js +8 -15
- package/es/label/overlap/place.js.map +1 -1
- package/es/label/rect.js.map +1 -1
- package/es/label/symbol.js.map +1 -1
- package/es/label/type.d.ts +2 -5
- package/es/label/type.js.map +1 -1
- package/es/util/labelSmartInvert.d.ts +0 -1
- package/es/util/labelSmartInvert.js +0 -17
- package/es/util/labelSmartInvert.js.map +1 -1
- package/es/util/matrix.d.ts +1 -1
- package/es/util/matrix.js.map +1 -1
- package/package.json +4 -4
- package/cjs/axis/grid.d.ts +0 -9
- package/cjs/axis/grid.js.map +0 -1
- package/cjs/label/polygon.d.ts +0 -12
- package/cjs/label/polygon.js +0 -35
- package/cjs/label/polygon.js.map +0 -1
- package/es/axis/grid.d.ts +0 -9
- package/es/axis/grid.js.map +0 -1
- package/es/label/polygon.d.ts +0 -12
- package/es/label/polygon.js +0 -31
- package/es/label/polygon.js.map +0 -1
package/cjs/axis/config.d.ts
CHANGED
|
@@ -51,21 +51,4 @@ export declare const DEFAULT_AXIS_THEME: {
|
|
|
51
51
|
strokeOpacity: number;
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
|
-
grid: {
|
|
55
|
-
style: {
|
|
56
|
-
lineWidth: number;
|
|
57
|
-
stroke: string;
|
|
58
|
-
strokeOpacity: number;
|
|
59
|
-
lineDash: number[];
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
subGrid: {
|
|
63
|
-
visible: boolean;
|
|
64
|
-
style: {
|
|
65
|
-
lineWidth: number;
|
|
66
|
-
stroke: string;
|
|
67
|
-
strokeOpacity: number;
|
|
68
|
-
lineDash: number[];
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
54
|
};
|
package/cjs/axis/config.js
CHANGED
|
@@ -54,23 +54,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
54
54
|
stroke: "#000",
|
|
55
55
|
strokeOpacity: 1
|
|
56
56
|
}
|
|
57
|
-
},
|
|
58
|
-
grid: {
|
|
59
|
-
style: {
|
|
60
|
-
lineWidth: 1,
|
|
61
|
-
stroke: "#999",
|
|
62
|
-
strokeOpacity: 1,
|
|
63
|
-
lineDash: [ 4, 4 ]
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
subGrid: {
|
|
67
|
-
visible: !1,
|
|
68
|
-
style: {
|
|
69
|
-
lineWidth: 1,
|
|
70
|
-
stroke: "#999",
|
|
71
|
-
strokeOpacity: 1,
|
|
72
|
-
lineDash: [ 4, 4 ]
|
|
73
|
-
}
|
|
74
57
|
}
|
|
75
58
|
};
|
|
76
59
|
//# sourceMappingURL=config.js.map
|
package/cjs/axis/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["axis/config.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG;IAChC,KAAK,EAAE;QACL,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,CAAC;QACV,SAAS,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,QAAQ;YACpB,WAAW,EAAE,CAAC;SACf;KACF;IACD,KAAK,EAAE;QACL,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,CAAC;QACV,KAAK,EAAE;YACL,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,QAAQ;YACpB,WAAW,EAAE,CAAC;SACf;KACF;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,KAAK;QACb,cAAc,EAAE,I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,KAAK;QACb,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,MAAM;YACd,aAAa,EAAE,CAAC;SACjB;KACF;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,IAAI;QACb,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,MAAM;YACd,aAAa,EAAE,CAAC;SACjB;KACF;CACF,CAAC","file":"config.js","sourcesContent":["export const DEFAULT_AXIS_THEME = {\n title: {\n space: 4,\n padding: 0,\n textStyle: {\n fontSize: 12,\n fill: '#333333',\n fontWeight: 'normal',\n fillOpacity: 1\n }\n },\n label: {\n visible: true,\n inside: false,\n space: 4,\n padding: 0,\n style: {\n fontSize: 12,\n fill: '#333',\n fontWeight: 'normal',\n fillOpacity: 1\n }\n },\n tick: {\n visible: true,\n inside: false,\n alignWithLabel: true,\n length: 4,\n style: {\n lineWidth: 1,\n stroke: '#000',\n strokeOpacity: 1\n }\n },\n subTick: {\n visible: false,\n inside: false,\n count: 4,\n length: 2,\n style: {\n lineWidth: 1,\n stroke: '#999',\n strokeOpacity: 1\n }\n },\n line: {\n visible: true,\n style: {\n lineWidth: 1,\n stroke: '#000',\n strokeOpacity: 1\n }\n }\n};\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IGroup } from '@visactor/vrender';
|
|
2
|
+
import { AbstractComponent } from '../../core/base';
|
|
3
|
+
import type { Point } from '../../core/type';
|
|
4
|
+
import type { GridBaseAttributes } from './type';
|
|
5
|
+
import type { TransformedAxisItem } from '../type';
|
|
6
|
+
export declare abstract class BaseGrid<T extends GridBaseAttributes> extends AbstractComponent<Required<T>> {
|
|
7
|
+
name: string;
|
|
8
|
+
static defaultAttributes: Partial<GridBaseAttributes>;
|
|
9
|
+
protected _innerView: IGroup;
|
|
10
|
+
getInnerView(): IGroup;
|
|
11
|
+
protected _prevInnerView: IGroup;
|
|
12
|
+
getPrevInnerView(): IGroup;
|
|
13
|
+
protected data: TransformedAxisItem[];
|
|
14
|
+
abstract getTickCoord(value: number): Point;
|
|
15
|
+
abstract isInValidValue(value: number): boolean;
|
|
16
|
+
abstract getVerticalVector(offset: number, inside: boolean, point: Point): [number, number];
|
|
17
|
+
protected abstract getGridAttribute(isSubGrid: boolean): T;
|
|
18
|
+
protected render(): void;
|
|
19
|
+
protected getVerticalCoord(point: Point, offset: number, inside: boolean): Point;
|
|
20
|
+
private _transformItems;
|
|
21
|
+
private _renderGrid;
|
|
22
|
+
private _renderGridByType;
|
|
23
|
+
protected _getNodeId(id: string): string;
|
|
24
|
+
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.
|
|
5
|
+
}), exports.BaseGrid = void 0;
|
|
6
6
|
|
|
7
|
-
const vutils_1 = require("@visactor/vutils"), vrender_1 = require("@visactor/vrender"), base_1 = require("
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), vrender_1 = require("@visactor/vrender"), base_1 = require("../../core/base"), constant_1 = require("../constant");
|
|
8
8
|
|
|
9
9
|
function getLinePath(points, closed) {
|
|
10
10
|
let path = "";
|
|
@@ -40,14 +40,51 @@ function getRegionPath(from, to, attribute) {
|
|
|
40
40
|
regionPath += nextPath, regionPath += "Z"), regionPath;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
class
|
|
44
|
-
constructor(
|
|
45
|
-
super(
|
|
43
|
+
class BaseGrid extends base_1.AbstractComponent {
|
|
44
|
+
constructor() {
|
|
45
|
+
super(...arguments), this.name = "axis-grid", this.data = [];
|
|
46
|
+
}
|
|
47
|
+
getInnerView() {
|
|
48
|
+
return this._innerView;
|
|
49
|
+
}
|
|
50
|
+
getPrevInnerView() {
|
|
51
|
+
return this._prevInnerView;
|
|
46
52
|
}
|
|
47
53
|
render() {
|
|
48
|
-
this.removeAllChild()
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
this.removeAllChild(), this._prevInnerView = this._innerView, this._innerView = (0,
|
|
55
|
+
vrender_1.createGroup)({
|
|
56
|
+
x: 0,
|
|
57
|
+
y: 0,
|
|
58
|
+
pickable: !1
|
|
59
|
+
}), this.add(this._innerView);
|
|
60
|
+
const {items: items, visible: visible} = this.attribute;
|
|
61
|
+
items && items.length && !1 !== visible && (this.data = this._transformItems(items),
|
|
62
|
+
this._renderGrid(this._innerView));
|
|
63
|
+
}
|
|
64
|
+
getVerticalCoord(point, offset, inside) {
|
|
65
|
+
const vector = this.getVerticalVector(offset, inside, point);
|
|
66
|
+
return {
|
|
67
|
+
x: point.x + vector[0],
|
|
68
|
+
y: point.y + vector[1]
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
_transformItems(items) {
|
|
72
|
+
const data = [];
|
|
73
|
+
return items.forEach((item => {
|
|
74
|
+
var _a;
|
|
75
|
+
data.push(Object.assign(Object.assign({}, item), {
|
|
76
|
+
point: this.getTickCoord(item.value),
|
|
77
|
+
id: null !== (_a = item.id) && void 0 !== _a ? _a : item.label
|
|
78
|
+
}));
|
|
79
|
+
})), data;
|
|
80
|
+
}
|
|
81
|
+
_renderGrid(container) {
|
|
82
|
+
const {visible: visible} = this.attribute.subGrid || {};
|
|
83
|
+
visible && this._renderGridByType(!0, container), this._renderGridByType(!1, container);
|
|
84
|
+
}
|
|
85
|
+
_renderGridByType(isSubGrid, container) {
|
|
86
|
+
const gridAttrs = (0, vutils_1.merge)({}, this.attribute, this.getGridAttribute(isSubGrid)), {type: type, items: items, style: style, closed: closed, alternateColor: alternateColor, depth: depth = 0} = gridAttrs, name = isSubGrid ? `${constant_1.AXIS_ELEMENT_NAME.grid}-sub` : `${constant_1.AXIS_ELEMENT_NAME.grid}`;
|
|
87
|
+
if (items.forEach(((item, index) => {
|
|
51
88
|
const {id: id, points: points} = item;
|
|
52
89
|
let path = "";
|
|
53
90
|
if ("line" === type || "polygon" === type) path = getLinePath(points, !!closed); else if ("circle" === type) {
|
|
@@ -57,8 +94,8 @@ class Grid extends base_1.AbstractComponent {
|
|
|
57
94
|
const shape = (0, vrender_1.createPath)(Object.assign({
|
|
58
95
|
path: path,
|
|
59
96
|
z: depth
|
|
60
|
-
}, (0, vutils_1.isFunction)(style) ? (0, vutils_1.merge)({},
|
|
61
|
-
shape.name = `${
|
|
97
|
+
}, (0, vutils_1.isFunction)(style) ? (0, vutils_1.merge)({}, BaseGrid.defaultAttributes.style, style(item, index)) : style));
|
|
98
|
+
shape.name = `${name}-line`, shape.id = this._getNodeId(`${name}-path-${id}`), container.add(shape);
|
|
62
99
|
})), depth && "line" === type && items.forEach(((item, index) => {
|
|
63
100
|
const {id: id, points: points} = item, nextPoints = [];
|
|
64
101
|
nextPoints.push(points[0]);
|
|
@@ -74,18 +111,18 @@ class Grid extends base_1.AbstractComponent {
|
|
|
74
111
|
alpha: deltaX > deltaY ? (points[1].x - points[0].x > 0 ? -1 : 1) * vutils_1.pi / 2 : 0,
|
|
75
112
|
beta: deltaX < deltaY ? -vutils_1.pi / 2 : 0,
|
|
76
113
|
anchor3d: deltaX > deltaY ? [ nextPoints[0].x, 0 ] : [ 0, nextPoints[0].y ]
|
|
77
|
-
}, (0, vutils_1.isFunction)(style) ? (0, vutils_1.merge)({},
|
|
78
|
-
shape.name = `${
|
|
79
|
-
})), items.length > 1 && alternateColor)
|
|
114
|
+
}, (0, vutils_1.isFunction)(style) ? (0, vutils_1.merge)({}, BaseGrid.defaultAttributes.style, style(item, index)) : style));
|
|
115
|
+
shape.name = `${name}-line`, shape.id = this._getNodeId(`${name}-path-${id}`), container.add(shape);
|
|
116
|
+
})), items.length > 1 && alternateColor) {
|
|
80
117
|
const colors = (0, vutils_1.isArray)(alternateColor) ? alternateColor : [ alternateColor, "transparent" ], getColor = index => colors[index % colors.length];
|
|
81
118
|
for (let index = 0; index < items.length - 1; index++) {
|
|
82
|
-
const [prev, curr] = [ items[index].points, items[index + 1].points ], path = getRegionPath(prev, curr,
|
|
119
|
+
const [prev, curr] = [ items[index].points, items[index + 1].points ], path = getRegionPath(prev, curr, gridAttrs), shape = (0,
|
|
83
120
|
vrender_1.createPath)({
|
|
84
121
|
path: path,
|
|
85
122
|
fill: getColor(index)
|
|
86
123
|
});
|
|
87
|
-
shape.name = `${
|
|
88
|
-
|
|
124
|
+
shape.name = `${name}-region`, shape.id = this._getNodeId(`${name}-region-${index}`),
|
|
125
|
+
container.add(shape);
|
|
89
126
|
}
|
|
90
127
|
}
|
|
91
128
|
}
|
|
@@ -94,11 +131,21 @@ class Grid extends base_1.AbstractComponent {
|
|
|
94
131
|
}
|
|
95
132
|
}
|
|
96
133
|
|
|
97
|
-
exports.
|
|
134
|
+
exports.BaseGrid = BaseGrid, BaseGrid.defaultAttributes = {
|
|
98
135
|
style: {
|
|
99
136
|
lineWidth: 1,
|
|
100
|
-
stroke: "#
|
|
137
|
+
stroke: "#999",
|
|
138
|
+
strokeOpacity: 1,
|
|
139
|
+
lineDash: [ 4, 4 ]
|
|
101
140
|
},
|
|
102
|
-
|
|
141
|
+
subGrid: {
|
|
142
|
+
visible: !1,
|
|
143
|
+
style: {
|
|
144
|
+
lineWidth: 1,
|
|
145
|
+
stroke: "#999",
|
|
146
|
+
strokeOpacity: 1,
|
|
147
|
+
lineDash: [ 4, 4 ]
|
|
148
|
+
}
|
|
149
|
+
}
|
|
103
150
|
};
|
|
104
|
-
//# sourceMappingURL=
|
|
151
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["axis/grid/base.ts"],"names":[],"mappings":";;;AAGA,6CAAqF;AAErF,+CAA4D;AAC5D,0CAAoD;AAIpD,0CAAgD;AAEhD,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,C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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;;AAxKH,4BAyKC;AAtKQ,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 { IGroup, Path } from '@visactor/vrender';\nimport { createGroup, createPath } from '@visactor/vrender';\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';\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: IGroup; // 缓存旧场景树,用于自定义动画\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.removeAllChild();\n this._prevInnerView = this._innerView;\n this._innerView = createGroup({ 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 const vector = this.getVerticalVector(offset, inside, point);\n return {\n x: point.x + vector[0],\n y: point.y + vector[1]\n };\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 = createPath({\n path,\n z: depth,\n ...(isFunction(style) ? merge({}, BaseGrid.defaultAttributes.style, style(item, index)) : 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 = createPath({\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) ? merge({}, BaseGrid.defaultAttributes.style, style(item, index)) : 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 = createPath({\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"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseGrid } from './base';
|
|
2
|
+
import type { CircleAxisGridAttributes } from './type';
|
|
3
|
+
import { CircleAxisMixin } from '../mixin/circle';
|
|
4
|
+
export interface CircleAxisGrid extends Pick<CircleAxisMixin, 'isInValidValue' | 'getTickCoord' | 'getVerticalVector'>, BaseGrid<CircleAxisGridAttributes> {
|
|
5
|
+
}
|
|
6
|
+
export declare class CircleAxisGrid extends BaseGrid<CircleAxisGridAttributes> {
|
|
7
|
+
constructor(attributes: CircleAxisGridAttributes);
|
|
8
|
+
protected getGridAttribute(isSubGrid: boolean): any;
|
|
9
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __rest = this && this.__rest || function(s, e) {
|
|
4
|
+
var t = {};
|
|
5
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
6
|
+
if (null != s && "function" == typeof Object.getOwnPropertySymbols) {
|
|
7
|
+
var i = 0;
|
|
8
|
+
for (p = Object.getOwnPropertySymbols(s); i < p.length; i++) e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, "__esModule", {
|
|
14
|
+
value: !0
|
|
15
|
+
}), exports.CircleAxisGrid = void 0;
|
|
16
|
+
|
|
17
|
+
const vutils_1 = require("@visactor/vutils"), base_1 = require("./base"), constant_1 = require("../../constant"), circle_1 = require("../mixin/circle");
|
|
18
|
+
|
|
19
|
+
class CircleAxisGrid extends base_1.BaseGrid {
|
|
20
|
+
constructor(attributes) {
|
|
21
|
+
super((0, vutils_1.merge)({}, base_1.BaseGrid.defaultAttributes, attributes));
|
|
22
|
+
}
|
|
23
|
+
getGridAttribute(isSubGrid) {
|
|
24
|
+
let gridAttribute, items = [];
|
|
25
|
+
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;
|
|
26
|
+
let tickSegment = 1;
|
|
27
|
+
if (this.data.length >= 2 && (tickSegment = this.data[1].value - this.data[0].value),
|
|
28
|
+
isSubGrid) {
|
|
29
|
+
gridAttribute = (0, vutils_1.merge)({}, grid, subGrid);
|
|
30
|
+
const subGridItems = [], {count: subCount = 4} = subGrid || {}, tickLineCount = this.data.length;
|
|
31
|
+
if (tickLineCount >= 2) {
|
|
32
|
+
const points = [];
|
|
33
|
+
this.data.forEach((item => {
|
|
34
|
+
let tickValue = item.value;
|
|
35
|
+
if (!alignWithLabel) {
|
|
36
|
+
const value = item.value - tickSegment / 2;
|
|
37
|
+
if (this.isInValidValue(value)) return;
|
|
38
|
+
tickValue = value;
|
|
39
|
+
}
|
|
40
|
+
points.push({
|
|
41
|
+
value: tickValue
|
|
42
|
+
});
|
|
43
|
+
}));
|
|
44
|
+
for (let i = 0; i < tickLineCount; i++) {
|
|
45
|
+
const pre = points[i], next = points[i + 1];
|
|
46
|
+
subGridItems.push({
|
|
47
|
+
id: `sub-${i}-0`,
|
|
48
|
+
points: [ this.getTickCoord(pre.value), this.getVerticalCoord(this.getTickCoord(pre.value), length, !0) ],
|
|
49
|
+
datum: {}
|
|
50
|
+
});
|
|
51
|
+
for (let j = 0; j < subCount; j++) {
|
|
52
|
+
const percent = (j + 1) / (subCount + 1), value = (1 - percent) * pre.value + percent * (next ? next.value : alignWithLabel ? 1 : pre.value + tickSegment), point = this.getTickCoord(value), endPoint = this.getVerticalCoord(point, length, !0);
|
|
53
|
+
subGridItems.push({
|
|
54
|
+
id: `sub-${i}-${j + 1}`,
|
|
55
|
+
points: [ point, endPoint ],
|
|
56
|
+
datum: {}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
Math.abs(endAngle - startAngle) % (2 * Math.PI) == 0 && subGridItems.push(subGridItems[0]),
|
|
61
|
+
items = subGridItems;
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
gridAttribute = grid;
|
|
65
|
+
const gridItems = [];
|
|
66
|
+
let data;
|
|
67
|
+
data = Math.abs(endAngle - startAngle) % (2 * Math.PI) == 0 ? [ ...this.data ].concat(this.data[0]) : this.data,
|
|
68
|
+
data.forEach((item => {
|
|
69
|
+
let {point: point} = item;
|
|
70
|
+
if (!alignWithLabel) {
|
|
71
|
+
const value = item.value - tickSegment / 2;
|
|
72
|
+
if (this.isInValidValue(value)) return;
|
|
73
|
+
point = this.getTickCoord(value);
|
|
74
|
+
}
|
|
75
|
+
const endPoint = this.getVerticalCoord(point, length, !0);
|
|
76
|
+
gridItems.push({
|
|
77
|
+
id: item.id,
|
|
78
|
+
points: [ point, endPoint ],
|
|
79
|
+
datum: item
|
|
80
|
+
});
|
|
81
|
+
})), items = gridItems;
|
|
82
|
+
}
|
|
83
|
+
return Object.assign(Object.assign({}, gridAttribute), {
|
|
84
|
+
items: items,
|
|
85
|
+
center: center,
|
|
86
|
+
type: "line"
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
exports.CircleAxisGrid = CircleAxisGrid, (0, vutils_1.mixin)(CircleAxisGrid, circle_1.CircleAxisMixin);
|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AAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,GAAG,WAAW,CAAC,CAAC;wBAC3G,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;wBACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;wBAC5D,YAAY,CAAC,IAAI,CAAC;4BAChB,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;4BACvB,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC;4BAEzB,KAAK,EAAE,EAAE;yBACV,CAAC,CAAC;qBACJ;iBACF;gBAED,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE;oBACzD,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,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;AApHD,wCAoHC;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 type { TransformedAxisItem } from '../type';\nimport { CircleAxisMixin } from '../mixin/circle';\n\nexport interface CircleAxisGrid\n extends Pick<CircleAxisMixin, 'isInValidValue' | 'getTickCoord' | 'getVerticalVector'>,\n BaseGrid<CircleAxisGridAttributes> {}\n\nexport class CircleAxisGrid extends BaseGrid<CircleAxisGridAttributes> {\n constructor(attributes: CircleAxisGridAttributes) {\n super(merge({}, BaseGrid.defaultAttributes, attributes));\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 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 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: { value: number }[] = [];\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 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"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4
|
+
void 0 === k2 && (k2 = k);
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
get: function() {
|
|
9
|
+
return m[k];
|
|
10
|
+
}
|
|
11
|
+
}), Object.defineProperty(o, k2, desc);
|
|
12
|
+
} : function(o, m, k, k2) {
|
|
13
|
+
void 0 === k2 && (k2 = k), o[k2] = m[k];
|
|
14
|
+
}), __exportStar = this && this.__exportStar || function(m, exports) {
|
|
15
|
+
for (var p in m) "default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(exports, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), __exportStar(require("./line"), exports), __exportStar(require("./circle"), exports),
|
|
21
|
+
__exportStar(require("./type"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["axis/grid/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,2CAAyB;AAEzB,yCAAuB","file":"index.js","sourcesContent":["export * from './line';\nexport * from './circle';\n\nexport * from './type';\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseGrid } from './base';
|
|
2
|
+
import type { LineAxisGridAttributes } from './type';
|
|
3
|
+
import { LineAxisMixin } from '../mixin/line';
|
|
4
|
+
export interface LineAxisGrid extends Pick<LineAxisMixin, 'isInValidValue' | 'getTickCoord' | 'getVerticalVector'>, BaseGrid<LineAxisGridAttributes> {
|
|
5
|
+
}
|
|
6
|
+
export declare class LineAxisGrid extends BaseGrid<LineAxisGridAttributes> {
|
|
7
|
+
constructor(attributes: LineAxisGridAttributes, mode?: '2d' | '3d');
|
|
8
|
+
private _getGridPoint;
|
|
9
|
+
protected getGridAttribute(isSubGrid: boolean): any;
|
|
10
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.LineAxisGrid = void 0;
|
|
6
|
+
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), base_1 = require("./base"), constant_1 = require("../../constant"), line_1 = require("../mixin/line");
|
|
8
|
+
|
|
9
|
+
function getCirclePoints(center, count, radius, startAngle, endAngle) {
|
|
10
|
+
const points = [], range = endAngle - startAngle;
|
|
11
|
+
for (let i = 0; i < count; i++) {
|
|
12
|
+
const angle = startAngle + i * range / count;
|
|
13
|
+
points.push((0, vutils_1.polarToCartesian)(center, radius, angle));
|
|
14
|
+
}
|
|
15
|
+
return points;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class LineAxisGrid extends base_1.BaseGrid {
|
|
19
|
+
constructor(attributes, mode) {
|
|
20
|
+
super((0, vutils_1.merge)({}, base_1.BaseGrid.defaultAttributes, attributes), mode),
|
|
21
|
+
"3d" === mode && this.setMode(mode);
|
|
22
|
+
}
|
|
23
|
+
_getGridPoint(gridType, point) {
|
|
24
|
+
let gridPoints;
|
|
25
|
+
if ("line" === gridType) {
|
|
26
|
+
const {length: length} = this.attribute;
|
|
27
|
+
gridPoints = [ point, this.getVerticalCoord(point, length, !0) ];
|
|
28
|
+
} else if ("circle" === gridType || "polygon" === gridType) {
|
|
29
|
+
const {center: center, sides: sides = 6, startAngle: startAngle = constant_1.POLAR_START_ANGLE, endAngle: endAngle = constant_1.POLAR_END_ANGLE} = this.attribute;
|
|
30
|
+
gridPoints = getCirclePoints(center, sides, vutils_1.PointService.distancePP(center, point), startAngle, endAngle);
|
|
31
|
+
}
|
|
32
|
+
return gridPoints;
|
|
33
|
+
}
|
|
34
|
+
getGridAttribute(isSubGrid) {
|
|
35
|
+
const {type: gridType, alignWithLabel: alignWithLabel = !0} = this.attribute;
|
|
36
|
+
let tickSegment = 1;
|
|
37
|
+
let gridAttribute;
|
|
38
|
+
this.data.length >= 2 && (tickSegment = this.data[1].value - this.data[0].value);
|
|
39
|
+
let items = [];
|
|
40
|
+
if (isSubGrid) {
|
|
41
|
+
gridAttribute = (0, vutils_1.merge)({}, this.attribute, this.attribute.subGrid);
|
|
42
|
+
const subGridItems = [], {count: subCount = 4} = this.attribute.subGrid || {};
|
|
43
|
+
if (this.data.length >= 2) {
|
|
44
|
+
const points = [];
|
|
45
|
+
this.data.forEach((item => {
|
|
46
|
+
let tickValue = item.value;
|
|
47
|
+
if (!alignWithLabel) {
|
|
48
|
+
const value = item.value - tickSegment / 2;
|
|
49
|
+
if (this.isInValidValue(value)) return;
|
|
50
|
+
tickValue = value;
|
|
51
|
+
}
|
|
52
|
+
points.push({
|
|
53
|
+
value: tickValue
|
|
54
|
+
});
|
|
55
|
+
}));
|
|
56
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
57
|
+
const pre = points[i], next = points[i + 1];
|
|
58
|
+
subGridItems.push({
|
|
59
|
+
id: `sub-${i}-0`,
|
|
60
|
+
points: this._getGridPoint(gridType, this.getTickCoord(pre.value)),
|
|
61
|
+
datum: {}
|
|
62
|
+
});
|
|
63
|
+
for (let j = 0; j < subCount; j++) {
|
|
64
|
+
const percent = (j + 1) / (subCount + 1), value = (1 - percent) * pre.value + percent * next.value, point = this.getTickCoord(value);
|
|
65
|
+
subGridItems.push({
|
|
66
|
+
id: `sub-${i}-${j + 1}`,
|
|
67
|
+
points: this._getGridPoint(gridType, point),
|
|
68
|
+
datum: {}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
i === points.length - 2 && subGridItems.push({
|
|
72
|
+
id: `sub-${i}-${subCount + 1}`,
|
|
73
|
+
points: this._getGridPoint(gridType, this.getTickCoord(next.value)),
|
|
74
|
+
datum: {}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
items = subGridItems;
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
gridAttribute = this.attribute;
|
|
81
|
+
const gridItems = [];
|
|
82
|
+
this.data.forEach((item => {
|
|
83
|
+
let {point: point} = item;
|
|
84
|
+
if (!alignWithLabel) {
|
|
85
|
+
const value = item.value - tickSegment / 2;
|
|
86
|
+
if (this.isInValidValue(value)) return;
|
|
87
|
+
point = this.getTickCoord(value);
|
|
88
|
+
}
|
|
89
|
+
gridItems.push({
|
|
90
|
+
id: item.label,
|
|
91
|
+
datum: item,
|
|
92
|
+
points: this._getGridPoint(gridType, point)
|
|
93
|
+
});
|
|
94
|
+
})), items = gridItems;
|
|
95
|
+
}
|
|
96
|
+
return Object.assign(Object.assign({}, gridAttribute), {
|
|
97
|
+
items: items
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
exports.LineA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;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;AA7HD,oCA6HC;AAED,IAAA,cAAK,EAAC,YAAY,EAAE,oBAAa,CAAC,CAAC","file":"line.js","sourcesContent":["/**\n * @description 直线型坐标轴的网格线\n */\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 type { TransformedAxisItem } from '../type';\nimport { LineAxisMixin } from '../mixin/line';\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\nexport class LineAxisGrid extends BaseGrid<LineAxisGridAttributes> {\n constructor(attributes: LineAxisGridAttributes, mode?: '2d' | '3d') {\n super(merge({}, BaseGrid.defaultAttributes, attributes), mode);\n if (mode === '3d') {\n this.setMode(mode);\n }\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 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 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: { value: number }[] = [];\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 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"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ILineGraphicAttribute, IGroupGraphicAttribute } from '@visactor/vrender';
|
|
2
|
+
import type { Point } from '../../core/type';
|
|
3
|
+
import type { AxisItem, callbackFunc } from '../type';
|
|
4
|
+
export type SubGridAttributesForAxis = {
|
|
5
|
+
visible?: boolean;
|
|
6
|
+
count?: number;
|
|
7
|
+
} & Pick<GridBaseAttributes, 'alternateColor' | 'style' | 'zIndex'>;
|
|
8
|
+
export interface IGrid3dType {
|
|
9
|
+
beta: number;
|
|
10
|
+
anchor3d?: [number, number];
|
|
11
|
+
}
|
|
12
|
+
export type GridItem = {
|
|
13
|
+
id?: string | number;
|
|
14
|
+
points: Point[];
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
};
|
|
17
|
+
export type GridBaseAttributes = {
|
|
18
|
+
type?: 'circle' | 'polygon' | 'line';
|
|
19
|
+
visible?: boolean;
|
|
20
|
+
items: AxisItem[];
|
|
21
|
+
closed?: boolean;
|
|
22
|
+
style?: ILineGraphicAttribute | callbackFunc<Partial<ILineGraphicAttribute> | undefined>;
|
|
23
|
+
alternateColor?: string | string[];
|
|
24
|
+
zIndex?: number;
|
|
25
|
+
alignWithLabel?: boolean;
|
|
26
|
+
subGrid?: SubGridAttributesForAxis;
|
|
27
|
+
verticalFactor?: number;
|
|
28
|
+
} & IGroupGraphicAttribute;
|
|
29
|
+
export type LineGridAttributes = {
|
|
30
|
+
smoothLink?: boolean;
|
|
31
|
+
center?: Point;
|
|
32
|
+
depth?: number;
|
|
33
|
+
} & GridBaseAttributes;
|
|
34
|
+
export type PolygonGridAttributes = {
|
|
35
|
+
type: 'polygon';
|
|
36
|
+
} & GridBaseAttributes;
|
|
37
|
+
export type CircleGridAttributes = {
|
|
38
|
+
type: 'circle';
|
|
39
|
+
center: Point;
|
|
40
|
+
} & GridBaseAttributes;
|
|
41
|
+
export type GridAttributes = LineGridAttributes | CircleGridAttributes | PolygonGridAttributes;
|
|
42
|
+
export type LineGridOfLineAxisAttributes = LineGridAttributes & {
|
|
43
|
+
type: 'line';
|
|
44
|
+
length: number;
|
|
45
|
+
};
|
|
46
|
+
export type PolarGridOfLineAxisAttributes = (PolygonGridAttributes | CircleGridAttributes) & {
|
|
47
|
+
center?: Point;
|
|
48
|
+
sides?: number;
|
|
49
|
+
startAngle?: number;
|
|
50
|
+
endAngle?: number;
|
|
51
|
+
};
|
|
52
|
+
export type LineAxisGridAttributes = (LineGridOfLineAxisAttributes | PolarGridOfLineAxisAttributes) & {
|
|
53
|
+
start: Point;
|
|
54
|
+
end: Point;
|
|
55
|
+
};
|
|
56
|
+
export type CircleAxisGridAttributes = LineGridAttributes & {
|
|
57
|
+
inside?: boolean;
|
|
58
|
+
center: Point;
|
|
59
|
+
startAngle?: number;
|
|
60
|
+
endAngle?: number;
|
|
61
|
+
radius: number;
|
|
62
|
+
innerRadius?: number;
|
|
63
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["axis/grid/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { ILineGraphicAttribute, IGroupGraphicAttribute } from '@visactor/vrender';\nimport type { Point } from '../../core/type';\nimport type { AxisItem, callbackFunc } from '../type';\n\nexport type SubGridAttributesForAxis = {\n /**\n * 是否展示子网格线\n */\n visible?: boolean;\n /**\n * 子网格线的个数\n */\n count?: number;\n} & Pick<GridBaseAttributes, 'alternateColor' | 'style' | 'zIndex'>;\n\nexport interface IGrid3dType {\n beta: number;\n anchor3d?: [number, number];\n}\n\nexport type GridItem = {\n /**\n * 标识符\n */\n id?: string | number;\n /** 网格线点集合 */\n points: Point[];\n [key: string]: any;\n};\n\n// 网格线配置\nexport type GridBaseAttributes = {\n type?: 'circle' | 'polygon' | 'line';\n /**\n * 是否展示网格线\n */\n visible?: boolean;\n /**\n * 网格线绘制点数据\n */\n items: AxisItem[];\n /**\n * 栅格线是否封闭\n */\n closed?: boolean;\n /**\n * 线样式配置\n */\n style?: ILineGraphicAttribute | callbackFunc<Partial<ILineGraphicAttribute> | undefined>;\n /**\n * 两个栅格线间的填充色\n */\n alternateColor?: string | string[];\n /**\n * 网格线的绘图层级\n */\n zIndex?: number;\n /** grid 是否与 label 对齐 */\n alignWithLabel?: boolean;\n /**\n * 子刻度对应网格线配置\n */\n subGrid?: SubGridAttributesForAxis;\n /**\n * 垂直于坐标轴方向的因子,默认为 1\n */\n verticalFactor?: number;\n} & IGroupGraphicAttribute;\n\nexport type LineGridAttributes = {\n /**\n * 当用户配置了 alternateColor 属性时,填充区域是否进行弧线连接\n */\n smoothLink?: boolean;\n center?: Point;\n /**\n * 3d网格线的深度\n */\n depth?: number;\n} & GridBaseAttributes;\n\nexport type PolygonGridAttributes = {\n type: 'polygon';\n} & GridBaseAttributes;\n\nexport type CircleGridAttributes = {\n type: 'circle';\n /**\n * 用于圆弧型网格线的圆心位置声明\n */\n center: Point;\n} & GridBaseAttributes;\n\nexport type GridAttributes = LineGridAttributes | CircleGridAttributes | PolygonGridAttributes;\n\nexport type LineGridOfLineAxisAttributes = LineGridAttributes & {\n type: 'line';\n /**\n * 网格线的长度\n */\n length: number;\n};\n\nexport type PolarGridOfLineAxisAttributes = (PolygonGridAttributes | CircleGridAttributes) & {\n /**\n * 圆心\n */\n center?: Point;\n /**\n * 边数\n */\n sides?: number;\n /**\n * **弧度值**,起始弧度,默认 -0.5 * Math.PI\n *\n */\n startAngle?: number;\n /**\n * **弧度值**,结束弧度,默认 1.5 * Math.PI\n */\n endAngle?: number;\n};\n\nexport type LineAxisGridAttributes = (LineGridOfLineAxisAttributes | PolarGridOfLineAxisAttributes) & {\n /**\n * 起始点坐标\n */\n start: Point;\n /**\n * 结束点坐标\n */\n end: Point;\n};\n\nexport type CircleAxisGridAttributes = LineGridAttributes & {\n /**\n * 当配置了 innerRadius 时,可以通过设置 inside: true,将坐标轴战士在内圆半径上。\n * @default false\n */\n inside?: boolean;\n /**\n * 圆心坐标\n */\n center: Point;\n /**\n * **弧度值**,起始弧度,默认 -0.5 * Math.PI\n *\n */\n startAngle?: number;\n /**\n * **弧度值**,结束弧度,默认 1.5 * Math.PI\n */\n endAngle?: number;\n /**\n * 半径\n */\n radius: number;\n /** 内半径 */\n innerRadius?: number;\n};\n"]}
|