@visactor/vrender-components 0.15.0-alpha.16 → 0.15.0-alpha.17
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 +16 -117
- 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/type.d.ts +0 -55
- package/cjs/axis/type.js.map +1 -1
- package/cjs/core/base.d.ts +2 -1
- package/cjs/core/base.js +4 -2
- package/cjs/core/base.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.js +2 -3
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/type.d.ts +0 -1
- package/cjs/label/type.js.map +1 -1
- package/cjs/link-path/index.js +1 -2
- package/cjs/link-path/link-path.js +2 -1
- package/cjs/marker/config.js +1 -1
- package/cjs/marker/index.js +1 -1
- package/cjs/marker/line.js +1 -1
- package/cjs/marker/point.js +1 -1
- package/cjs/pager/index.js +1 -1
- package/cjs/pager/pager.js +1 -1
- package/cjs/pager/type.js +1 -1
- package/cjs/poptip/register.d.ts +1 -1
- package/cjs/poptip/register.js +8 -6
- package/cjs/poptip/register.js.map +1 -1
- package/cjs/util/matrix.d.ts +1 -1
- package/cjs/util/matrix.js.map +1 -1
- package/cjs/util/text.js +3 -3
- package/cjs/util/text.js.map +1 -1
- package/dist/index.js +640 -591
- 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 +8 -109
- 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/type.d.ts +0 -55
- package/es/axis/type.js.map +1 -1
- package/es/core/base.d.ts +2 -1
- package/es/core/base.js +3 -3
- package/es/core/base.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.js +2 -3
- package/es/label/arc.js.map +1 -1
- package/es/label/type.d.ts +0 -1
- package/es/label/type.js.map +1 -1
- package/es/link-path/index.js +1 -2
- package/es/link-path/link-path.js +2 -1
- package/es/marker/config.js +1 -1
- package/es/marker/index.js +1 -1
- package/es/marker/line.js +1 -1
- package/es/marker/point.js +1 -1
- package/es/pager/index.js +1 -1
- package/es/pager/pager.js +1 -1
- package/es/pager/type.js +1 -1
- package/es/poptip/register.d.ts +1 -1
- package/es/poptip/register.js +7 -6
- package/es/poptip/register.js.map +1 -1
- package/es/util/matrix.d.ts +1 -1
- package/es/util/matrix.js.map +1 -1
- package/es/util/text.js +3 -3
- package/es/util/text.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/es/axis/grid.d.ts +0 -9
- package/es/axis/grid.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
setAttribute(key, value, forceUpdateTag) {
|
|
39
|
-
if (vutils.isPlainObject(this.attribute[key])) {
|
|
39
|
+
if (vutils.isPlainObject(this.attribute[key]) && !vutils.isFunction(this.attribute[key]) && !vutils.isFunction(value)) {
|
|
40
40
|
vutils.merge(this.attribute[key], value);
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
}
|
|
78
78
|
for (let i = 0; i < keys.length; i++) {
|
|
79
79
|
const key = keys[i];
|
|
80
|
-
if (vutils.isPlainObject(this.attribute[key])) {
|
|
80
|
+
if (vutils.isPlainObject(this.attribute[key]) && !vutils.isFunction(this.attribute[key]) && !vutils.isFunction(params[key])) {
|
|
81
81
|
vutils.merge(this.attribute[key], params[key]);
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
@@ -575,16 +575,16 @@
|
|
|
575
575
|
}, getTextBounds: useNaiveCanvas ? undefined : vrender.getTextBounds, specialCharSet: '-/: .,@%\'"~' + vutils.TextMeasure.ALPHABET_CHAR_SET + vutils.TextMeasure.ALPHABET_CHAR_SET.toUpperCase() }, (option !== null && option !== void 0 ? option : {})), textSpec);
|
|
576
576
|
};
|
|
577
577
|
function measureTextSize(text, textSpec) {
|
|
578
|
-
var _a
|
|
578
|
+
var _a;
|
|
579
579
|
if (!text) {
|
|
580
580
|
return { width: 0, height: 0 };
|
|
581
581
|
}
|
|
582
582
|
const bounds = vrender.getTextBounds({
|
|
583
583
|
text,
|
|
584
|
-
fontFamily:
|
|
584
|
+
fontFamily: textSpec.fontFamily,
|
|
585
585
|
fontSize: textSpec.fontSize || 12,
|
|
586
586
|
fontWeight: textSpec.fontWeight,
|
|
587
|
-
textAlign: (
|
|
587
|
+
textAlign: (_a = textSpec.textAlign) !== null && _a !== void 0 ? _a : 'center',
|
|
588
588
|
textBaseline: textSpec.textBaseline,
|
|
589
589
|
ellipsis: !!textSpec.ellipsis,
|
|
590
590
|
maxLineWidth: textSpec.maxLineWidth || Infinity,
|
|
@@ -1103,16 +1103,21 @@
|
|
|
1103
1103
|
injectable()
|
|
1104
1104
|
], PopTipForClipedTextPlugin);
|
|
1105
1105
|
|
|
1106
|
-
const popTipModule = new ContainerModule(bind => {
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1106
|
+
const popTipModule = new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
1107
|
+
if (!isBound(PopTipRenderContribution)) {
|
|
1108
|
+
bind(PopTipRenderContribution).toSelf().inSingletonScope();
|
|
1109
|
+
bind(vrender.InteractiveSubRenderContribution).toService(PopTipRenderContribution);
|
|
1110
|
+
}
|
|
1111
|
+
if (!isBound(PopTipPlugin)) {
|
|
1112
|
+
bind(PopTipPlugin).toSelf();
|
|
1113
|
+
bind(vrender.AutoEnablePlugins).toService(PopTipPlugin);
|
|
1114
|
+
}
|
|
1115
|
+
if (!isBound(PopTipForClipedTextPlugin)) {
|
|
1116
|
+
bind(PopTipForClipedTextPlugin).toSelf();
|
|
1117
|
+
bind(vrender.AutoEnablePlugins).toService(PopTipForClipedTextPlugin);
|
|
1118
|
+
}
|
|
1113
1119
|
});
|
|
1114
|
-
function loadPoptip(
|
|
1115
|
-
vutils.merge(theme.poptip, defaultPoptipTheme);
|
|
1120
|
+
function loadPoptip() {
|
|
1116
1121
|
vrender.container.load(popTipModule);
|
|
1117
1122
|
}
|
|
1118
1123
|
function setPoptipTheme(defaultPoptipTheme) {
|
|
@@ -3068,14 +3073,13 @@
|
|
|
3068
3073
|
}
|
|
3069
3074
|
}
|
|
3070
3075
|
_labelLine(text) {
|
|
3071
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q
|
|
3076
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
3072
3077
|
const labelLine = ((_a = text.attribute) === null || _a === void 0 ? void 0 : _a.points)
|
|
3073
3078
|
? vrender.createLine({
|
|
3074
3079
|
visible: (_g = (_e = (((_c = (_b = text.attribute) === null || _b === void 0 ? void 0 : _b.line) === null || _c === void 0 ? void 0 : _c.visible) && ((_d = text.attribute) === null || _d === void 0 ? void 0 : _d.visible))) !== null && _e !== void 0 ? _e : (_f = text.attribute) === null || _f === void 0 ? void 0 : _f.visible) !== null && _g !== void 0 ? _g : true,
|
|
3075
3080
|
stroke: (_k = (_j = (_h = text.attribute) === null || _h === void 0 ? void 0 : _h.line) === null || _j === void 0 ? void 0 : _j.stroke) !== null && _k !== void 0 ? _k : (_l = text.attribute) === null || _l === void 0 ? void 0 : _l.fill,
|
|
3076
3081
|
lineWidth: (_p = (_o = (_m = text.attribute) === null || _m === void 0 ? void 0 : _m.line) === null || _o === void 0 ? void 0 : _o.lineWidth) !== null && _p !== void 0 ? _p : 1,
|
|
3077
|
-
points: (_q = text.attribute) === null || _q === void 0 ? void 0 : _q.points
|
|
3078
|
-
curveType: ((_s = (_r = text.attribute) === null || _r === void 0 ? void 0 : _r.line) === null || _s === void 0 ? void 0 : _s.smooth) ? 'basis' : null
|
|
3082
|
+
points: (_q = text.attribute) === null || _q === void 0 ? void 0 : _q.points
|
|
3079
3083
|
})
|
|
3080
3084
|
: undefined;
|
|
3081
3085
|
return labelLine;
|
|
@@ -3198,156 +3202,6 @@
|
|
|
3198
3202
|
pickable: false
|
|
3199
3203
|
};
|
|
3200
3204
|
|
|
3201
|
-
function getLinePath(points, closed) {
|
|
3202
|
-
let path = '';
|
|
3203
|
-
if (points.length === 0) {
|
|
3204
|
-
return path;
|
|
3205
|
-
}
|
|
3206
|
-
points.forEach((point, index) => {
|
|
3207
|
-
if (index === 0) {
|
|
3208
|
-
path = `M${point.x},${point.y}`;
|
|
3209
|
-
}
|
|
3210
|
-
else {
|
|
3211
|
-
path += `L${point.x},${point.y}`;
|
|
3212
|
-
}
|
|
3213
|
-
});
|
|
3214
|
-
if (closed) {
|
|
3215
|
-
path += 'Z';
|
|
3216
|
-
}
|
|
3217
|
-
return path;
|
|
3218
|
-
}
|
|
3219
|
-
function getArcPath(center, points, reverse, closed) {
|
|
3220
|
-
let path = '';
|
|
3221
|
-
if (!center || points.length === 0) {
|
|
3222
|
-
return path;
|
|
3223
|
-
}
|
|
3224
|
-
const firstPoint = points[0];
|
|
3225
|
-
const radius = vutils.PointService.distancePP(center, firstPoint);
|
|
3226
|
-
const sweepFlag = reverse ? 0 : 1;
|
|
3227
|
-
if (closed) {
|
|
3228
|
-
path += `M${center.x},${center.y - radius}A${radius},${radius},0,0,${sweepFlag},${center.x},${center.y + radius}A${radius},${radius},0,0,${sweepFlag},${center.x},${center.y - radius}Z`;
|
|
3229
|
-
}
|
|
3230
|
-
else {
|
|
3231
|
-
points.forEach((point, index) => {
|
|
3232
|
-
if (index === 0) {
|
|
3233
|
-
path = `M${point.x},${point.y}`;
|
|
3234
|
-
}
|
|
3235
|
-
else {
|
|
3236
|
-
path += `A${radius},${radius},0,0,${sweepFlag},${point.x},${point.y}`;
|
|
3237
|
-
}
|
|
3238
|
-
});
|
|
3239
|
-
}
|
|
3240
|
-
return path;
|
|
3241
|
-
}
|
|
3242
|
-
function getRegionPath(from, to, attribute) {
|
|
3243
|
-
const { type, closed } = attribute;
|
|
3244
|
-
const reversePoints = to.slice(0).reverse();
|
|
3245
|
-
let regionPath = '';
|
|
3246
|
-
let nextPath = '';
|
|
3247
|
-
if (type === 'line' && attribute.smoothLink && attribute.center) {
|
|
3248
|
-
const fromStart = from[0];
|
|
3249
|
-
const toEnd = reversePoints[0];
|
|
3250
|
-
const center = attribute.center;
|
|
3251
|
-
regionPath = getLinePath(from, !!closed);
|
|
3252
|
-
nextPath = getLinePath(reversePoints, !!closed);
|
|
3253
|
-
const toEndRadius = vutils.PointService.distancePP(toEnd, center);
|
|
3254
|
-
const fromStartRadius = vutils.PointService.distancePP(fromStart, center);
|
|
3255
|
-
regionPath += `A${toEndRadius},${toEndRadius},0,0,1,${toEnd.x},${toEnd.y}L${toEnd.x},${toEnd.y}`;
|
|
3256
|
-
nextPath += `A${fromStartRadius},${fromStartRadius},0,0,0,${fromStart.x},${fromStart.y}`;
|
|
3257
|
-
}
|
|
3258
|
-
else if (type === 'circle') {
|
|
3259
|
-
const { center } = attribute;
|
|
3260
|
-
regionPath = getArcPath(center, from, false, !!closed);
|
|
3261
|
-
nextPath = getArcPath(center, reversePoints, true, !!closed);
|
|
3262
|
-
}
|
|
3263
|
-
else if (type === 'line' || type === 'polygon') {
|
|
3264
|
-
regionPath = getLinePath(from, !!closed);
|
|
3265
|
-
nextPath = getLinePath(reversePoints, !!closed);
|
|
3266
|
-
}
|
|
3267
|
-
if (closed) {
|
|
3268
|
-
regionPath += nextPath;
|
|
3269
|
-
}
|
|
3270
|
-
else {
|
|
3271
|
-
nextPath = 'L' + nextPath.substring(1);
|
|
3272
|
-
regionPath += nextPath;
|
|
3273
|
-
regionPath += 'Z';
|
|
3274
|
-
}
|
|
3275
|
-
return regionPath;
|
|
3276
|
-
}
|
|
3277
|
-
class Grid extends AbstractComponent {
|
|
3278
|
-
constructor(attributes) {
|
|
3279
|
-
super(vutils.merge({}, Grid.defaultAttributes, attributes));
|
|
3280
|
-
this.name = 'grid';
|
|
3281
|
-
}
|
|
3282
|
-
render() {
|
|
3283
|
-
this.removeAllChild();
|
|
3284
|
-
const { type, items, style, closed, alternateColor, depth = 0 } = this.attribute;
|
|
3285
|
-
if (vutils.isEmpty(items)) {
|
|
3286
|
-
return;
|
|
3287
|
-
}
|
|
3288
|
-
items.forEach((item, index) => {
|
|
3289
|
-
const { id, points } = item;
|
|
3290
|
-
let path = '';
|
|
3291
|
-
if (type === 'line' || type === 'polygon') {
|
|
3292
|
-
path = getLinePath(points, !!closed);
|
|
3293
|
-
}
|
|
3294
|
-
else if (type === 'circle') {
|
|
3295
|
-
const { center } = this.attribute;
|
|
3296
|
-
path = getArcPath(center, points, false, !!closed);
|
|
3297
|
-
}
|
|
3298
|
-
const shape = vrender.createPath(Object.assign({ path, z: depth }, (vutils.isFunction(style) ? vutils.merge({}, Grid.defaultAttributes.style, style(item, index)) : style)));
|
|
3299
|
-
shape.name = `${this.name}-line`;
|
|
3300
|
-
shape.id = this._getNodeId(`path-${id}`);
|
|
3301
|
-
this.add(shape);
|
|
3302
|
-
});
|
|
3303
|
-
if (depth && type === 'line') {
|
|
3304
|
-
items.forEach((item, index) => {
|
|
3305
|
-
const { id, points } = item;
|
|
3306
|
-
const nextPoints = [];
|
|
3307
|
-
nextPoints.push(points[0]);
|
|
3308
|
-
const dir = { x: points[1].x - points[0].x, y: points[1].y - points[0].y };
|
|
3309
|
-
const dirLen = Math.sqrt(dir.x * dir.x + dir.y * dir.y);
|
|
3310
|
-
const ratio = depth / dirLen;
|
|
3311
|
-
nextPoints.push({ x: points[0].x + dir.x * ratio, y: points[0].y + dir.y * ratio });
|
|
3312
|
-
const path = getLinePath(nextPoints, !!closed);
|
|
3313
|
-
const deltaX = vutils.abs(nextPoints[0].x - nextPoints[1].x);
|
|
3314
|
-
const deltaY = vutils.abs(nextPoints[0].y - nextPoints[1].y);
|
|
3315
|
-
const shape = vrender.createPath(Object.assign({ path, z: 0, alpha: deltaX > deltaY ? ((points[1].x - points[0].x > 0 ? -1 : 1) * vutils.pi) / 2 : 0, beta: deltaX < deltaY ? -vutils.pi / 2 : 0, anchor3d: deltaX > deltaY ? [nextPoints[0].x, 0] : [0, nextPoints[0].y] }, (vutils.isFunction(style) ? vutils.merge({}, Grid.defaultAttributes.style, style(item, index)) : style)));
|
|
3316
|
-
shape.name = `${this.name}-line`;
|
|
3317
|
-
shape.id = this._getNodeId(`path-${id}`);
|
|
3318
|
-
this.add(shape);
|
|
3319
|
-
});
|
|
3320
|
-
}
|
|
3321
|
-
if (items.length > 1 && alternateColor) {
|
|
3322
|
-
const colors = vutils.isArray(alternateColor)
|
|
3323
|
-
? alternateColor
|
|
3324
|
-
: [alternateColor, 'transparent'];
|
|
3325
|
-
const getColor = (index) => colors[index % colors.length];
|
|
3326
|
-
for (let index = 0; index < items.length - 1; index++) {
|
|
3327
|
-
const [prev, curr] = [items[index].points, items[index + 1].points];
|
|
3328
|
-
const path = getRegionPath(prev, curr, this.attribute);
|
|
3329
|
-
const shape = vrender.createPath({
|
|
3330
|
-
path,
|
|
3331
|
-
fill: getColor(index)
|
|
3332
|
-
});
|
|
3333
|
-
shape.name = `${this.name}-region`;
|
|
3334
|
-
shape.id = this._getNodeId(`region-${index}`);
|
|
3335
|
-
this.add(shape);
|
|
3336
|
-
}
|
|
3337
|
-
}
|
|
3338
|
-
}
|
|
3339
|
-
_getNodeId(id) {
|
|
3340
|
-
return `${this.id}-${id}`;
|
|
3341
|
-
}
|
|
3342
|
-
}
|
|
3343
|
-
Grid.defaultAttributes = {
|
|
3344
|
-
style: {
|
|
3345
|
-
lineWidth: 1,
|
|
3346
|
-
stroke: '#416180'
|
|
3347
|
-
},
|
|
3348
|
-
zIndex: 0
|
|
3349
|
-
};
|
|
3350
|
-
|
|
3351
3205
|
class Segment extends AbstractComponent {
|
|
3352
3206
|
constructor(attributes) {
|
|
3353
3207
|
super(vutils.merge({}, Segment.defaultAttributes, attributes));
|
|
@@ -3565,23 +3419,6 @@
|
|
|
3565
3419
|
stroke: '#000',
|
|
3566
3420
|
strokeOpacity: 1
|
|
3567
3421
|
}
|
|
3568
|
-
},
|
|
3569
|
-
grid: {
|
|
3570
|
-
style: {
|
|
3571
|
-
lineWidth: 1,
|
|
3572
|
-
stroke: '#999',
|
|
3573
|
-
strokeOpacity: 1,
|
|
3574
|
-
lineDash: [4, 4]
|
|
3575
|
-
}
|
|
3576
|
-
},
|
|
3577
|
-
subGrid: {
|
|
3578
|
-
visible: false,
|
|
3579
|
-
style: {
|
|
3580
|
-
lineWidth: 1,
|
|
3581
|
-
stroke: '#999',
|
|
3582
|
-
strokeOpacity: 1,
|
|
3583
|
-
lineDash: [4, 4]
|
|
3584
|
-
}
|
|
3585
3422
|
}
|
|
3586
3423
|
};
|
|
3587
3424
|
|
|
@@ -3678,7 +3515,7 @@
|
|
|
3678
3515
|
}
|
|
3679
3516
|
}
|
|
3680
3517
|
_renderInner(container) {
|
|
3681
|
-
const { title, label, tick, line,
|
|
3518
|
+
const { title, label, tick, line, items } = this.attribute;
|
|
3682
3519
|
const axisContainer = vrender.createGroup({ x: 0, y: 0, zIndex: 1 });
|
|
3683
3520
|
axisContainer.name = exports.AXIS_ELEMENT_NAME.axisContainer;
|
|
3684
3521
|
axisContainer.id = this._getNodeId('container');
|
|
@@ -3707,9 +3544,6 @@
|
|
|
3707
3544
|
this.afterLabelsOverlap(labels, axisItems, layerLabelGroup, layer, items.length);
|
|
3708
3545
|
});
|
|
3709
3546
|
}
|
|
3710
|
-
if (grid === null || grid === void 0 ? void 0 : grid.visible) {
|
|
3711
|
-
this.renderGrid(container);
|
|
3712
|
-
}
|
|
3713
3547
|
}
|
|
3714
3548
|
if (title === null || title === void 0 ? void 0 : title.visible) {
|
|
3715
3549
|
this.renderTitle(axisContainer);
|
|
@@ -3826,13 +3660,6 @@
|
|
|
3826
3660
|
axisTitle.id = this._getNodeId('title');
|
|
3827
3661
|
container.add(axisTitle);
|
|
3828
3662
|
}
|
|
3829
|
-
renderGrid(container) {
|
|
3830
|
-
const { visible } = this.attribute.subGrid || {};
|
|
3831
|
-
if (visible) {
|
|
3832
|
-
this._renderGridByType('subGrid', container);
|
|
3833
|
-
}
|
|
3834
|
-
this._renderGridByType('grid', container);
|
|
3835
|
-
}
|
|
3836
3663
|
getVerticalCoord(point, offset, inside) {
|
|
3837
3664
|
const vector = this.getVerticalVector(offset, inside, point);
|
|
3838
3665
|
return {
|
|
@@ -4003,13 +3830,6 @@
|
|
|
4003
3830
|
});
|
|
4004
3831
|
return data;
|
|
4005
3832
|
}
|
|
4006
|
-
_renderGridByType(type, container) {
|
|
4007
|
-
const gridAttrs = this.getGridAttribute(type);
|
|
4008
|
-
const gridGroup = new Grid(Object.assign(Object.assign({ pickable: false }, gridAttrs), { zIndex: 0 }));
|
|
4009
|
-
gridGroup.name = type === 'subGrid' ? `${exports.AXIS_ELEMENT_NAME.grid}-sub` : `${exports.AXIS_ELEMENT_NAME.grid}`;
|
|
4010
|
-
gridGroup.id = this._getNodeId(type);
|
|
4011
|
-
container.add(gridGroup);
|
|
4012
|
-
}
|
|
4013
3833
|
}
|
|
4014
3834
|
|
|
4015
3835
|
const methods = {
|
|
@@ -4308,15 +4128,31 @@
|
|
|
4308
4128
|
}
|
|
4309
4129
|
}
|
|
4310
4130
|
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4131
|
+
class LineAxisMixin {
|
|
4132
|
+
isInValidValue(value) {
|
|
4133
|
+
return value < 0 || value > 1;
|
|
4134
|
+
}
|
|
4135
|
+
getTickCoord(tickValue) {
|
|
4136
|
+
const { start } = this.attribute;
|
|
4137
|
+
const axisVector = this.getRelativeVector();
|
|
4138
|
+
return {
|
|
4139
|
+
x: start.x + axisVector[0] * tickValue,
|
|
4140
|
+
y: start.y + axisVector[1] * tickValue
|
|
4141
|
+
};
|
|
4142
|
+
}
|
|
4143
|
+
getRelativeVector(point) {
|
|
4144
|
+
const { start, end } = this.attribute;
|
|
4145
|
+
return [end.x - start.x, end.y - start.y];
|
|
4146
|
+
}
|
|
4147
|
+
getVerticalVector(offset, inside = false, point) {
|
|
4148
|
+
const { verticalFactor = 1 } = this.attribute;
|
|
4149
|
+
const axisVector = this.getRelativeVector();
|
|
4150
|
+
const normalizedAxisVector = normalize(axisVector);
|
|
4151
|
+
const verticalVector = [normalizedAxisVector[1], normalizedAxisVector[0] * -1];
|
|
4152
|
+
return scale(verticalVector, offset * (inside ? 1 : -1) * verticalFactor);
|
|
4317
4153
|
}
|
|
4318
|
-
return points;
|
|
4319
4154
|
}
|
|
4155
|
+
|
|
4320
4156
|
class LineAxis extends AxisBase {
|
|
4321
4157
|
constructor(attributes, mode) {
|
|
4322
4158
|
super(vutils.merge({}, LineAxis.defaultAttributes, attributes), mode);
|
|
@@ -4354,28 +4190,6 @@
|
|
|
4354
4190
|
axisLineGroup.id = this._getNodeId('line');
|
|
4355
4191
|
container.add(axisLineGroup);
|
|
4356
4192
|
}
|
|
4357
|
-
isInValidValue(value) {
|
|
4358
|
-
return value < 0 || value > 1;
|
|
4359
|
-
}
|
|
4360
|
-
getTickCoord(tickValue) {
|
|
4361
|
-
const { start } = this.attribute;
|
|
4362
|
-
const axisVector = this.getRelativeVector();
|
|
4363
|
-
return {
|
|
4364
|
-
x: start.x + axisVector[0] * tickValue,
|
|
4365
|
-
y: start.y + axisVector[1] * tickValue
|
|
4366
|
-
};
|
|
4367
|
-
}
|
|
4368
|
-
getRelativeVector() {
|
|
4369
|
-
const { start, end } = this.attribute;
|
|
4370
|
-
return [end.x - start.x, end.y - start.y];
|
|
4371
|
-
}
|
|
4372
|
-
getVerticalVector(offset, inside = false) {
|
|
4373
|
-
const { verticalFactor = 1 } = this.attribute;
|
|
4374
|
-
const axisVector = this.getRelativeVector();
|
|
4375
|
-
const normalizedAxisVector = normalize(axisVector);
|
|
4376
|
-
const verticalVector = [normalizedAxisVector[1], normalizedAxisVector[0] * -1];
|
|
4377
|
-
return scale(verticalVector, offset * (inside ? 1 : -1) * verticalFactor);
|
|
4378
|
-
}
|
|
4379
4193
|
getTitleAttribute() {
|
|
4380
4194
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4381
4195
|
const _j = this.attribute.title, { position = 'middle', space = 4, textStyle = {}, autoRotate = true, shape, background, state } = _j, restAttrs = __rest(_j, ["position", "space", "textStyle", "autoRotate", "shape", "background", "state"]);
|
|
@@ -4460,7 +4274,7 @@
|
|
|
4460
4274
|
}
|
|
4461
4275
|
const offset = tickLength + labelLength + space;
|
|
4462
4276
|
const titlePoint = this.getVerticalCoord(point, offset, false);
|
|
4463
|
-
const vector = this.getVerticalVector(offset, false);
|
|
4277
|
+
const vector = this.getVerticalVector(offset, false, { x: 0, y: 0 });
|
|
4464
4278
|
let { angle } = restAttrs;
|
|
4465
4279
|
let textAlign;
|
|
4466
4280
|
if (position === 'start') {
|
|
@@ -4508,129 +4322,35 @@
|
|
|
4508
4322
|
}
|
|
4509
4323
|
return attrs;
|
|
4510
4324
|
}
|
|
4511
|
-
|
|
4512
|
-
let
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4325
|
+
getTextBaseline(vector, inside) {
|
|
4326
|
+
let base = 'middle';
|
|
4327
|
+
const { verticalFactor = 1 } = this.attribute;
|
|
4328
|
+
const factor = (inside ? 1 : -1) * verticalFactor;
|
|
4329
|
+
if (vutils.isNumberClose(vector[1], 0)) {
|
|
4330
|
+
if (vutils.isNumberClose(vector[0], 0) && !Object.is(vector[0], -0) && !Object.is(vector[1], -0)) {
|
|
4331
|
+
base = factor === 1 ? 'bottom' : 'top';
|
|
4332
|
+
}
|
|
4333
|
+
else {
|
|
4334
|
+
base = 'middle';
|
|
4335
|
+
}
|
|
4517
4336
|
}
|
|
4518
|
-
else if (
|
|
4519
|
-
|
|
4520
|
-
const distance = vutils.PointService.distancePP(center, point);
|
|
4521
|
-
gridPoints = getCirclePoints(center, sides, distance, startAngle, endAngle);
|
|
4337
|
+
else if (vector[1] > 0) {
|
|
4338
|
+
base = 'top';
|
|
4522
4339
|
}
|
|
4523
|
-
|
|
4340
|
+
else if (vector[1] < 0) {
|
|
4341
|
+
base = 'bottom';
|
|
4342
|
+
}
|
|
4343
|
+
return base;
|
|
4524
4344
|
}
|
|
4525
|
-
|
|
4526
|
-
const
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
if (type === 'grid') {
|
|
4535
|
-
gridAttribute = this.attribute.grid;
|
|
4536
|
-
const gridItems = [];
|
|
4537
|
-
this.data.forEach(item => {
|
|
4538
|
-
let { point } = item;
|
|
4539
|
-
if (!alignWithLabel) {
|
|
4540
|
-
const value = item.value - tickSegment / 2;
|
|
4541
|
-
if (this.isInValidValue(value)) {
|
|
4542
|
-
return;
|
|
4543
|
-
}
|
|
4544
|
-
point = this.getTickCoord(value);
|
|
4545
|
-
}
|
|
4546
|
-
gridItems.push({
|
|
4547
|
-
id: item.label,
|
|
4548
|
-
datum: item,
|
|
4549
|
-
points: this._getGridPoint(gridType, point)
|
|
4550
|
-
});
|
|
4551
|
-
});
|
|
4552
|
-
items = gridItems;
|
|
4553
|
-
}
|
|
4554
|
-
else {
|
|
4555
|
-
gridAttribute = vutils.merge({}, this.attribute.grid, this.attribute.subGrid);
|
|
4556
|
-
const subGridItems = [];
|
|
4557
|
-
const { count: subCount = 4 } = this.attribute.subTick || {};
|
|
4558
|
-
const tickLineCount = this.data.length;
|
|
4559
|
-
if (tickLineCount >= 2) {
|
|
4560
|
-
const points = [];
|
|
4561
|
-
this.data.forEach((item) => {
|
|
4562
|
-
let tickValue = item.value;
|
|
4563
|
-
if (!alignWithLabel) {
|
|
4564
|
-
const value = item.value - tickSegment / 2;
|
|
4565
|
-
if (this.isInValidValue(value)) {
|
|
4566
|
-
return;
|
|
4567
|
-
}
|
|
4568
|
-
tickValue = value;
|
|
4569
|
-
}
|
|
4570
|
-
points.push({
|
|
4571
|
-
value: tickValue
|
|
4572
|
-
});
|
|
4573
|
-
});
|
|
4574
|
-
for (let i = 0; i < points.length - 1; i++) {
|
|
4575
|
-
const pre = points[i];
|
|
4576
|
-
const next = points[i + 1];
|
|
4577
|
-
subGridItems.push({
|
|
4578
|
-
id: `sub-${i}-0`,
|
|
4579
|
-
points: this._getGridPoint(gridType, this.getTickCoord(pre.value)),
|
|
4580
|
-
datum: {}
|
|
4581
|
-
});
|
|
4582
|
-
for (let j = 0; j < subCount; j++) {
|
|
4583
|
-
const percent = (j + 1) / (subCount + 1);
|
|
4584
|
-
const value = (1 - percent) * pre.value + percent * next.value;
|
|
4585
|
-
const point = this.getTickCoord(value);
|
|
4586
|
-
subGridItems.push({
|
|
4587
|
-
id: `sub-${i}-${j + 1}`,
|
|
4588
|
-
points: this._getGridPoint(gridType, point),
|
|
4589
|
-
datum: {}
|
|
4590
|
-
});
|
|
4591
|
-
}
|
|
4592
|
-
if (i === points.length - 2) {
|
|
4593
|
-
subGridItems.push({
|
|
4594
|
-
id: `sub-${i}-${subCount + 1}`,
|
|
4595
|
-
points: this._getGridPoint(gridType, this.getTickCoord(next.value)),
|
|
4596
|
-
datum: {}
|
|
4597
|
-
});
|
|
4598
|
-
}
|
|
4599
|
-
}
|
|
4600
|
-
items = subGridItems;
|
|
4601
|
-
}
|
|
4602
|
-
}
|
|
4603
|
-
return Object.assign(Object.assign({}, gridAttribute), { items });
|
|
4604
|
-
}
|
|
4605
|
-
getTextBaseline(vector, inside) {
|
|
4606
|
-
let base = 'middle';
|
|
4607
|
-
const { verticalFactor = 1 } = this.attribute;
|
|
4608
|
-
const factor = (inside ? 1 : -1) * verticalFactor;
|
|
4609
|
-
if (vutils.isNumberClose(vector[1], 0)) {
|
|
4610
|
-
if (vutils.isNumberClose(vector[0], 0) && !Object.is(vector[0], -0) && !Object.is(vector[1], -0)) {
|
|
4611
|
-
base = factor === 1 ? 'bottom' : 'top';
|
|
4612
|
-
}
|
|
4613
|
-
else {
|
|
4614
|
-
base = 'middle';
|
|
4615
|
-
}
|
|
4616
|
-
}
|
|
4617
|
-
else if (vector[1] > 0) {
|
|
4618
|
-
base = 'top';
|
|
4619
|
-
}
|
|
4620
|
-
else if (vector[1] < 0) {
|
|
4621
|
-
base = 'bottom';
|
|
4622
|
-
}
|
|
4623
|
-
return base;
|
|
4624
|
-
}
|
|
4625
|
-
getLabelAlign(vector, inside, angle) {
|
|
4626
|
-
const orient = this.attribute.orient;
|
|
4627
|
-
if (vutils.isValidNumber(angle)) {
|
|
4628
|
-
if (orient === 'top' || orient === 'bottom') {
|
|
4629
|
-
return getXAxisLabelAlign(orient, angle);
|
|
4630
|
-
}
|
|
4631
|
-
if (orient === 'left' || orient === 'right') {
|
|
4632
|
-
return getYAxisLabelAlign(orient, angle);
|
|
4633
|
-
}
|
|
4345
|
+
getLabelAlign(vector, inside, angle) {
|
|
4346
|
+
const orient = this.attribute.orient;
|
|
4347
|
+
if (vutils.isValidNumber(angle)) {
|
|
4348
|
+
if (orient === 'top' || orient === 'bottom') {
|
|
4349
|
+
return getXAxisLabelAlign(orient, angle);
|
|
4350
|
+
}
|
|
4351
|
+
if (orient === 'left' || orient === 'right') {
|
|
4352
|
+
return getYAxisLabelAlign(orient, angle);
|
|
4353
|
+
}
|
|
4634
4354
|
}
|
|
4635
4355
|
return {
|
|
4636
4356
|
textAlign: this.getTextAlign(vector),
|
|
@@ -4835,29 +4555,9 @@
|
|
|
4835
4555
|
}
|
|
4836
4556
|
}
|
|
4837
4557
|
LineAxis.defaultAttributes = DEFAULT_AXIS_THEME;
|
|
4558
|
+
vutils.mixin(LineAxis, LineAxisMixin);
|
|
4838
4559
|
|
|
4839
|
-
class
|
|
4840
|
-
constructor(attributes) {
|
|
4841
|
-
super(vutils.merge({}, CircleAxis.defaultAttributes, attributes));
|
|
4842
|
-
}
|
|
4843
|
-
renderLine(container) {
|
|
4844
|
-
const { startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE, radius, center, innerRadius = 0, line, inside = false } = this.attribute;
|
|
4845
|
-
let arcRadius = radius;
|
|
4846
|
-
let arcInnerRadius = innerRadius;
|
|
4847
|
-
if (inside && innerRadius > 0) {
|
|
4848
|
-
arcRadius = innerRadius;
|
|
4849
|
-
arcInnerRadius = 0;
|
|
4850
|
-
}
|
|
4851
|
-
const arcAttrs = Object.assign(Object.assign(Object.assign({}, center), { startAngle,
|
|
4852
|
-
endAngle, radius: arcRadius, innerRadius: arcInnerRadius }), line === null || line === void 0 ? void 0 : line.style);
|
|
4853
|
-
const axisLine = vrender.createCircle(arcAttrs);
|
|
4854
|
-
axisLine.name = exports.AXIS_ELEMENT_NAME.line;
|
|
4855
|
-
axisLine.id = this._getNodeId('line');
|
|
4856
|
-
if (!vutils.isEmpty(line === null || line === void 0 ? void 0 : line.state)) {
|
|
4857
|
-
axisLine.states = vutils.merge({}, DEFAULT_STATES$1, line.state);
|
|
4858
|
-
}
|
|
4859
|
-
container.add(axisLine);
|
|
4860
|
-
}
|
|
4560
|
+
class CircleAxisMixin {
|
|
4861
4561
|
isInValidValue(value) {
|
|
4862
4562
|
const { startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE } = this.attribute;
|
|
4863
4563
|
if (Math.abs(endAngle - startAngle) % (Math.PI * 2) === 0) {
|
|
@@ -4880,6 +4580,30 @@
|
|
|
4880
4580
|
const { center } = this.attribute;
|
|
4881
4581
|
return [point.y - center.y, -1 * (point.x - center.x)];
|
|
4882
4582
|
}
|
|
4583
|
+
}
|
|
4584
|
+
|
|
4585
|
+
class CircleAxis extends AxisBase {
|
|
4586
|
+
constructor(attributes) {
|
|
4587
|
+
super(vutils.merge({}, CircleAxis.defaultAttributes, attributes));
|
|
4588
|
+
}
|
|
4589
|
+
renderLine(container) {
|
|
4590
|
+
const { startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE, radius, center, innerRadius = 0, line, inside = false } = this.attribute;
|
|
4591
|
+
let arcRadius = radius;
|
|
4592
|
+
let arcInnerRadius = innerRadius;
|
|
4593
|
+
if (inside && innerRadius > 0) {
|
|
4594
|
+
arcRadius = innerRadius;
|
|
4595
|
+
arcInnerRadius = 0;
|
|
4596
|
+
}
|
|
4597
|
+
const arcAttrs = Object.assign(Object.assign(Object.assign({}, center), { startAngle,
|
|
4598
|
+
endAngle, radius: arcRadius, innerRadius: arcInnerRadius }), line === null || line === void 0 ? void 0 : line.style);
|
|
4599
|
+
const axisLine = vrender.createCircle(arcAttrs);
|
|
4600
|
+
axisLine.name = exports.AXIS_ELEMENT_NAME.line;
|
|
4601
|
+
axisLine.id = this._getNodeId('line');
|
|
4602
|
+
if (!vutils.isEmpty(line === null || line === void 0 ? void 0 : line.state)) {
|
|
4603
|
+
axisLine.states = vutils.merge({}, DEFAULT_STATES$1, line.state);
|
|
4604
|
+
}
|
|
4605
|
+
container.add(axisLine);
|
|
4606
|
+
}
|
|
4883
4607
|
getTitleAttribute() {
|
|
4884
4608
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4885
4609
|
const { center, radius, innerRadius = 0 } = this.attribute;
|
|
@@ -4932,40 +4656,541 @@
|
|
|
4932
4656
|
if (background && background.visible) {
|
|
4933
4657
|
attrs.panel = Object.assign({ visible: true }, background.style);
|
|
4934
4658
|
}
|
|
4935
|
-
return attrs;
|
|
4936
|
-
}
|
|
4937
|
-
getSubTickLineItems() {
|
|
4938
|
-
var _a, _b;
|
|
4939
|
-
const { subTick } = this.attribute;
|
|
4940
|
-
const subTickLineItems = [];
|
|
4941
|
-
const { count: subCount = 4, inside = false, length = 2 } = subTick;
|
|
4942
|
-
const tickLineItems = this.tickLineItems;
|
|
4943
|
-
const tickLineCount = tickLineItems.length;
|
|
4944
|
-
if (tickLineCount >= 2) {
|
|
4945
|
-
const tickSegment = this.data[1].value - this.data[0].value;
|
|
4946
|
-
const isAlignWithLable = (_b = (_a = this.attribute) === null || _a === void 0 ? void 0 : _a.tick) === null || _b === void 0 ? void 0 : _b.alignWithLabel;
|
|
4947
|
-
for (let i = 0; i < tickLineCount; i++) {
|
|
4948
|
-
const pre = tickLineItems[i];
|
|
4949
|
-
const next = tickLineItems[i + 1];
|
|
4950
|
-
for (let j = 0; j < subCount; j++) {
|
|
4951
|
-
const percent = (j + 1) / (subCount + 1);
|
|
4952
|
-
const value = (1 - percent) * pre.value + percent * (next ? next.value : isAlignWithLable ? 1 : pre.value + tickSegment);
|
|
4953
|
-
const point = this.getTickCoord(value);
|
|
4954
|
-
const endPoint = this.getVerticalCoord(point, length, inside);
|
|
4955
|
-
subTickLineItems.push({
|
|
4956
|
-
start: point,
|
|
4957
|
-
end: endPoint,
|
|
4958
|
-
value
|
|
4659
|
+
return attrs;
|
|
4660
|
+
}
|
|
4661
|
+
getSubTickLineItems() {
|
|
4662
|
+
var _a, _b;
|
|
4663
|
+
const { subTick } = this.attribute;
|
|
4664
|
+
const subTickLineItems = [];
|
|
4665
|
+
const { count: subCount = 4, inside = false, length = 2 } = subTick;
|
|
4666
|
+
const tickLineItems = this.tickLineItems;
|
|
4667
|
+
const tickLineCount = tickLineItems.length;
|
|
4668
|
+
if (tickLineCount >= 2) {
|
|
4669
|
+
const tickSegment = this.data[1].value - this.data[0].value;
|
|
4670
|
+
const isAlignWithLable = (_b = (_a = this.attribute) === null || _a === void 0 ? void 0 : _a.tick) === null || _b === void 0 ? void 0 : _b.alignWithLabel;
|
|
4671
|
+
for (let i = 0; i < tickLineCount; i++) {
|
|
4672
|
+
const pre = tickLineItems[i];
|
|
4673
|
+
const next = tickLineItems[i + 1];
|
|
4674
|
+
for (let j = 0; j < subCount; j++) {
|
|
4675
|
+
const percent = (j + 1) / (subCount + 1);
|
|
4676
|
+
const value = (1 - percent) * pre.value + percent * (next ? next.value : isAlignWithLable ? 1 : pre.value + tickSegment);
|
|
4677
|
+
const point = this.getTickCoord(value);
|
|
4678
|
+
const endPoint = this.getVerticalCoord(point, length, inside);
|
|
4679
|
+
subTickLineItems.push({
|
|
4680
|
+
start: point,
|
|
4681
|
+
end: endPoint,
|
|
4682
|
+
value
|
|
4683
|
+
});
|
|
4684
|
+
}
|
|
4685
|
+
}
|
|
4686
|
+
}
|
|
4687
|
+
return subTickLineItems;
|
|
4688
|
+
}
|
|
4689
|
+
getTextBaseline(vector) {
|
|
4690
|
+
let base = 'middle';
|
|
4691
|
+
if (vutils.isNumberClose(vector[1], 0)) {
|
|
4692
|
+
base = 'middle';
|
|
4693
|
+
}
|
|
4694
|
+
else if (vector[1] > 0 && vector[1] > Math.abs(vector[0])) {
|
|
4695
|
+
base = 'top';
|
|
4696
|
+
}
|
|
4697
|
+
else if (vector[1] < 0 && Math.abs(vector[1]) > Math.abs(vector[0])) {
|
|
4698
|
+
base = 'bottom';
|
|
4699
|
+
}
|
|
4700
|
+
return base;
|
|
4701
|
+
}
|
|
4702
|
+
beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
4703
|
+
return;
|
|
4704
|
+
}
|
|
4705
|
+
handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
4706
|
+
return;
|
|
4707
|
+
}
|
|
4708
|
+
afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
4709
|
+
return;
|
|
4710
|
+
}
|
|
4711
|
+
getLabelAlign(vector, inside, angle) {
|
|
4712
|
+
return {
|
|
4713
|
+
textAlign: this.getTextAlign(vector),
|
|
4714
|
+
textBaseline: this.getTextBaseline(vector)
|
|
4715
|
+
};
|
|
4716
|
+
}
|
|
4717
|
+
}
|
|
4718
|
+
CircleAxis.defaultAttributes = DEFAULT_AXIS_THEME;
|
|
4719
|
+
vutils.mixin(CircleAxis, CircleAxisMixin);
|
|
4720
|
+
|
|
4721
|
+
function getElMap(g) {
|
|
4722
|
+
const elMap = {};
|
|
4723
|
+
traverseGroup(g, (el) => {
|
|
4724
|
+
if (el.type !== 'group' && el.id) {
|
|
4725
|
+
elMap[el.id] = el;
|
|
4726
|
+
}
|
|
4727
|
+
});
|
|
4728
|
+
return elMap;
|
|
4729
|
+
}
|
|
4730
|
+
class GroupTransition extends vrender.ACustomAnimate {
|
|
4731
|
+
constructor() {
|
|
4732
|
+
super(...arguments);
|
|
4733
|
+
this.mode = vrender.AnimateMode.NORMAL;
|
|
4734
|
+
}
|
|
4735
|
+
onBind() {
|
|
4736
|
+
const currentInnerView = this.target.getInnerView();
|
|
4737
|
+
const prevInnerView = this.target.getPrevInnerView();
|
|
4738
|
+
if (!prevInnerView) {
|
|
4739
|
+
return;
|
|
4740
|
+
}
|
|
4741
|
+
this._oldElementMap = getElMap(prevInnerView);
|
|
4742
|
+
this._newElementAttrMap = {};
|
|
4743
|
+
traverseGroup(currentInnerView, (el) => {
|
|
4744
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4745
|
+
if (el.type !== 'group' && el.id) {
|
|
4746
|
+
const oldEl = this._oldElementMap[el.id];
|
|
4747
|
+
if (oldEl) {
|
|
4748
|
+
if (!vutils.isEqual(el.attribute, oldEl.attribute)) {
|
|
4749
|
+
const newProps = vutils.cloneDeep(el.attribute);
|
|
4750
|
+
this._newElementAttrMap[el.id] = {
|
|
4751
|
+
state: 'update',
|
|
4752
|
+
node: el,
|
|
4753
|
+
attrs: Object.assign(Object.assign({}, newProps), { opacity: (_a = newProps.opacity) !== null && _a !== void 0 ? _a : 1, fillOpacity: (_b = newProps.fillOpacity) !== null && _b !== void 0 ? _b : 1, strokeOpacity: (_c = newProps.strokeOpacity) !== null && _c !== void 0 ? _c : 1 })
|
|
4754
|
+
};
|
|
4755
|
+
el.setAttributes(oldEl.attribute);
|
|
4756
|
+
}
|
|
4757
|
+
}
|
|
4758
|
+
else {
|
|
4759
|
+
const finalOpacityAttrs = {
|
|
4760
|
+
opacity: (_d = el.attribute.opacity) !== null && _d !== void 0 ? _d : 1,
|
|
4761
|
+
fillOpacity: (_e = el.attribute.fillOpacity) !== null && _e !== void 0 ? _e : 1,
|
|
4762
|
+
strokeOpacity: (_f = el.attribute.strokeOpacity) !== null && _f !== void 0 ? _f : 1
|
|
4763
|
+
};
|
|
4764
|
+
this._newElementAttrMap[el.id] = {
|
|
4765
|
+
state: 'enter',
|
|
4766
|
+
node: el,
|
|
4767
|
+
attrs: finalOpacityAttrs
|
|
4768
|
+
};
|
|
4769
|
+
el.setAttributes({
|
|
4770
|
+
opacity: 0,
|
|
4771
|
+
fillOpacity: 0,
|
|
4772
|
+
strokeOpacity: 0
|
|
4773
|
+
});
|
|
4774
|
+
}
|
|
4775
|
+
}
|
|
4776
|
+
});
|
|
4777
|
+
}
|
|
4778
|
+
onStart() {
|
|
4779
|
+
let duration = this.duration;
|
|
4780
|
+
let easing = this.easing;
|
|
4781
|
+
Object.keys(this._newElementAttrMap).forEach(id => {
|
|
4782
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4783
|
+
const { node, attrs, state } = this._newElementAttrMap[id];
|
|
4784
|
+
if (state === 'enter') {
|
|
4785
|
+
duration = vutils.isValidNumber((_b = (_a = this.params) === null || _a === void 0 ? void 0 : _a.enter) === null || _b === void 0 ? void 0 : _b.duration) ? (_c = this.params) === null || _c === void 0 ? void 0 : _c.enter.duration : duration;
|
|
4786
|
+
easing = ((_e = (_d = this.params) === null || _d === void 0 ? void 0 : _d.enter) === null || _e === void 0 ? void 0 : _e.easing) ? (_g = (_f = this.params) === null || _f === void 0 ? void 0 : _f.enter) === null || _g === void 0 ? void 0 : _g.easing : easing;
|
|
4787
|
+
}
|
|
4788
|
+
if (node.type === 'path') {
|
|
4789
|
+
node
|
|
4790
|
+
.animate({
|
|
4791
|
+
interpolate(key, ratio, from, to, nextAttributes) {
|
|
4792
|
+
if (key === 'path') {
|
|
4793
|
+
nextAttributes.path = vutils.interpolateString(from, to)(ratio);
|
|
4794
|
+
return true;
|
|
4795
|
+
}
|
|
4796
|
+
return false;
|
|
4797
|
+
}
|
|
4798
|
+
})
|
|
4799
|
+
.to(attrs, duration, easing);
|
|
4800
|
+
}
|
|
4801
|
+
else {
|
|
4802
|
+
node
|
|
4803
|
+
.animate()
|
|
4804
|
+
.to(attrs, duration, easing);
|
|
4805
|
+
}
|
|
4806
|
+
});
|
|
4807
|
+
}
|
|
4808
|
+
onUpdate(end, ratio, out) {
|
|
4809
|
+
}
|
|
4810
|
+
}
|
|
4811
|
+
|
|
4812
|
+
class GroupFadeIn extends vrender.ACustomAnimate {
|
|
4813
|
+
constructor(from, to, duration, easing) {
|
|
4814
|
+
super(null, null, duration, easing);
|
|
4815
|
+
}
|
|
4816
|
+
getEndProps() {
|
|
4817
|
+
return {};
|
|
4818
|
+
}
|
|
4819
|
+
onBind() {
|
|
4820
|
+
this.target.setTheme({
|
|
4821
|
+
common: {
|
|
4822
|
+
opacity: 0
|
|
4823
|
+
}
|
|
4824
|
+
});
|
|
4825
|
+
return;
|
|
4826
|
+
}
|
|
4827
|
+
onEnd() {
|
|
4828
|
+
this.target.setTheme({
|
|
4829
|
+
common: {
|
|
4830
|
+
opacity: 1
|
|
4831
|
+
}
|
|
4832
|
+
});
|
|
4833
|
+
return;
|
|
4834
|
+
}
|
|
4835
|
+
onUpdate(end, ratio, out) {
|
|
4836
|
+
this.target.setTheme({
|
|
4837
|
+
common: {
|
|
4838
|
+
opacity: ratio
|
|
4839
|
+
}
|
|
4840
|
+
});
|
|
4841
|
+
}
|
|
4842
|
+
}
|
|
4843
|
+
class GroupFadeOut extends vrender.ACustomAnimate {
|
|
4844
|
+
constructor(from, to, duration, easing) {
|
|
4845
|
+
super(null, null, duration, easing);
|
|
4846
|
+
}
|
|
4847
|
+
getEndProps() {
|
|
4848
|
+
return {};
|
|
4849
|
+
}
|
|
4850
|
+
onBind() {
|
|
4851
|
+
this.target.setTheme({
|
|
4852
|
+
common: {
|
|
4853
|
+
opacity: 1
|
|
4854
|
+
}
|
|
4855
|
+
});
|
|
4856
|
+
return;
|
|
4857
|
+
}
|
|
4858
|
+
onEnd() {
|
|
4859
|
+
this.target.setTheme({
|
|
4860
|
+
common: {
|
|
4861
|
+
opacity: 0
|
|
4862
|
+
}
|
|
4863
|
+
});
|
|
4864
|
+
return;
|
|
4865
|
+
}
|
|
4866
|
+
onUpdate(end, ratio, out) {
|
|
4867
|
+
this.target.setTheme({
|
|
4868
|
+
common: {
|
|
4869
|
+
opacity: 1 - ratio
|
|
4870
|
+
}
|
|
4871
|
+
});
|
|
4872
|
+
}
|
|
4873
|
+
}
|
|
4874
|
+
|
|
4875
|
+
function getLinePath(points, closed) {
|
|
4876
|
+
let path = '';
|
|
4877
|
+
if (points.length === 0) {
|
|
4878
|
+
return path;
|
|
4879
|
+
}
|
|
4880
|
+
points.forEach((point, index) => {
|
|
4881
|
+
if (index === 0) {
|
|
4882
|
+
path = `M${point.x},${point.y}`;
|
|
4883
|
+
}
|
|
4884
|
+
else {
|
|
4885
|
+
path += `L${point.x},${point.y}`;
|
|
4886
|
+
}
|
|
4887
|
+
});
|
|
4888
|
+
if (closed) {
|
|
4889
|
+
path += 'Z';
|
|
4890
|
+
}
|
|
4891
|
+
return path;
|
|
4892
|
+
}
|
|
4893
|
+
function getArcPath(center, points, reverse, closed) {
|
|
4894
|
+
let path = '';
|
|
4895
|
+
if (!center || points.length === 0) {
|
|
4896
|
+
return path;
|
|
4897
|
+
}
|
|
4898
|
+
const firstPoint = points[0];
|
|
4899
|
+
const radius = vutils.PointService.distancePP(center, firstPoint);
|
|
4900
|
+
const sweepFlag = reverse ? 0 : 1;
|
|
4901
|
+
if (closed) {
|
|
4902
|
+
path += `M${center.x},${center.y - radius}A${radius},${radius},0,0,${sweepFlag},${center.x},${center.y + radius}A${radius},${radius},0,0,${sweepFlag},${center.x},${center.y - radius}Z`;
|
|
4903
|
+
}
|
|
4904
|
+
else {
|
|
4905
|
+
points.forEach((point, index) => {
|
|
4906
|
+
if (index === 0) {
|
|
4907
|
+
path = `M${point.x},${point.y}`;
|
|
4908
|
+
}
|
|
4909
|
+
else {
|
|
4910
|
+
path += `A${radius},${radius},0,0,${sweepFlag},${point.x},${point.y}`;
|
|
4911
|
+
}
|
|
4912
|
+
});
|
|
4913
|
+
}
|
|
4914
|
+
return path;
|
|
4915
|
+
}
|
|
4916
|
+
function getRegionPath(from, to, attribute) {
|
|
4917
|
+
const { type, closed } = attribute;
|
|
4918
|
+
const reversePoints = to.slice(0).reverse();
|
|
4919
|
+
let regionPath = '';
|
|
4920
|
+
let nextPath = '';
|
|
4921
|
+
if (type === 'line' && attribute.smoothLink && attribute.center) {
|
|
4922
|
+
const fromStart = from[0];
|
|
4923
|
+
const toEnd = reversePoints[0];
|
|
4924
|
+
const center = attribute.center;
|
|
4925
|
+
regionPath = getLinePath(from, !!closed);
|
|
4926
|
+
nextPath = getLinePath(reversePoints, !!closed);
|
|
4927
|
+
const toEndRadius = vutils.PointService.distancePP(toEnd, center);
|
|
4928
|
+
const fromStartRadius = vutils.PointService.distancePP(fromStart, center);
|
|
4929
|
+
regionPath += `A${toEndRadius},${toEndRadius},0,0,1,${toEnd.x},${toEnd.y}L${toEnd.x},${toEnd.y}`;
|
|
4930
|
+
nextPath += `A${fromStartRadius},${fromStartRadius},0,0,0,${fromStart.x},${fromStart.y}`;
|
|
4931
|
+
}
|
|
4932
|
+
else if (type === 'circle') {
|
|
4933
|
+
const { center } = attribute;
|
|
4934
|
+
regionPath = getArcPath(center, from, false, !!closed);
|
|
4935
|
+
nextPath = getArcPath(center, reversePoints, true, !!closed);
|
|
4936
|
+
}
|
|
4937
|
+
else if (type === 'line' || type === 'polygon') {
|
|
4938
|
+
regionPath = getLinePath(from, !!closed);
|
|
4939
|
+
nextPath = getLinePath(reversePoints, !!closed);
|
|
4940
|
+
}
|
|
4941
|
+
if (closed) {
|
|
4942
|
+
regionPath += nextPath;
|
|
4943
|
+
}
|
|
4944
|
+
else {
|
|
4945
|
+
nextPath = 'L' + nextPath.substring(1);
|
|
4946
|
+
regionPath += nextPath;
|
|
4947
|
+
regionPath += 'Z';
|
|
4948
|
+
}
|
|
4949
|
+
return regionPath;
|
|
4950
|
+
}
|
|
4951
|
+
class BaseGrid extends AbstractComponent {
|
|
4952
|
+
constructor() {
|
|
4953
|
+
super(...arguments);
|
|
4954
|
+
this.name = 'axis-grid';
|
|
4955
|
+
this.data = [];
|
|
4956
|
+
}
|
|
4957
|
+
getInnerView() {
|
|
4958
|
+
return this._innerView;
|
|
4959
|
+
}
|
|
4960
|
+
getPrevInnerView() {
|
|
4961
|
+
return this._prevInnerView;
|
|
4962
|
+
}
|
|
4963
|
+
render() {
|
|
4964
|
+
this.removeAllChild();
|
|
4965
|
+
this._prevInnerView = this._innerView;
|
|
4966
|
+
this._innerView = vrender.createGroup({ x: 0, y: 0, pickable: false });
|
|
4967
|
+
this.add(this._innerView);
|
|
4968
|
+
const { items, visible } = this.attribute;
|
|
4969
|
+
if (items && items.length && visible !== false) {
|
|
4970
|
+
this.data = this._transformItems(items);
|
|
4971
|
+
this._renderGrid(this._innerView);
|
|
4972
|
+
}
|
|
4973
|
+
}
|
|
4974
|
+
getVerticalCoord(point, offset, inside) {
|
|
4975
|
+
const vector = this.getVerticalVector(offset, inside, point);
|
|
4976
|
+
return {
|
|
4977
|
+
x: point.x + vector[0],
|
|
4978
|
+
y: point.y + vector[1]
|
|
4979
|
+
};
|
|
4980
|
+
}
|
|
4981
|
+
_transformItems(items) {
|
|
4982
|
+
const data = [];
|
|
4983
|
+
items.forEach((item) => {
|
|
4984
|
+
var _a;
|
|
4985
|
+
data.push(Object.assign(Object.assign({}, item), { point: this.getTickCoord(item.value), id: (_a = item.id) !== null && _a !== void 0 ? _a : item.label }));
|
|
4986
|
+
});
|
|
4987
|
+
return data;
|
|
4988
|
+
}
|
|
4989
|
+
_renderGrid(container) {
|
|
4990
|
+
const { visible } = this.attribute.subGrid || {};
|
|
4991
|
+
if (visible) {
|
|
4992
|
+
this._renderGridByType(true, container);
|
|
4993
|
+
}
|
|
4994
|
+
this._renderGridByType(false, container);
|
|
4995
|
+
}
|
|
4996
|
+
_renderGridByType(isSubGrid, container) {
|
|
4997
|
+
const gridAttrs = vutils.merge({}, this.attribute, this.getGridAttribute(isSubGrid));
|
|
4998
|
+
const { type, items, style, closed, alternateColor, depth = 0 } = gridAttrs;
|
|
4999
|
+
const name = isSubGrid ? `${exports.AXIS_ELEMENT_NAME.grid}-sub` : `${exports.AXIS_ELEMENT_NAME.grid}`;
|
|
5000
|
+
items.forEach((item, index) => {
|
|
5001
|
+
const { id, points } = item;
|
|
5002
|
+
let path = '';
|
|
5003
|
+
if (type === 'line' || type === 'polygon') {
|
|
5004
|
+
path = getLinePath(points, !!closed);
|
|
5005
|
+
}
|
|
5006
|
+
else if (type === 'circle') {
|
|
5007
|
+
const { center } = this.attribute;
|
|
5008
|
+
path = getArcPath(center, points, false, !!closed);
|
|
5009
|
+
}
|
|
5010
|
+
const shape = vrender.createPath(Object.assign({ path, z: depth }, (vutils.isFunction(style) ? vutils.merge({}, BaseGrid.defaultAttributes.style, style(item, index)) : style)));
|
|
5011
|
+
shape.name = `${name}-line`;
|
|
5012
|
+
shape.id = this._getNodeId(`${name}-path-${id}`);
|
|
5013
|
+
container.add(shape);
|
|
5014
|
+
});
|
|
5015
|
+
if (depth && type === 'line') {
|
|
5016
|
+
items.forEach((item, index) => {
|
|
5017
|
+
const { id, points } = item;
|
|
5018
|
+
const nextPoints = [];
|
|
5019
|
+
nextPoints.push(points[0]);
|
|
5020
|
+
const dir = { x: points[1].x - points[0].x, y: points[1].y - points[0].y };
|
|
5021
|
+
const dirLen = Math.sqrt(dir.x * dir.x + dir.y * dir.y);
|
|
5022
|
+
const ratio = depth / dirLen;
|
|
5023
|
+
nextPoints.push({ x: points[0].x + dir.x * ratio, y: points[0].y + dir.y * ratio });
|
|
5024
|
+
const path = getLinePath(nextPoints, !!closed);
|
|
5025
|
+
const deltaX = vutils.abs(nextPoints[0].x - nextPoints[1].x);
|
|
5026
|
+
const deltaY = vutils.abs(nextPoints[0].y - nextPoints[1].y);
|
|
5027
|
+
const shape = vrender.createPath(Object.assign({ path, z: 0, alpha: deltaX > deltaY ? ((points[1].x - points[0].x > 0 ? -1 : 1) * vutils.pi) / 2 : 0, beta: deltaX < deltaY ? -vutils.pi / 2 : 0, anchor3d: deltaX > deltaY ? [nextPoints[0].x, 0] : [0, nextPoints[0].y] }, (vutils.isFunction(style) ? vutils.merge({}, BaseGrid.defaultAttributes.style, style(item, index)) : style)));
|
|
5028
|
+
shape.name = `${name}-line`;
|
|
5029
|
+
shape.id = this._getNodeId(`${name}-path-${id}`);
|
|
5030
|
+
container.add(shape);
|
|
5031
|
+
});
|
|
5032
|
+
}
|
|
5033
|
+
if (items.length > 1 && alternateColor) {
|
|
5034
|
+
const colors = vutils.isArray(alternateColor)
|
|
5035
|
+
? alternateColor
|
|
5036
|
+
: [alternateColor, 'transparent'];
|
|
5037
|
+
const getColor = (index) => colors[index % colors.length];
|
|
5038
|
+
for (let index = 0; index < items.length - 1; index++) {
|
|
5039
|
+
const [prev, curr] = [items[index].points, items[index + 1].points];
|
|
5040
|
+
const path = getRegionPath(prev, curr, gridAttrs);
|
|
5041
|
+
const shape = vrender.createPath({
|
|
5042
|
+
path,
|
|
5043
|
+
fill: getColor(index)
|
|
5044
|
+
});
|
|
5045
|
+
shape.name = `${name}-region`;
|
|
5046
|
+
shape.id = this._getNodeId(`${name}-region-${index}`);
|
|
5047
|
+
container.add(shape);
|
|
5048
|
+
}
|
|
5049
|
+
}
|
|
5050
|
+
}
|
|
5051
|
+
_getNodeId(id) {
|
|
5052
|
+
return `${this.id}-${id}`;
|
|
5053
|
+
}
|
|
5054
|
+
}
|
|
5055
|
+
BaseGrid.defaultAttributes = {
|
|
5056
|
+
style: {
|
|
5057
|
+
lineWidth: 1,
|
|
5058
|
+
stroke: '#999',
|
|
5059
|
+
strokeOpacity: 1,
|
|
5060
|
+
lineDash: [4, 4]
|
|
5061
|
+
},
|
|
5062
|
+
subGrid: {
|
|
5063
|
+
visible: false,
|
|
5064
|
+
style: {
|
|
5065
|
+
lineWidth: 1,
|
|
5066
|
+
stroke: '#999',
|
|
5067
|
+
strokeOpacity: 1,
|
|
5068
|
+
lineDash: [4, 4]
|
|
5069
|
+
}
|
|
5070
|
+
}
|
|
5071
|
+
};
|
|
5072
|
+
|
|
5073
|
+
function getCirclePoints(center, count, radius, startAngle, endAngle) {
|
|
5074
|
+
const points = [];
|
|
5075
|
+
const range = endAngle - startAngle;
|
|
5076
|
+
for (let i = 0; i < count; i++) {
|
|
5077
|
+
const angle = startAngle + (i * range) / count;
|
|
5078
|
+
points.push(vutils.polarToCartesian(center, radius, angle));
|
|
5079
|
+
}
|
|
5080
|
+
return points;
|
|
5081
|
+
}
|
|
5082
|
+
class LineAxisGrid extends BaseGrid {
|
|
5083
|
+
constructor(attributes, mode) {
|
|
5084
|
+
super(vutils.merge({}, BaseGrid.defaultAttributes, attributes), mode);
|
|
5085
|
+
if (mode === '3d') {
|
|
5086
|
+
this.setMode(mode);
|
|
5087
|
+
}
|
|
5088
|
+
}
|
|
5089
|
+
_getGridPoint(gridType, point) {
|
|
5090
|
+
let gridPoints;
|
|
5091
|
+
if (gridType === 'line') {
|
|
5092
|
+
const { length } = this.attribute;
|
|
5093
|
+
const endPoint = this.getVerticalCoord(point, length, true);
|
|
5094
|
+
gridPoints = [point, endPoint];
|
|
5095
|
+
}
|
|
5096
|
+
else if (gridType === 'circle' || gridType === 'polygon') {
|
|
5097
|
+
const { center, sides = 6, startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE } = this.attribute;
|
|
5098
|
+
const distance = vutils.PointService.distancePP(center, point);
|
|
5099
|
+
gridPoints = getCirclePoints(center, sides, distance, startAngle, endAngle);
|
|
5100
|
+
}
|
|
5101
|
+
return gridPoints;
|
|
5102
|
+
}
|
|
5103
|
+
getGridAttribute(isSubGrid) {
|
|
5104
|
+
const { type: gridType, alignWithLabel = true } = this.attribute;
|
|
5105
|
+
let tickSegment = 1;
|
|
5106
|
+
const count = this.data.length;
|
|
5107
|
+
if (count >= 2) {
|
|
5108
|
+
tickSegment = this.data[1].value - this.data[0].value;
|
|
5109
|
+
}
|
|
5110
|
+
let gridAttribute;
|
|
5111
|
+
let items = [];
|
|
5112
|
+
if (!isSubGrid) {
|
|
5113
|
+
gridAttribute = this.attribute;
|
|
5114
|
+
const gridItems = [];
|
|
5115
|
+
this.data.forEach(item => {
|
|
5116
|
+
let { point } = item;
|
|
5117
|
+
if (!alignWithLabel) {
|
|
5118
|
+
const value = item.value - tickSegment / 2;
|
|
5119
|
+
if (this.isInValidValue(value)) {
|
|
5120
|
+
return;
|
|
5121
|
+
}
|
|
5122
|
+
point = this.getTickCoord(value);
|
|
5123
|
+
}
|
|
5124
|
+
gridItems.push({
|
|
5125
|
+
id: item.label,
|
|
5126
|
+
datum: item,
|
|
5127
|
+
points: this._getGridPoint(gridType, point)
|
|
5128
|
+
});
|
|
5129
|
+
});
|
|
5130
|
+
items = gridItems;
|
|
5131
|
+
}
|
|
5132
|
+
else {
|
|
5133
|
+
gridAttribute = vutils.merge({}, this.attribute, this.attribute.subGrid);
|
|
5134
|
+
const subGridItems = [];
|
|
5135
|
+
const { count: subCount = 4 } = this.attribute.subGrid || {};
|
|
5136
|
+
const tickLineCount = this.data.length;
|
|
5137
|
+
if (tickLineCount >= 2) {
|
|
5138
|
+
const points = [];
|
|
5139
|
+
this.data.forEach((item) => {
|
|
5140
|
+
let tickValue = item.value;
|
|
5141
|
+
if (!alignWithLabel) {
|
|
5142
|
+
const value = item.value - tickSegment / 2;
|
|
5143
|
+
if (this.isInValidValue(value)) {
|
|
5144
|
+
return;
|
|
5145
|
+
}
|
|
5146
|
+
tickValue = value;
|
|
5147
|
+
}
|
|
5148
|
+
points.push({
|
|
5149
|
+
value: tickValue
|
|
5150
|
+
});
|
|
5151
|
+
});
|
|
5152
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
5153
|
+
const pre = points[i];
|
|
5154
|
+
const next = points[i + 1];
|
|
5155
|
+
subGridItems.push({
|
|
5156
|
+
id: `sub-${i}-0`,
|
|
5157
|
+
points: this._getGridPoint(gridType, this.getTickCoord(pre.value)),
|
|
5158
|
+
datum: {}
|
|
4959
5159
|
});
|
|
5160
|
+
for (let j = 0; j < subCount; j++) {
|
|
5161
|
+
const percent = (j + 1) / (subCount + 1);
|
|
5162
|
+
const value = (1 - percent) * pre.value + percent * next.value;
|
|
5163
|
+
const point = this.getTickCoord(value);
|
|
5164
|
+
subGridItems.push({
|
|
5165
|
+
id: `sub-${i}-${j + 1}`,
|
|
5166
|
+
points: this._getGridPoint(gridType, point),
|
|
5167
|
+
datum: {}
|
|
5168
|
+
});
|
|
5169
|
+
}
|
|
5170
|
+
if (i === points.length - 2) {
|
|
5171
|
+
subGridItems.push({
|
|
5172
|
+
id: `sub-${i}-${subCount + 1}`,
|
|
5173
|
+
points: this._getGridPoint(gridType, this.getTickCoord(next.value)),
|
|
5174
|
+
datum: {}
|
|
5175
|
+
});
|
|
5176
|
+
}
|
|
4960
5177
|
}
|
|
5178
|
+
items = subGridItems;
|
|
4961
5179
|
}
|
|
4962
5180
|
}
|
|
4963
|
-
return
|
|
5181
|
+
return Object.assign(Object.assign({}, gridAttribute), { items });
|
|
5182
|
+
}
|
|
5183
|
+
}
|
|
5184
|
+
vutils.mixin(LineAxisGrid, LineAxisMixin);
|
|
5185
|
+
|
|
5186
|
+
class CircleAxisGrid extends BaseGrid {
|
|
5187
|
+
constructor(attributes) {
|
|
5188
|
+
super(vutils.merge({}, BaseGrid.defaultAttributes, attributes));
|
|
4964
5189
|
}
|
|
4965
|
-
getGridAttribute(
|
|
5190
|
+
getGridAttribute(isSubGrid) {
|
|
4966
5191
|
let gridAttribute;
|
|
4967
5192
|
let items = [];
|
|
4968
|
-
const { radius, innerRadius = 0, startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE, center,
|
|
5193
|
+
const _a = this.attribute, { radius, innerRadius = 0, startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE, center, subGrid } = _a, grid = __rest(_a, ["radius", "innerRadius", "startAngle", "endAngle", "center", "subGrid"]);
|
|
4969
5194
|
const { alignWithLabel = true } = grid || {};
|
|
4970
5195
|
const length = radius - innerRadius;
|
|
4971
5196
|
let tickSegment = 1;
|
|
@@ -4973,8 +5198,8 @@
|
|
|
4973
5198
|
if (count >= 2) {
|
|
4974
5199
|
tickSegment = this.data[1].value - this.data[0].value;
|
|
4975
5200
|
}
|
|
4976
|
-
if (
|
|
4977
|
-
gridAttribute =
|
|
5201
|
+
if (!isSubGrid) {
|
|
5202
|
+
gridAttribute = grid;
|
|
4978
5203
|
const gridItems = [];
|
|
4979
5204
|
let data;
|
|
4980
5205
|
if (Math.abs(endAngle - startAngle) % (Math.PI * 2) === 0) {
|
|
@@ -5002,9 +5227,9 @@
|
|
|
5002
5227
|
items = gridItems;
|
|
5003
5228
|
}
|
|
5004
5229
|
else {
|
|
5005
|
-
gridAttribute = vutils.merge({},
|
|
5230
|
+
gridAttribute = vutils.merge({}, grid, subGrid);
|
|
5006
5231
|
const subGridItems = [];
|
|
5007
|
-
const { count: subCount = 4 } =
|
|
5232
|
+
const { count: subCount = 4 } = subGrid || {};
|
|
5008
5233
|
const tickLineCount = this.data.length;
|
|
5009
5234
|
if (tickLineCount >= 2) {
|
|
5010
5235
|
const points = [];
|
|
@@ -5048,192 +5273,10 @@
|
|
|
5048
5273
|
}
|
|
5049
5274
|
}
|
|
5050
5275
|
return Object.assign(Object.assign({}, gridAttribute), { items,
|
|
5051
|
-
center });
|
|
5052
|
-
}
|
|
5053
|
-
getTextBaseline(vector) {
|
|
5054
|
-
let base = 'middle';
|
|
5055
|
-
if (vutils.isNumberClose(vector[1], 0)) {
|
|
5056
|
-
base = 'middle';
|
|
5057
|
-
}
|
|
5058
|
-
else if (vector[1] > 0 && vector[1] > Math.abs(vector[0])) {
|
|
5059
|
-
base = 'top';
|
|
5060
|
-
}
|
|
5061
|
-
else if (vector[1] < 0 && Math.abs(vector[1]) > Math.abs(vector[0])) {
|
|
5062
|
-
base = 'bottom';
|
|
5063
|
-
}
|
|
5064
|
-
return base;
|
|
5065
|
-
}
|
|
5066
|
-
beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
5067
|
-
return;
|
|
5068
|
-
}
|
|
5069
|
-
handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
5070
|
-
return;
|
|
5071
|
-
}
|
|
5072
|
-
afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
5073
|
-
return;
|
|
5074
|
-
}
|
|
5075
|
-
getLabelAlign(vector, inside, angle) {
|
|
5076
|
-
return {
|
|
5077
|
-
textAlign: this.getTextAlign(vector),
|
|
5078
|
-
textBaseline: this.getTextBaseline(vector)
|
|
5079
|
-
};
|
|
5080
|
-
}
|
|
5081
|
-
}
|
|
5082
|
-
CircleAxis.defaultAttributes = DEFAULT_AXIS_THEME;
|
|
5083
|
-
|
|
5084
|
-
function getElMap(g) {
|
|
5085
|
-
const elMap = {};
|
|
5086
|
-
traverseGroup(g, (el) => {
|
|
5087
|
-
if (el.type !== 'group' && el.id) {
|
|
5088
|
-
elMap[el.id] = el;
|
|
5089
|
-
}
|
|
5090
|
-
});
|
|
5091
|
-
return elMap;
|
|
5092
|
-
}
|
|
5093
|
-
class GroupTransition extends vrender.ACustomAnimate {
|
|
5094
|
-
constructor() {
|
|
5095
|
-
super(...arguments);
|
|
5096
|
-
this.mode = vrender.AnimateMode.NORMAL;
|
|
5097
|
-
}
|
|
5098
|
-
onBind() {
|
|
5099
|
-
const currentInnerView = this.target.getInnerView();
|
|
5100
|
-
const prevInnerView = this.target.getPrevInnerView();
|
|
5101
|
-
if (!prevInnerView) {
|
|
5102
|
-
return;
|
|
5103
|
-
}
|
|
5104
|
-
this._oldElementMap = getElMap(prevInnerView);
|
|
5105
|
-
this._newElementAttrMap = {};
|
|
5106
|
-
traverseGroup(currentInnerView, (el) => {
|
|
5107
|
-
var _a, _b, _c, _d, _e, _f;
|
|
5108
|
-
if (el.type !== 'group' && el.id) {
|
|
5109
|
-
const oldEl = this._oldElementMap[el.id];
|
|
5110
|
-
if (oldEl) {
|
|
5111
|
-
if (!vutils.isEqual(el.attribute, oldEl.attribute)) {
|
|
5112
|
-
const newProps = vutils.cloneDeep(el.attribute);
|
|
5113
|
-
this._newElementAttrMap[el.id] = {
|
|
5114
|
-
state: 'update',
|
|
5115
|
-
node: el,
|
|
5116
|
-
attrs: Object.assign(Object.assign({}, newProps), { opacity: (_a = newProps.opacity) !== null && _a !== void 0 ? _a : 1, fillOpacity: (_b = newProps.fillOpacity) !== null && _b !== void 0 ? _b : 1, strokeOpacity: (_c = newProps.strokeOpacity) !== null && _c !== void 0 ? _c : 1 })
|
|
5117
|
-
};
|
|
5118
|
-
el.setAttributes(oldEl.attribute);
|
|
5119
|
-
}
|
|
5120
|
-
}
|
|
5121
|
-
else {
|
|
5122
|
-
const finalOpacityAttrs = {
|
|
5123
|
-
opacity: (_d = el.attribute.opacity) !== null && _d !== void 0 ? _d : 1,
|
|
5124
|
-
fillOpacity: (_e = el.attribute.fillOpacity) !== null && _e !== void 0 ? _e : 1,
|
|
5125
|
-
strokeOpacity: (_f = el.attribute.strokeOpacity) !== null && _f !== void 0 ? _f : 1
|
|
5126
|
-
};
|
|
5127
|
-
this._newElementAttrMap[el.id] = {
|
|
5128
|
-
state: 'enter',
|
|
5129
|
-
node: el,
|
|
5130
|
-
attrs: finalOpacityAttrs
|
|
5131
|
-
};
|
|
5132
|
-
el.setAttributes({
|
|
5133
|
-
opacity: 0,
|
|
5134
|
-
fillOpacity: 0,
|
|
5135
|
-
strokeOpacity: 0
|
|
5136
|
-
});
|
|
5137
|
-
}
|
|
5138
|
-
}
|
|
5139
|
-
});
|
|
5140
|
-
}
|
|
5141
|
-
onStart() {
|
|
5142
|
-
let duration = this.duration;
|
|
5143
|
-
let easing = this.easing;
|
|
5144
|
-
Object.keys(this._newElementAttrMap).forEach(id => {
|
|
5145
|
-
var _a, _b, _c;
|
|
5146
|
-
const { node, attrs, state } = this._newElementAttrMap[id];
|
|
5147
|
-
if (state === 'enter') {
|
|
5148
|
-
duration = vutils.isValidNumber((_a = this.params.enter) === null || _a === void 0 ? void 0 : _a.duration) ? this.params.enter.duration : duration;
|
|
5149
|
-
easing = ((_b = this.params.enter) === null || _b === void 0 ? void 0 : _b.easing) ? (_c = this.params.enter) === null || _c === void 0 ? void 0 : _c.easing : easing;
|
|
5150
|
-
}
|
|
5151
|
-
if (node.type === 'path') {
|
|
5152
|
-
node
|
|
5153
|
-
.animate({
|
|
5154
|
-
interpolate(key, ratio, from, to, nextAttributes) {
|
|
5155
|
-
if (key === 'path') {
|
|
5156
|
-
nextAttributes.path = vutils.interpolateString(from, to)(ratio);
|
|
5157
|
-
return true;
|
|
5158
|
-
}
|
|
5159
|
-
return false;
|
|
5160
|
-
}
|
|
5161
|
-
})
|
|
5162
|
-
.to(attrs, duration, easing);
|
|
5163
|
-
}
|
|
5164
|
-
else {
|
|
5165
|
-
node
|
|
5166
|
-
.animate()
|
|
5167
|
-
.to(attrs, duration, easing);
|
|
5168
|
-
}
|
|
5169
|
-
});
|
|
5170
|
-
}
|
|
5171
|
-
onUpdate(end, ratio, out) {
|
|
5172
|
-
}
|
|
5173
|
-
}
|
|
5174
|
-
|
|
5175
|
-
class GroupFadeIn extends vrender.ACustomAnimate {
|
|
5176
|
-
constructor(from, to, duration, easing) {
|
|
5177
|
-
super(null, null, duration, easing);
|
|
5178
|
-
}
|
|
5179
|
-
getEndProps() {
|
|
5180
|
-
return {};
|
|
5181
|
-
}
|
|
5182
|
-
onBind() {
|
|
5183
|
-
this.target.setTheme({
|
|
5184
|
-
common: {
|
|
5185
|
-
opacity: 0
|
|
5186
|
-
}
|
|
5187
|
-
});
|
|
5188
|
-
return;
|
|
5189
|
-
}
|
|
5190
|
-
onEnd() {
|
|
5191
|
-
this.target.setTheme({
|
|
5192
|
-
common: {
|
|
5193
|
-
opacity: 1
|
|
5194
|
-
}
|
|
5195
|
-
});
|
|
5196
|
-
return;
|
|
5197
|
-
}
|
|
5198
|
-
onUpdate(end, ratio, out) {
|
|
5199
|
-
this.target.setTheme({
|
|
5200
|
-
common: {
|
|
5201
|
-
opacity: ratio
|
|
5202
|
-
}
|
|
5203
|
-
});
|
|
5204
|
-
}
|
|
5205
|
-
}
|
|
5206
|
-
class GroupFadeOut extends vrender.ACustomAnimate {
|
|
5207
|
-
constructor(from, to, duration, easing) {
|
|
5208
|
-
super(null, null, duration, easing);
|
|
5209
|
-
}
|
|
5210
|
-
getEndProps() {
|
|
5211
|
-
return {};
|
|
5212
|
-
}
|
|
5213
|
-
onBind() {
|
|
5214
|
-
this.target.setTheme({
|
|
5215
|
-
common: {
|
|
5216
|
-
opacity: 1
|
|
5217
|
-
}
|
|
5218
|
-
});
|
|
5219
|
-
return;
|
|
5220
|
-
}
|
|
5221
|
-
onEnd() {
|
|
5222
|
-
this.target.setTheme({
|
|
5223
|
-
common: {
|
|
5224
|
-
opacity: 0
|
|
5225
|
-
}
|
|
5226
|
-
});
|
|
5227
|
-
return;
|
|
5228
|
-
}
|
|
5229
|
-
onUpdate(end, ratio, out) {
|
|
5230
|
-
this.target.setTheme({
|
|
5231
|
-
common: {
|
|
5232
|
-
opacity: 1 - ratio
|
|
5233
|
-
}
|
|
5234
|
-
});
|
|
5276
|
+
center, type: 'line' });
|
|
5235
5277
|
}
|
|
5236
5278
|
}
|
|
5279
|
+
vutils.mixin(CircleAxisGrid, CircleAxisMixin);
|
|
5237
5280
|
|
|
5238
5281
|
var DataZoomActiveTag;
|
|
5239
5282
|
(function (DataZoomActiveTag) {
|
|
@@ -10310,7 +10353,11 @@
|
|
|
10310
10353
|
}
|
|
10311
10354
|
Tooltip.defaultAttributes = defaultAttributes;
|
|
10312
10355
|
|
|
10313
|
-
|
|
10356
|
+
function VTag(params) {
|
|
10357
|
+
return new Tag(params ? params.attribute : {});
|
|
10358
|
+
}
|
|
10359
|
+
|
|
10360
|
+
const version = "0.15.0-alpha.17";
|
|
10314
10361
|
|
|
10315
10362
|
exports.AbstractComponent = AbstractComponent;
|
|
10316
10363
|
exports.ArcInfo = ArcInfo;
|
|
@@ -10318,6 +10365,7 @@
|
|
|
10318
10365
|
exports.BasePlayer = BasePlayer;
|
|
10319
10366
|
exports.Brush = Brush;
|
|
10320
10367
|
exports.CircleAxis = CircleAxis;
|
|
10368
|
+
exports.CircleAxisGrid = CircleAxisGrid;
|
|
10321
10369
|
exports.CircleCrosshair = CircleCrosshair;
|
|
10322
10370
|
exports.ColorContinuousLegend = ColorContinuousLegend;
|
|
10323
10371
|
exports.ContinuousPlayer = ContinuousPlayer;
|
|
@@ -10334,13 +10382,13 @@
|
|
|
10334
10382
|
exports.DataZoom = DataZoom;
|
|
10335
10383
|
exports.DiscreteLegend = DiscreteLegend;
|
|
10336
10384
|
exports.DiscretePlayer = DiscretePlayer;
|
|
10337
|
-
exports.Grid = Grid;
|
|
10338
10385
|
exports.GroupFadeIn = GroupFadeIn;
|
|
10339
10386
|
exports.GroupFadeOut = GroupFadeOut;
|
|
10340
10387
|
exports.GroupTransition = GroupTransition;
|
|
10341
10388
|
exports.Indicator = Indicator;
|
|
10342
10389
|
exports.LabelBase = LabelBase;
|
|
10343
10390
|
exports.LineAxis = LineAxis;
|
|
10391
|
+
exports.LineAxisGrid = LineAxisGrid;
|
|
10344
10392
|
exports.LineCrosshair = LineCrosshair;
|
|
10345
10393
|
exports.LineLabel = LineLabel;
|
|
10346
10394
|
exports.LinkPath = LinkPath;
|
|
@@ -10361,6 +10409,7 @@
|
|
|
10361
10409
|
exports.Tag = Tag;
|
|
10362
10410
|
exports.Title = Title;
|
|
10363
10411
|
exports.Tooltip = Tooltip;
|
|
10412
|
+
exports.VTag = VTag;
|
|
10364
10413
|
exports.getHorizontalPath = getHorizontalPath;
|
|
10365
10414
|
exports.getSizeHandlerPath = getSizeHandlerPath;
|
|
10366
10415
|
exports.getVerticalPath = getVerticalPath;
|