@visactor/vgrammar-plot 0.6.6 → 0.7.0-alpha.0
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/area.js +3 -3
- package/cjs/area.js.map +1 -1
- package/cjs/cell.js +3 -3
- package/cjs/cell.js.map +1 -1
- package/cjs/circle-packing.js +4 -5
- package/cjs/circle-packing.js.map +1 -1
- package/cjs/image.js +3 -3
- package/cjs/image.js.map +1 -1
- package/cjs/interval.js +3 -3
- package/cjs/interval.js.map +1 -1
- package/cjs/line.js +3 -3
- package/cjs/line.js.map +1 -1
- package/cjs/path.js +4 -1
- package/cjs/path.js.map +1 -1
- package/cjs/plot.d.ts +6 -4
- package/cjs/plot.js +24 -16
- package/cjs/plot.js.map +1 -1
- package/cjs/polygon.js +3 -3
- package/cjs/polygon.js.map +1 -1
- package/cjs/rect-x.js +3 -3
- package/cjs/rect-x.js.map +1 -1
- package/cjs/rect-y.js +3 -3
- package/cjs/rect-y.js.map +1 -1
- package/cjs/rect.js +3 -3
- package/cjs/rect.js.map +1 -1
- package/cjs/rule-x.js +3 -3
- package/cjs/rule-x.js.map +1 -1
- package/cjs/rule-y.d.ts +1 -1
- package/cjs/rule-y.js +14 -8
- package/cjs/rule-y.js.map +1 -1
- package/cjs/rule.js +3 -3
- package/cjs/rule.js.map +1 -1
- package/cjs/sankey.js +6 -8
- package/cjs/sankey.js.map +1 -1
- package/cjs/semantic-mark.d.ts +9 -4
- package/cjs/semantic-mark.js +113 -77
- package/cjs/semantic-mark.js.map +1 -1
- package/cjs/sunburst.js +4 -5
- package/cjs/sunburst.js.map +1 -1
- package/cjs/symbol.d.ts +3 -1
- package/cjs/symbol.js +25 -3
- package/cjs/symbol.js.map +1 -1
- package/cjs/text.js +5 -3
- package/cjs/text.js.map +1 -1
- package/cjs/tree.js +4 -5
- package/cjs/tree.js.map +1 -1
- package/cjs/treemap.js +4 -5
- package/cjs/treemap.js.map +1 -1
- package/cjs/wordcloud-shape.d.ts +1 -0
- package/cjs/wordcloud-shape.js +12 -7
- package/cjs/wordcloud-shape.js.map +1 -1
- package/cjs/wordcloud.js +4 -5
- package/cjs/wordcloud.js.map +1 -1
- package/dist/index.js +274 -117
- package/dist/index.min.js +1 -1
- package/es/area.js +3 -3
- package/es/area.js.map +1 -1
- package/es/cell.js +3 -3
- package/es/cell.js.map +1 -1
- package/es/circle-packing.js +5 -5
- package/es/circle-packing.js.map +1 -1
- package/es/image.js +3 -3
- package/es/image.js.map +1 -1
- package/es/interval.js +4 -4
- package/es/interval.js.map +1 -1
- package/es/line.js +3 -3
- package/es/line.js.map +1 -1
- package/es/path.js +4 -1
- package/es/path.js.map +1 -1
- package/es/plot.d.ts +6 -4
- package/es/plot.js +25 -17
- package/es/plot.js.map +1 -1
- package/es/polygon.js +3 -3
- package/es/polygon.js.map +1 -1
- package/es/rect-x.js +3 -3
- package/es/rect-x.js.map +1 -1
- package/es/rect-y.js +3 -3
- package/es/rect-y.js.map +1 -1
- package/es/rect.js +3 -3
- package/es/rect.js.map +1 -1
- package/es/rule-x.js +3 -3
- package/es/rule-x.js.map +1 -1
- package/es/rule-y.d.ts +1 -1
- package/es/rule-y.js +15 -7
- package/es/rule-y.js.map +1 -1
- package/es/rule.js +3 -3
- package/es/rule.js.map +1 -1
- package/es/sankey.js +7 -7
- package/es/sankey.js.map +1 -1
- package/es/semantic-mark.d.ts +9 -4
- package/es/semantic-mark.js +111 -77
- package/es/semantic-mark.js.map +1 -1
- package/es/sunburst.js +5 -5
- package/es/sunburst.js.map +1 -1
- package/es/symbol.d.ts +3 -1
- package/es/symbol.js +25 -3
- package/es/symbol.js.map +1 -1
- package/es/text.js +5 -3
- package/es/text.js.map +1 -1
- package/es/tree.js +5 -5
- package/es/tree.js.map +1 -1
- package/es/treemap.js +5 -5
- package/es/treemap.js.map +1 -1
- package/es/wordcloud-shape.d.ts +1 -0
- package/es/wordcloud-shape.js +14 -6
- package/es/wordcloud-shape.js.map +1 -1
- package/es/wordcloud.js +5 -5
- package/es/wordcloud.js.map +1 -1
- package/package.json +8 -8
package/es/semantic-mark.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import { Logger, array, isArray, isBoolean, isNil, isPlainObject } from "@visactor/vutils";
|
|
1
|
+
import { Logger, array, isArray, isBoolean, isNil, isPlainObject, merge } from "@visactor/vutils";
|
|
2
2
|
|
|
3
3
|
import { isContinuous, isDiscrete } from "@visactor/vscale";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { ComponentEnum, SIGNAL_VIEW_BOX, BuiltInEncodeNames, ThemeManager } from "@visactor/vgrammar";
|
|
6
6
|
|
|
7
7
|
import { field as getFieldAccessor, toPercent } from "@visactor/vgrammar-util";
|
|
8
8
|
|
|
9
|
-
const defaultTheme = getTheme("default");
|
|
10
|
-
|
|
11
9
|
let semanticMarkId = -1;
|
|
12
10
|
|
|
13
11
|
export class SemanticMark {
|
|
14
|
-
constructor(type, id) {
|
|
12
|
+
constructor(type, id, plot) {
|
|
15
13
|
this.type = type, this.uid = ++semanticMarkId, this._logger = Logger.getInstance(),
|
|
16
|
-
this.spec = {
|
|
14
|
+
this.plot = plot, this.spec = {
|
|
17
15
|
id: null != id ? id : `${this.type}-${this.uid}`
|
|
18
16
|
};
|
|
19
17
|
}
|
|
@@ -96,6 +94,10 @@ export class SemanticMark {
|
|
|
96
94
|
layout: layout
|
|
97
95
|
}, this;
|
|
98
96
|
}
|
|
97
|
+
getPalette() {
|
|
98
|
+
var _a;
|
|
99
|
+
return null === (_a = (this.plot ? this.plot.view.getCurrentTheme() : ThemeManager.getDefaultTheme()).palette) || void 0 === _a ? void 0 : _a.default;
|
|
100
|
+
}
|
|
99
101
|
setDefaultDataTransform() {
|
|
100
102
|
return [];
|
|
101
103
|
}
|
|
@@ -112,7 +114,7 @@ export class SemanticMark {
|
|
|
112
114
|
const excludeIndex = [];
|
|
113
115
|
for (let i = 0, len = userTransform.length; i < len; i++) {
|
|
114
116
|
const customizedSpec = userTransform[i], index = defaultTransform.findIndex((entry => entry.type === customizedSpec.type));
|
|
115
|
-
index >= 0 ? (transforms.push(
|
|
117
|
+
index >= 0 ? (transforms.push(merge({}, defaultTransform[index], customizedSpec)),
|
|
116
118
|
excludeIndex.push(index)) : transforms.push(customizedSpec);
|
|
117
119
|
}
|
|
118
120
|
for (let j = 0, dlen = defaultTransform.length; j < dlen; j++) excludeIndex.includes(j) || (transforms = [ defaultTransform[j] ].concat(transforms));
|
|
@@ -131,7 +133,8 @@ export class SemanticMark {
|
|
|
131
133
|
return Object.keys(encode).map((channel => {
|
|
132
134
|
markEncoder[channel] = {
|
|
133
135
|
field: encode[channel],
|
|
134
|
-
scale: this.getScaleId(channel)
|
|
136
|
+
scale: this.getScaleId(channel),
|
|
137
|
+
band: .5
|
|
135
138
|
};
|
|
136
139
|
})), markEncoder;
|
|
137
140
|
}
|
|
@@ -202,7 +205,18 @@ export class SemanticMark {
|
|
|
202
205
|
data: this.getDataIdOfMain(),
|
|
203
206
|
field: option
|
|
204
207
|
},
|
|
205
|
-
range: getPalette()
|
|
208
|
+
range: this.getPalette()
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
parseScaleOfEncodeStroke(option) {
|
|
212
|
+
return {
|
|
213
|
+
type: "ordinal",
|
|
214
|
+
id: this.getScaleId("stroke"),
|
|
215
|
+
domain: {
|
|
216
|
+
data: this.getDataIdOfMain(),
|
|
217
|
+
field: option
|
|
218
|
+
},
|
|
219
|
+
range: this.getPalette()
|
|
206
220
|
};
|
|
207
221
|
}
|
|
208
222
|
parseScaleOfEncodeGroup(option) {
|
|
@@ -213,11 +227,11 @@ export class SemanticMark {
|
|
|
213
227
|
data: this.getDataIdOfMain(),
|
|
214
228
|
field: option
|
|
215
229
|
},
|
|
216
|
-
range: getPalette()
|
|
230
|
+
range: this.getPalette()
|
|
217
231
|
};
|
|
218
232
|
}
|
|
219
233
|
parseScaleOfCommonEncode(channel, option) {
|
|
220
|
-
return "x" === channel ? this.parseScaleOfEncodeX(option) : "y" === channel ? this.parseScaleOfEncodeY(option) : "color" === channel ? this.parseScaleOfEncodeColor(option) : "group" === channel ? this.parseScaleOfEncodeGroup(option) : null;
|
|
234
|
+
return "x" === channel ? this.parseScaleOfEncodeX(option) : "y" === channel ? this.parseScaleOfEncodeY(option) : "color" === channel ? this.parseScaleOfEncodeColor(option) : "group" === channel ? this.parseScaleOfEncodeGroup(option) : "stroke" === channel ? this.parseScaleOfEncodeStroke(option) : null;
|
|
221
235
|
}
|
|
222
236
|
setDefaultAxis() {
|
|
223
237
|
return {};
|
|
@@ -259,7 +273,7 @@ export class SemanticMark {
|
|
|
259
273
|
y: -params.viewBox.height()
|
|
260
274
|
}
|
|
261
275
|
};
|
|
262
|
-
return isPlainObject(option) ?
|
|
276
|
+
return isPlainObject(option) ? merge(positionAttrs, option) : positionAttrs;
|
|
263
277
|
}
|
|
264
278
|
}
|
|
265
279
|
};
|
|
@@ -302,6 +316,7 @@ export class SemanticMark {
|
|
|
302
316
|
type: "component",
|
|
303
317
|
componentType: ComponentEnum.legend,
|
|
304
318
|
scale: this.getScaleId(channel),
|
|
319
|
+
shapeScale: this.getScaleId("shape"),
|
|
305
320
|
dependency: [ SIGNAL_VIEW_BOX ],
|
|
306
321
|
target: {
|
|
307
322
|
data: this.getDataIdOfFiltered(),
|
|
@@ -327,7 +342,7 @@ export class SemanticMark {
|
|
|
327
342
|
x: null !== (_w = null === (_v = null === (_u = element.mark) || void 0 === _u ? void 0 : _u.relativePosition) || void 0 === _v ? void 0 : _v.left) && void 0 !== _w ? _w : 0,
|
|
328
343
|
y: null !== (_z = null === (_y = null === (_x = element.mark) || void 0 === _x ? void 0 : _x.relativePosition) || void 0 === _y ? void 0 : _y.top) && void 0 !== _z ? _z : 0
|
|
329
344
|
};
|
|
330
|
-
return isPlainObject(option) ?
|
|
345
|
+
return isPlainObject(option) ? merge({}, calculatedAttrs, option) : calculatedAttrs;
|
|
331
346
|
}
|
|
332
347
|
}
|
|
333
348
|
};
|
|
@@ -383,16 +398,18 @@ export class SemanticMark {
|
|
|
383
398
|
return null;
|
|
384
399
|
}
|
|
385
400
|
parseTooltipSpec() {
|
|
386
|
-
var _a;
|
|
401
|
+
var _a, _b;
|
|
387
402
|
const defaultTooltipSpec = this.setDefaultTooltip(), userTooltipSpec = this.spec.tooltip;
|
|
388
403
|
if (!1 !== userTooltipSpec && null !== userTooltipSpec && null !== defaultTooltipSpec) {
|
|
389
|
-
const res = [], tooltipSpec =
|
|
404
|
+
const res = [], tooltipSpec = merge({}, defaultTooltipSpec, !0 === userTooltipSpec ? {} : userTooltipSpec), colorChannel = isNil(this.spec.encode.color) ? isNil(this.spec.encode.group) ? "stroke" : "group" : "color", colorEncode = this.spec.encode[colorChannel], dependency = colorEncode ? [ this.getScaleId(colorChannel) ] : [], colorAccessor = colorEncode ? getFieldAccessor(colorEncode) : null, title = {
|
|
390
405
|
visible: !!tooltipSpec.title || !!tooltipSpec.staticTitle,
|
|
391
406
|
key: "title",
|
|
392
407
|
value: isNil(tooltipSpec.staticTitle) ? {
|
|
393
|
-
field: (datum, el, params) => tooltipSpec.title
|
|
408
|
+
field: (datum, el, params) => tooltipSpec.title ? getFieldAccessor(tooltipSpec.title)(isArray(datum) ? datum[0] : datum) : void 0
|
|
394
409
|
} : tooltipSpec.staticTitle
|
|
395
|
-
}
|
|
410
|
+
};
|
|
411
|
+
this.spec.encode.shape && dependency.push(this.getScaleId("shape"));
|
|
412
|
+
const content = isArray(tooltipSpec.content) && tooltipSpec.content.length ? tooltipSpec.content.map(((entry, index) => ({
|
|
396
413
|
key: entry.key ? {
|
|
397
414
|
field: entry.key
|
|
398
415
|
} : isNil(tooltipSpec.staticContentKey) ? (datum, el, params) => colorAccessor ? colorAccessor(datum) : void 0 : isArray(tooltipSpec.staticContentKey) ? tooltipSpec.staticContentKey[index] : tooltipSpec.staticContentKey,
|
|
@@ -401,14 +418,16 @@ export class SemanticMark {
|
|
|
401
418
|
},
|
|
402
419
|
symbol: (datum, el, params) => {
|
|
403
420
|
var _a;
|
|
404
|
-
const scale = params[this.getScaleId(colorChannel)];
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
421
|
+
const scale = params[this.getScaleId(colorChannel)], shapeScale = params[this.getScaleId("shape")];
|
|
422
|
+
let symbolType = "circle";
|
|
423
|
+
return shapeScale && entry.symbol ? symbolType = shapeScale.scale(getFieldAccessor(entry.symbol)(datum)) : entry.symbol && (symbolType = getFieldAccessor(entry.symbol)(datum)),
|
|
424
|
+
{
|
|
425
|
+
fill: scale && colorAccessor ? scale.scale(colorAccessor(datum)) : null === (_a = this.getPalette()) || void 0 === _a ? void 0 : _a[0],
|
|
426
|
+
symbolType: symbolType
|
|
408
427
|
};
|
|
409
428
|
}
|
|
410
429
|
}))) : null;
|
|
411
|
-
|
|
430
|
+
if (!0 !== tooltipSpec.disableGraphicTooltip && res.push({
|
|
412
431
|
type: "component",
|
|
413
432
|
componentType: ComponentEnum.tooltip,
|
|
414
433
|
target: this.getMarkId(),
|
|
@@ -416,21 +435,25 @@ export class SemanticMark {
|
|
|
416
435
|
title: title,
|
|
417
436
|
content: content,
|
|
418
437
|
zIndex: 1e3
|
|
419
|
-
}), !0 !== tooltipSpec.disableDimensionTooltip
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
438
|
+
}), !0 !== tooltipSpec.disableDimensionTooltip) {
|
|
439
|
+
const channel = null !== (_a = tooltipSpec.dimensionTooltipChannel) && void 0 !== _a ? _a : "x";
|
|
440
|
+
res.push({
|
|
441
|
+
type: "component",
|
|
442
|
+
componentType: ComponentEnum.dimensionTooltip,
|
|
443
|
+
tooltipType: this.getVisualChannel(channel),
|
|
444
|
+
scale: this.getScaleId(channel),
|
|
445
|
+
dependency: dependency,
|
|
446
|
+
target: {
|
|
447
|
+
data: this.getDataIdOfFiltered(),
|
|
448
|
+
filter: null === (_b = this.spec.encode) || void 0 === _b ? void 0 : _b[channel]
|
|
449
|
+
},
|
|
450
|
+
title: title,
|
|
451
|
+
content: content,
|
|
452
|
+
avoidMark: tooltipSpec.disableGraphicTooltip ? [] : [ this.getMarkId() ],
|
|
453
|
+
zIndex: 1e3
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
return res;
|
|
434
457
|
}
|
|
435
458
|
return [];
|
|
436
459
|
}
|
|
@@ -445,7 +468,7 @@ export class SemanticMark {
|
|
|
445
468
|
if (option) {
|
|
446
469
|
const scaleId = this.getScaleId(channel), scaleSpec = this.getScaleSpec(scaleId), dataId = this.getDataIdOfMain();
|
|
447
470
|
if (!scaleSpec || !isContinuous(scaleSpec.type)) return void this._logger.warn(`[VGrammar]: Don't use slider in a channel which has scale type = ${null == scaleSpec ? void 0 : scaleSpec.type}`);
|
|
448
|
-
const getter = getFieldAccessor(null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a[channel]), markLayout = null != layout ? layout : isPlainObject(option) && !isNil(option.layout) ? "horizontal" === option.layout ? {
|
|
471
|
+
const theme = this.plot ? this.plot.view.getCurrentTheme() : ThemeManager.getDefaultTheme(), getter = getFieldAccessor(null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a[channel]), markLayout = null != layout ? layout : isPlainObject(option) && !isNil(option.layout) ? "horizontal" === option.layout ? {
|
|
449
472
|
position: "top",
|
|
450
473
|
align: "center"
|
|
451
474
|
} : "vertical" === option.layout ? {
|
|
@@ -480,28 +503,28 @@ export class SemanticMark {
|
|
|
480
503
|
layout: "vertical",
|
|
481
504
|
x: null !== (_c = null === (_b = null === (_a = elment.mark) || void 0 === _a ? void 0 : _a.relativePosition) || void 0 === _b ? void 0 : _b.left) && void 0 !== _c ? _c : 0,
|
|
482
505
|
y: null !== (_f = null === (_e = null === (_d = elment.mark) || void 0 === _d ? void 0 : _d.relativePosition) || void 0 === _e ? void 0 : _e.top) && void 0 !== _f ? _f : 0,
|
|
483
|
-
railWidth:
|
|
506
|
+
railWidth: theme.components.slider.railHeight,
|
|
484
507
|
railHeight: params.viewBox.height()
|
|
485
508
|
} : "right" === markLayout.position ? {
|
|
486
509
|
layout: "vertical",
|
|
487
510
|
x: null !== (_j = null === (_h = null === (_g = elment.mark) || void 0 === _g ? void 0 : _g.relativePosition) || void 0 === _h ? void 0 : _h.left) && void 0 !== _j ? _j : params.viewBox.width(),
|
|
488
511
|
y: null !== (_m = null === (_l = null === (_k = elment.mark) || void 0 === _k ? void 0 : _k.relativePosition) || void 0 === _l ? void 0 : _l.top) && void 0 !== _m ? _m : 0,
|
|
489
|
-
railWidth:
|
|
512
|
+
railWidth: theme.components.slider.railHeight,
|
|
490
513
|
railHeight: params.viewBox.height()
|
|
491
514
|
} : "bottom" === markLayout.position ? {
|
|
492
515
|
layout: "horizontal",
|
|
493
516
|
x: null !== (_q = null === (_p = null === (_o = elment.mark) || void 0 === _o ? void 0 : _o.relativePosition) || void 0 === _p ? void 0 : _p.left) && void 0 !== _q ? _q : 0,
|
|
494
517
|
y: null !== (_t = null === (_s = null === (_r = elment.mark) || void 0 === _r ? void 0 : _r.relativePosition) || void 0 === _s ? void 0 : _s.top) && void 0 !== _t ? _t : params.viewBox.height(),
|
|
495
|
-
railHeight:
|
|
518
|
+
railHeight: theme.components.slider.railHeight,
|
|
496
519
|
railWidth: params.viewBox.width()
|
|
497
520
|
} : {
|
|
498
521
|
layout: "horizontal",
|
|
499
522
|
x: null !== (_w = null === (_v = null === (_u = elment.mark) || void 0 === _u ? void 0 : _u.relativePosition) || void 0 === _v ? void 0 : _v.left) && void 0 !== _w ? _w : 0,
|
|
500
523
|
y: null !== (_z = null === (_y = null === (_x = elment.mark) || void 0 === _x ? void 0 : _x.relativePosition) || void 0 === _y ? void 0 : _y.top) && void 0 !== _z ? _z : 0,
|
|
501
|
-
railHeight:
|
|
524
|
+
railHeight: theme.components.slider.railHeight,
|
|
502
525
|
railWidth: params.viewBox.width()
|
|
503
526
|
};
|
|
504
|
-
return isPlainObject(option) ?
|
|
527
|
+
return isPlainObject(option) ? merge({}, calculatedAttrs, option) : calculatedAttrs;
|
|
505
528
|
}
|
|
506
529
|
}
|
|
507
530
|
};
|
|
@@ -538,7 +561,7 @@ export class SemanticMark {
|
|
|
538
561
|
scale: x,
|
|
539
562
|
field: null !== (_d = null === (_c = this.spec.encode) || void 0 === _c ? void 0 : _c[channel]) && void 0 !== _d ? _d : channel
|
|
540
563
|
};
|
|
541
|
-
const markSpec = {
|
|
564
|
+
const theme = this.plot ? this.plot.view.getCurrentTheme() : ThemeManager.getDefaultTheme(), markSpec = {
|
|
542
565
|
type: "component",
|
|
543
566
|
componentType: ComponentEnum.datazoom,
|
|
544
567
|
dependency: [ SIGNAL_VIEW_BOX, dataId ],
|
|
@@ -556,7 +579,7 @@ export class SemanticMark {
|
|
|
556
579
|
y: null !== (_f = null === (_e = null === (_d = elment.mark) || void 0 === _d ? void 0 : _d.relativePosition) || void 0 === _e ? void 0 : _e.top) && void 0 !== _f ? _f : 0,
|
|
557
580
|
size: {
|
|
558
581
|
height: params.viewBox.height(),
|
|
559
|
-
width:
|
|
582
|
+
width: theme.components.datazoom.size.height
|
|
560
583
|
}
|
|
561
584
|
} : "right" === markLayout.position ? {
|
|
562
585
|
orient: markLayout.position,
|
|
@@ -564,7 +587,7 @@ export class SemanticMark {
|
|
|
564
587
|
y: null !== (_m = null === (_l = null === (_k = elment.mark) || void 0 === _k ? void 0 : _k.relativePosition) || void 0 === _l ? void 0 : _l.top) && void 0 !== _m ? _m : 0,
|
|
565
588
|
size: {
|
|
566
589
|
height: params.viewBox.height(),
|
|
567
|
-
width:
|
|
590
|
+
width: theme.components.datazoom.size.height
|
|
568
591
|
}
|
|
569
592
|
} : "bottom" === markLayout.position ? {
|
|
570
593
|
orient: markLayout.position,
|
|
@@ -572,7 +595,7 @@ export class SemanticMark {
|
|
|
572
595
|
y: null !== (_t = null === (_s = null === (_r = elment.mark) || void 0 === _r ? void 0 : _r.relativePosition) || void 0 === _s ? void 0 : _s.top) && void 0 !== _t ? _t : params.viewBox.height(),
|
|
573
596
|
size: {
|
|
574
597
|
width: params.viewBox.width(),
|
|
575
|
-
height:
|
|
598
|
+
height: theme.components.datazoom.size.height
|
|
576
599
|
}
|
|
577
600
|
} : {
|
|
578
601
|
orient: markLayout.position,
|
|
@@ -580,10 +603,10 @@ export class SemanticMark {
|
|
|
580
603
|
y: null !== (_z = null === (_y = null === (_x = elment.mark) || void 0 === _x ? void 0 : _x.relativePosition) || void 0 === _y ? void 0 : _y.top) && void 0 !== _z ? _z : 0,
|
|
581
604
|
size: {
|
|
582
605
|
width: params.viewBox.width(),
|
|
583
|
-
height:
|
|
606
|
+
height: theme.components.datazoom.size.height
|
|
584
607
|
}
|
|
585
608
|
};
|
|
586
|
-
return isPlainObject(option) ?
|
|
609
|
+
return isPlainObject(option) ? merge({}, calculatedAttrs, option) : calculatedAttrs;
|
|
587
610
|
}
|
|
588
611
|
}
|
|
589
612
|
};
|
|
@@ -599,7 +622,9 @@ export class SemanticMark {
|
|
|
599
622
|
return "polar" === (null === (_a = this._coordinate) || void 0 === _a ? void 0 : _a.type) ? this._coordinate.transpose ? "endAngle" : "outer" : (null === (_b = this._coordinate) || void 0 === _b ? void 0 : _b.transpose) ? "right" : "top";
|
|
600
623
|
}
|
|
601
624
|
setLabelTextGetter(channel, option) {
|
|
602
|
-
return
|
|
625
|
+
return {
|
|
626
|
+
field: channel
|
|
627
|
+
};
|
|
603
628
|
}
|
|
604
629
|
parseLabelSpec() {
|
|
605
630
|
const label = this.spec.label, res = [];
|
|
@@ -614,7 +639,7 @@ export class SemanticMark {
|
|
|
614
639
|
position: "content",
|
|
615
640
|
skipBeforeLayouted: !0
|
|
616
641
|
},
|
|
617
|
-
labelStyle: isPlainObject(option) ?
|
|
642
|
+
labelStyle: isPlainObject(option) ? merge({
|
|
618
643
|
position: this.getLabelPosition()
|
|
619
644
|
}, option) : {
|
|
620
645
|
position: this.getLabelPosition()
|
|
@@ -685,7 +710,7 @@ export class SemanticMark {
|
|
|
685
710
|
height: 20
|
|
686
711
|
}
|
|
687
712
|
};
|
|
688
|
-
return isPlainObject(option) ?
|
|
713
|
+
return isPlainObject(option) ? merge({}, calculatedAttrs, option) : calculatedAttrs;
|
|
689
714
|
}
|
|
690
715
|
}
|
|
691
716
|
};
|
|
@@ -726,38 +751,47 @@ export class SemanticMark {
|
|
|
726
751
|
const {encode: encode, scale: scale, datazoom: datazoom} = this.spec, scales = {};
|
|
727
752
|
return encode && Object.keys(encode).forEach((k => {
|
|
728
753
|
var _a;
|
|
729
|
-
const encodeOption = encode[k], scaleId = this.getScaleId(k);
|
|
730
|
-
scales[scaleId] = Object.assign({
|
|
754
|
+
const encodeOption = encode[k], scaleId = this.getScaleId(k), userScale = null === (_a = this.spec.scale) || void 0 === _a ? void 0 : _a[k];
|
|
755
|
+
scales[scaleId] = userScale ? Object.assign({
|
|
731
756
|
id: scaleId
|
|
732
|
-
}, this.parseScaleByEncode(k, encodeOption),
|
|
757
|
+
}, this.parseScaleByEncode(k, encodeOption), userScale, {
|
|
758
|
+
userScale: userScale
|
|
759
|
+
}) : Object.assign({
|
|
760
|
+
id: scaleId
|
|
761
|
+
}, this.parseScaleByEncode(k, encodeOption));
|
|
733
762
|
})), scale && Object.keys(scale).forEach((k => {
|
|
734
763
|
const scaleId = this.getScaleId(k);
|
|
735
|
-
scales[scaleId] || (scales[scaleId] = scale[k]);
|
|
764
|
+
scales[scaleId] || (scales[scaleId] = scale[k], scales[scaleId].userScale = scale[k]);
|
|
736
765
|
})), datazoom && Object.keys(datazoom).forEach((k => {
|
|
737
766
|
var _a, _b, _c, _d;
|
|
738
767
|
const scaleId = this.getScaleId(k), {x: xScaleId, y: yScaleId} = this.getDataZoomScaleId(k);
|
|
739
|
-
"x" === k && encode[k]
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
768
|
+
if ("x" === k && encode[k]) {
|
|
769
|
+
if (scales[xScaleId] = {
|
|
770
|
+
type: scales[scaleId].type,
|
|
771
|
+
id: xScaleId,
|
|
772
|
+
domain: {
|
|
773
|
+
data: this.getDataIdOfMain(),
|
|
774
|
+
field: encode[k]
|
|
775
|
+
},
|
|
776
|
+
dependency: [ SIGNAL_VIEW_BOX ],
|
|
777
|
+
range: (scale, params) => [ 0, params.viewBox.width() ]
|
|
778
|
+
}, encode.y) {
|
|
779
|
+
const theme = this.plot ? this.plot.view.getCurrentTheme() : ThemeManager.getDefaultTheme();
|
|
780
|
+
scales[yScaleId] = {
|
|
781
|
+
type: null !== (_b = null === (_a = scales[this.getScaleId("y")]) || void 0 === _a ? void 0 : _a.type) && void 0 !== _b ? _b : "linear",
|
|
782
|
+
id: yScaleId,
|
|
783
|
+
domain: {
|
|
784
|
+
data: this.getDataIdOfMain(),
|
|
785
|
+
field: null == encode ? void 0 : encode.y
|
|
786
|
+
},
|
|
787
|
+
range: (scale, params) => {
|
|
788
|
+
var _a, _b;
|
|
789
|
+
const option = this.parseOption(datazoom[k]).option;
|
|
790
|
+
return [ 0, isPlainObject(option) && null !== (_b = null === (_a = option.size) || void 0 === _a ? void 0 : _a.height) && void 0 !== _b ? _b : theme.components.datazoom.size.height ];
|
|
791
|
+
}
|
|
792
|
+
};
|
|
759
793
|
}
|
|
760
|
-
}
|
|
794
|
+
} else scales[xScaleId] = {
|
|
761
795
|
type: null !== (_c = scales[scaleId].type) && void 0 !== _c ? _c : "band",
|
|
762
796
|
id: xScaleId,
|
|
763
797
|
domain: {
|