@visactor/vgrammar-plot 0.7.7 → 0.8.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/circle-packing.d.ts +1 -1
- package/cjs/circle-packing.js.map +1 -1
- package/cjs/plot.js +4 -2
- package/cjs/plot.js.map +1 -1
- package/cjs/sankey.d.ts +1 -1
- package/cjs/sankey.js.map +1 -1
- package/cjs/semantic-mark.d.ts +44 -13
- package/cjs/semantic-mark.js +154 -77
- package/cjs/semantic-mark.js.map +1 -1
- package/cjs/sunburst.d.ts +6 -3
- package/cjs/sunburst.js +4 -1
- package/cjs/sunburst.js.map +1 -1
- package/cjs/tree.d.ts +1 -1
- package/cjs/tree.js.map +1 -1
- package/cjs/treemap.d.ts +6 -3
- package/cjs/treemap.js +4 -1
- package/cjs/treemap.js.map +1 -1
- package/cjs/wordcloud-shape.d.ts +5 -2
- package/cjs/wordcloud-shape.js +4 -1
- package/cjs/wordcloud-shape.js.map +1 -1
- package/cjs/wordcloud.d.ts +5 -2
- package/cjs/wordcloud.js +4 -1
- package/cjs/wordcloud.js.map +1 -1
- package/es/circle-packing.d.ts +1 -1
- package/es/circle-packing.js.map +1 -1
- package/es/plot.js +4 -2
- package/es/plot.js.map +1 -1
- package/es/sankey.d.ts +1 -1
- package/es/sankey.js.map +1 -1
- package/es/semantic-mark.d.ts +44 -13
- package/es/semantic-mark.js +153 -77
- package/es/semantic-mark.js.map +1 -1
- package/es/sunburst.d.ts +6 -3
- package/es/sunburst.js +4 -1
- package/es/sunburst.js.map +1 -1
- package/es/tree.d.ts +1 -1
- package/es/tree.js.map +1 -1
- package/es/treemap.d.ts +6 -3
- package/es/treemap.js +4 -1
- package/es/treemap.js.map +1 -1
- package/es/wordcloud-shape.d.ts +5 -2
- package/es/wordcloud-shape.js +4 -1
- package/es/wordcloud-shape.js.map +1 -1
- package/es/wordcloud.d.ts +5 -2
- package/es/wordcloud.js +4 -1
- package/es/wordcloud.js.map +1 -1
- package/package.json +9 -8
package/cjs/semantic-mark.js
CHANGED
|
@@ -189,6 +189,9 @@ class SemanticMark {
|
|
|
189
189
|
getMarkId() {
|
|
190
190
|
return `${this.spec.id}-mark`;
|
|
191
191
|
}
|
|
192
|
+
getComponentId(id, component) {
|
|
193
|
+
return `${this.spec.id}-${null != component ? component : "component"}-${id}`;
|
|
194
|
+
}
|
|
192
195
|
getScaleSpec(scaleId) {
|
|
193
196
|
var _a, _b, _c;
|
|
194
197
|
return null === (_c = null === (_b = null === (_a = this.viewSpec) || void 0 === _a ? void 0 : _a.scales) || void 0 === _b ? void 0 : _b.find) || void 0 === _c ? void 0 : _c.call(_b, (scale => scale.id === scaleId));
|
|
@@ -263,7 +266,10 @@ class SemanticMark {
|
|
|
263
266
|
return {};
|
|
264
267
|
}
|
|
265
268
|
parseAxisSpec() {
|
|
266
|
-
const axis = this.spec.axis, res =
|
|
269
|
+
const axis = this.spec.axis, res = {
|
|
270
|
+
marks: [],
|
|
271
|
+
interactions: []
|
|
272
|
+
};
|
|
267
273
|
return axis && Object.keys(axis).forEach((channel => {
|
|
268
274
|
const {option: option, layout: layout} = this.parseOption(axis[channel]);
|
|
269
275
|
if (option) {
|
|
@@ -306,12 +312,15 @@ class SemanticMark {
|
|
|
306
312
|
axisMarkSpec.layout = null != layout ? layout : {
|
|
307
313
|
position: this._coordinate ? "auto" : (0, vutils_1.isPlainObject)(layout) && !(0,
|
|
308
314
|
vutils_1.isNil)(layout.orient) ? layout.orient : "x" === channel ? "bottom" : "left"
|
|
309
|
-
}, res.push(axisMarkSpec);
|
|
315
|
+
}, res.marks.push(axisMarkSpec);
|
|
310
316
|
}
|
|
311
317
|
})), res;
|
|
312
318
|
}
|
|
313
319
|
parseGridSpec() {
|
|
314
|
-
const grid = this.spec.grid, res =
|
|
320
|
+
const grid = this.spec.grid, res = {
|
|
321
|
+
marks: [],
|
|
322
|
+
interactions: []
|
|
323
|
+
};
|
|
315
324
|
return grid && Object.keys(grid).forEach((channel => {
|
|
316
325
|
var _a, _b, _c, _d, _e;
|
|
317
326
|
const option = grid[channel];
|
|
@@ -360,7 +369,7 @@ class SemanticMark {
|
|
|
360
369
|
}
|
|
361
370
|
}
|
|
362
371
|
};
|
|
363
|
-
res.push(markSpec);
|
|
372
|
+
res.marks.push(markSpec);
|
|
364
373
|
}
|
|
365
374
|
})), res;
|
|
366
375
|
}
|
|
@@ -376,7 +385,10 @@ class SemanticMark {
|
|
|
376
385
|
return {};
|
|
377
386
|
}
|
|
378
387
|
parseLegendSpec() {
|
|
379
|
-
const legend = this.spec.legend, res =
|
|
388
|
+
const legend = this.spec.legend, res = {
|
|
389
|
+
marks: [],
|
|
390
|
+
interactions: []
|
|
391
|
+
};
|
|
380
392
|
return legend && Object.keys(legend).forEach((channel => {
|
|
381
393
|
var _a;
|
|
382
394
|
const {option: option, layout: layout} = this.parseOption(legend[channel]);
|
|
@@ -396,14 +408,11 @@ class SemanticMark {
|
|
|
396
408
|
align: "center"
|
|
397
409
|
}, markSpec = {
|
|
398
410
|
type: "component",
|
|
411
|
+
id: this.getComponentId(channel, "legend"),
|
|
399
412
|
componentType: vgrammar_core_1.ComponentEnum.legend,
|
|
400
413
|
scale: this.getScaleId(channel),
|
|
401
414
|
shapeScale: this.getScaleId("shape"),
|
|
402
415
|
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX ],
|
|
403
|
-
target: {
|
|
404
|
-
data: this.getDataIdOfFiltered(),
|
|
405
|
-
filter: null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a[channel]
|
|
406
|
-
},
|
|
407
416
|
encode: {
|
|
408
417
|
update: (datum, element, params) => {
|
|
409
418
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
@@ -428,7 +437,16 @@ class SemanticMark {
|
|
|
428
437
|
}
|
|
429
438
|
}
|
|
430
439
|
};
|
|
431
|
-
markSpec.layout = markLayout
|
|
440
|
+
markSpec.layout = markLayout;
|
|
441
|
+
const interactionSpec = {
|
|
442
|
+
type: "legend-filter",
|
|
443
|
+
source: `#${this.getComponentId(channel, "legend")}`,
|
|
444
|
+
target: {
|
|
445
|
+
data: this.getDataIdOfFiltered(),
|
|
446
|
+
filter: null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a[channel]
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
res.marks.push(markSpec), res.interactions.push(interactionSpec);
|
|
432
450
|
}
|
|
433
451
|
})), res;
|
|
434
452
|
}
|
|
@@ -441,38 +459,39 @@ class SemanticMark {
|
|
|
441
459
|
}
|
|
442
460
|
parseCrosshairSpec() {
|
|
443
461
|
const defaultCrosshair = this.setDefaultCrosshair(), defaultKeys = Object.keys(defaultCrosshair), crosshairKeys = this.spec.crosshair ? Object.keys(this.spec.crosshair).reduce(((res, key) => (res.includes(key) || res.push(key),
|
|
444
|
-
res)), defaultKeys) : defaultKeys, res =
|
|
462
|
+
res)), defaultKeys) : defaultKeys, res = {
|
|
463
|
+
marks: [],
|
|
464
|
+
interactions: []
|
|
465
|
+
};
|
|
445
466
|
return crosshairKeys.length && crosshairKeys.forEach((channel => {
|
|
446
467
|
var _a, _b;
|
|
447
468
|
const userOption = null === (_a = this.spec.crosshair) || void 0 === _a ? void 0 : _a[channel], option = null != userOption ? userOption : defaultCrosshair[channel];
|
|
448
469
|
if (option) {
|
|
449
|
-
const scaleId = this.getScaleId(channel), scaleSpec = this.getScaleSpec(scaleId),
|
|
450
|
-
type: "
|
|
451
|
-
componentType: vgrammar_core_1.ComponentEnum.crosshair,
|
|
470
|
+
const scaleId = this.getScaleId(channel), scaleSpec = this.getScaleSpec(scaleId), interactionSpec = {
|
|
471
|
+
type: "crosshair",
|
|
452
472
|
scale: this.getScaleId(channel),
|
|
453
|
-
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX ],
|
|
454
473
|
crosshairShape: (0, vutils_1.isBoolean)(option) ? "band" === (null == scaleSpec ? void 0 : scaleSpec.type) ? "rect" : "line" : null !== (_b = option.crosshairShape) && void 0 !== _b ? _b : "band" === (null == scaleSpec ? void 0 : scaleSpec.type) ? "rect" : "line",
|
|
455
|
-
crosshairType: this.getVisualChannel(channel)
|
|
474
|
+
crosshairType: this.getVisualChannel(channel),
|
|
475
|
+
container: "#plotContainer"
|
|
456
476
|
};
|
|
457
|
-
if ((0, vutils_1.isPlainObject)(userOption) && (
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
markSpec.crosshairType = "radius-polygon";
|
|
477
|
+
if ((0, vutils_1.isPlainObject)(userOption) && (interactionSpec.attributes = userOption,
|
|
478
|
+
"polygon" === userOption.type)) {
|
|
479
|
+
interactionSpec.crosshairType = "radius-polygon";
|
|
461
480
|
const anotherDimScaleId = this.getScaleId("x" === channel ? "y" : "x");
|
|
462
|
-
|
|
481
|
+
interactionSpec.attributes.sides = (datum, params) => {
|
|
463
482
|
const scale = params[anotherDimScaleId];
|
|
464
483
|
return scale && (0, vscale_1.isDiscrete)(scale.type) ? scale.domain().length : void 0;
|
|
465
|
-
},
|
|
484
|
+
}, interactionSpec.attributes.startAngle = (datum, params) => {
|
|
466
485
|
var _a, _b;
|
|
467
486
|
const scale = params[anotherDimScaleId];
|
|
468
487
|
return scale && (0, vscale_1.isDiscrete)(scale.type) ? scale.range()[0] + (null !== (_b = null === (_a = null == scale ? void 0 : scale.bandwidth) || void 0 === _a ? void 0 : _a.call(scale)) && void 0 !== _b ? _b : 0) / 2 : void 0;
|
|
469
|
-
},
|
|
488
|
+
}, interactionSpec.attributes.endAngle = (datum, params) => {
|
|
470
489
|
var _a, _b;
|
|
471
490
|
const scale = params[anotherDimScaleId];
|
|
472
491
|
return scale && (0, vscale_1.isDiscrete)(scale.type) ? scale.range()[1] + (null !== (_b = null === (_a = null == scale ? void 0 : scale.bandwidth) || void 0 === _a ? void 0 : _a.call(scale)) && void 0 !== _b ? _b : 0) / 2 : void 0;
|
|
473
|
-
};
|
|
492
|
+
}, interactionSpec.dependencies = [ anotherDimScaleId ];
|
|
474
493
|
}
|
|
475
|
-
res.push(
|
|
494
|
+
res.interactions.push(interactionSpec);
|
|
476
495
|
}
|
|
477
496
|
})), res;
|
|
478
497
|
}
|
|
@@ -481,9 +500,12 @@ class SemanticMark {
|
|
|
481
500
|
}
|
|
482
501
|
parseTooltipSpec() {
|
|
483
502
|
var _a, _b;
|
|
484
|
-
const defaultTooltipSpec = this.setDefaultTooltip(), userTooltipSpec = this.spec.tooltip
|
|
503
|
+
const defaultTooltipSpec = this.setDefaultTooltip(), userTooltipSpec = this.spec.tooltip, res = {
|
|
504
|
+
marks: [],
|
|
505
|
+
interactions: []
|
|
506
|
+
};
|
|
485
507
|
if (!1 !== userTooltipSpec && null !== userTooltipSpec && null !== defaultTooltipSpec) {
|
|
486
|
-
const
|
|
508
|
+
const tooltipSpec = (0, vutils_1.merge)({}, defaultTooltipSpec, !0 === userTooltipSpec ? {} : userTooltipSpec), colorChannel = (0,
|
|
487
509
|
vutils_1.isNil)(this.spec.encode.color) ? (0, vutils_1.isNil)(this.spec.encode.group) ? "stroke" : "group" : "color", colorEncode = this.spec.encode[colorChannel], dependency = colorEncode ? [ this.getScaleId(colorChannel) ] : [], colorAccessor = colorEncode ? (0,
|
|
488
510
|
vgrammar_util_1.field)(colorEncode) : null, title = {
|
|
489
511
|
visible: !!tooltipSpec.title || !!tooltipSpec.staticTitle,
|
|
@@ -497,12 +519,12 @@ class SemanticMark {
|
|
|
497
519
|
const content = (0, vutils_1.isArray)(tooltipSpec.content) && tooltipSpec.content.length ? tooltipSpec.content.map(((entry, index) => ({
|
|
498
520
|
key: entry.key ? {
|
|
499
521
|
field: entry.key
|
|
500
|
-
} : (0, vutils_1.isNil)(tooltipSpec.staticContentKey) ? (datum,
|
|
522
|
+
} : (0, vutils_1.isNil)(tooltipSpec.staticContentKey) ? (datum, params) => colorAccessor ? colorAccessor(datum) : void 0 : (0,
|
|
501
523
|
vutils_1.isArray)(tooltipSpec.staticContentKey) ? tooltipSpec.staticContentKey[index] : tooltipSpec.staticContentKey,
|
|
502
524
|
value: {
|
|
503
525
|
field: entry.value
|
|
504
526
|
},
|
|
505
|
-
symbol: (datum,
|
|
527
|
+
symbol: (datum, params) => {
|
|
506
528
|
var _a;
|
|
507
529
|
const scale = params[this.getScaleId(colorChannel)], shapeScale = params[this.getScaleId("shape")];
|
|
508
530
|
let symbolType = "circle";
|
|
@@ -513,41 +535,50 @@ class SemanticMark {
|
|
|
513
535
|
};
|
|
514
536
|
}
|
|
515
537
|
}))) : null;
|
|
516
|
-
if (!0 !== tooltipSpec.disableGraphicTooltip
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
538
|
+
if (!0 !== tooltipSpec.disableGraphicTooltip) {
|
|
539
|
+
const interactionSpec = {
|
|
540
|
+
type: "tooltip",
|
|
541
|
+
selector: `#${this.getMarkId()}`,
|
|
542
|
+
title: title,
|
|
543
|
+
content: content,
|
|
544
|
+
attributes: {
|
|
545
|
+
zIndex: 1e3
|
|
546
|
+
},
|
|
547
|
+
dependencies: [ this.getScaleId(colorChannel), this.getScaleId("shape") ]
|
|
548
|
+
};
|
|
549
|
+
res.interactions.push(interactionSpec);
|
|
550
|
+
}
|
|
551
|
+
if (!0 !== tooltipSpec.disableDimensionTooltip) {
|
|
552
|
+
const channel = null !== (_a = tooltipSpec.dimensionTooltipChannel) && void 0 !== _a ? _a : "x", interactionSpec = {
|
|
553
|
+
type: "dimension-tooltip",
|
|
529
554
|
tooltipType: this.getVisualChannel(channel),
|
|
530
555
|
scale: this.getScaleId(channel),
|
|
531
|
-
dependency: dependency,
|
|
532
556
|
target: {
|
|
533
557
|
data: this.getDataIdOfFiltered(),
|
|
534
558
|
filter: null === (_b = this.spec.encode) || void 0 === _b ? void 0 : _b[channel]
|
|
535
559
|
},
|
|
536
560
|
title: title,
|
|
537
561
|
content: content,
|
|
538
|
-
avoidMark: tooltipSpec.disableGraphicTooltip ? [] : [ this.getMarkId() ],
|
|
539
|
-
|
|
540
|
-
|
|
562
|
+
avoidMark: tooltipSpec.disableGraphicTooltip ? [] : [ `#${this.getMarkId()}` ],
|
|
563
|
+
attributes: {
|
|
564
|
+
zIndex: 1e3
|
|
565
|
+
},
|
|
566
|
+
dependencies: [ this.getScaleId(colorChannel), this.getScaleId("shape") ]
|
|
567
|
+
};
|
|
568
|
+
res.interactions.push(interactionSpec);
|
|
541
569
|
}
|
|
542
570
|
return res;
|
|
543
571
|
}
|
|
544
|
-
return
|
|
572
|
+
return res;
|
|
545
573
|
}
|
|
546
574
|
setDefaultSlider() {
|
|
547
575
|
return {};
|
|
548
576
|
}
|
|
549
577
|
parseSliderSpec() {
|
|
550
|
-
const slider = this.spec.slider, res =
|
|
578
|
+
const slider = this.spec.slider, res = {
|
|
579
|
+
marks: [],
|
|
580
|
+
interactions: []
|
|
581
|
+
};
|
|
551
582
|
return slider && Object.keys(slider).forEach((channel => {
|
|
552
583
|
var _a, _b;
|
|
553
584
|
const {option: option, layout: layout} = this.parseOption(slider[channel]);
|
|
@@ -570,6 +601,7 @@ class SemanticMark {
|
|
|
570
601
|
align: "center"
|
|
571
602
|
}, markSpec = {
|
|
572
603
|
type: "component",
|
|
604
|
+
id: this.getComponentId(channel, "slider"),
|
|
573
605
|
componentType: vgrammar_core_1.ComponentEnum.slider,
|
|
574
606
|
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX, dataId ],
|
|
575
607
|
min: (datum, elment, params) => {
|
|
@@ -580,10 +612,6 @@ class SemanticMark {
|
|
|
580
612
|
const data = params[dataId];
|
|
581
613
|
return Math.max.apply(null, data.map(getter));
|
|
582
614
|
},
|
|
583
|
-
target: {
|
|
584
|
-
data: this.getDataIdOfFiltered(),
|
|
585
|
-
filter: null === (_b = this.spec.encode) || void 0 === _b ? void 0 : _b[channel]
|
|
586
|
-
},
|
|
587
615
|
encode: {
|
|
588
616
|
update: (datum, elment, params) => {
|
|
589
617
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
@@ -616,7 +644,16 @@ class SemanticMark {
|
|
|
616
644
|
}
|
|
617
645
|
}
|
|
618
646
|
};
|
|
619
|
-
markSpec.layout = markLayout
|
|
647
|
+
markSpec.layout = markLayout;
|
|
648
|
+
const interactionSpec = {
|
|
649
|
+
type: "slider-filter",
|
|
650
|
+
source: `#${this.getComponentId(channel, "slider")}`,
|
|
651
|
+
target: {
|
|
652
|
+
data: this.getDataIdOfFiltered(),
|
|
653
|
+
filter: null === (_b = this.spec.encode) || void 0 === _b ? void 0 : _b[channel]
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
res.marks.push(markSpec), res.interactions.push(interactionSpec);
|
|
620
657
|
}
|
|
621
658
|
})), res;
|
|
622
659
|
}
|
|
@@ -626,8 +663,11 @@ class SemanticMark {
|
|
|
626
663
|
getVisiualPositionByDimension(channel) {
|
|
627
664
|
return "y" === channel ? "left" : "bottom";
|
|
628
665
|
}
|
|
629
|
-
|
|
630
|
-
const datazoom = this.spec.datazoom, res =
|
|
666
|
+
parseDatazoomSpec() {
|
|
667
|
+
const datazoom = this.spec.datazoom, res = {
|
|
668
|
+
marks: [],
|
|
669
|
+
interactions: []
|
|
670
|
+
};
|
|
631
671
|
return datazoom && Object.keys(datazoom).forEach((channel => {
|
|
632
672
|
var _a, _b, _c, _d, _e;
|
|
633
673
|
const {option: option, layout: layout} = this.parseOption(datazoom[channel]);
|
|
@@ -652,12 +692,9 @@ class SemanticMark {
|
|
|
652
692
|
};
|
|
653
693
|
const theme = this.plot ? this.plot.view.getCurrentTheme() : vgrammar_core_1.ThemeManager.getDefaultTheme(), markSpec = {
|
|
654
694
|
type: "component",
|
|
695
|
+
id: this.getComponentId(channel, "datazoom"),
|
|
655
696
|
componentType: vgrammar_core_1.ComponentEnum.datazoom,
|
|
656
697
|
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX, dataId ],
|
|
657
|
-
target: {
|
|
658
|
-
data: this.getDataIdOfFiltered(),
|
|
659
|
-
filter: null === (_e = this.spec.encode) || void 0 === _e ? void 0 : _e[channel]
|
|
660
|
-
},
|
|
661
698
|
preview: preview,
|
|
662
699
|
encode: {
|
|
663
700
|
update: (datum, elment, params) => {
|
|
@@ -699,7 +736,16 @@ class SemanticMark {
|
|
|
699
736
|
}
|
|
700
737
|
}
|
|
701
738
|
};
|
|
702
|
-
markSpec.layout = markLayout
|
|
739
|
+
markSpec.layout = markLayout;
|
|
740
|
+
const interactionSpec = {
|
|
741
|
+
type: "datazoom-filter",
|
|
742
|
+
source: `#${this.getComponentId(channel, "datazoom")}`,
|
|
743
|
+
target: {
|
|
744
|
+
data: this.getDataIdOfFiltered(),
|
|
745
|
+
filter: null === (_e = this.spec.encode) || void 0 === _e ? void 0 : _e[channel]
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
res.marks.push(markSpec), res.interactions.push(interactionSpec);
|
|
703
749
|
}
|
|
704
750
|
})), res;
|
|
705
751
|
}
|
|
@@ -716,7 +762,10 @@ class SemanticMark {
|
|
|
716
762
|
};
|
|
717
763
|
}
|
|
718
764
|
parseLabelSpec() {
|
|
719
|
-
const label = this.spec.label, res =
|
|
765
|
+
const label = this.spec.label, res = {
|
|
766
|
+
marks: [],
|
|
767
|
+
interactions: []
|
|
768
|
+
};
|
|
720
769
|
return label && Object.keys(label).forEach((channel => {
|
|
721
770
|
const option = label[channel];
|
|
722
771
|
if (option) {
|
|
@@ -741,7 +790,7 @@ class SemanticMark {
|
|
|
741
790
|
}
|
|
742
791
|
}
|
|
743
792
|
};
|
|
744
|
-
res.push(markSpec);
|
|
793
|
+
res.marks.push(markSpec);
|
|
745
794
|
}
|
|
746
795
|
})), res;
|
|
747
796
|
}
|
|
@@ -750,7 +799,10 @@ class SemanticMark {
|
|
|
750
799
|
}
|
|
751
800
|
parsePlayerSpec() {
|
|
752
801
|
var _a;
|
|
753
|
-
const player = this.spec.player, res =
|
|
802
|
+
const player = this.spec.player, res = {
|
|
803
|
+
marks: [],
|
|
804
|
+
interactions: []
|
|
805
|
+
};
|
|
754
806
|
if (player) {
|
|
755
807
|
const option = null == player ? void 0 : player.option, layout = null == player ? void 0 : player.layout;
|
|
756
808
|
if (option) {
|
|
@@ -761,13 +813,11 @@ class SemanticMark {
|
|
|
761
813
|
position: "bottom"
|
|
762
814
|
}, markSpec = {
|
|
763
815
|
type: "component",
|
|
816
|
+
id: this.getComponentId("", "player"),
|
|
764
817
|
componentType: vgrammar_core_1.ComponentEnum.player,
|
|
765
818
|
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX ],
|
|
766
|
-
target: {
|
|
767
|
-
data: this.getDataIdOfMain(),
|
|
768
|
-
source: this.getDataIdOfPlayer()
|
|
769
|
-
},
|
|
770
819
|
playerType: (0, vutils_1.isPlainObject)(option) && null !== (_a = option.type) && void 0 !== _a ? _a : "auto",
|
|
820
|
+
source: this.getDataIdOfPlayer(),
|
|
771
821
|
encode: {
|
|
772
822
|
update: (datum, elment, params) => {
|
|
773
823
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
@@ -804,13 +854,24 @@ class SemanticMark {
|
|
|
804
854
|
}
|
|
805
855
|
}
|
|
806
856
|
};
|
|
807
|
-
markSpec.layout = markLayout
|
|
857
|
+
markSpec.layout = markLayout;
|
|
858
|
+
const interactionSpec = {
|
|
859
|
+
type: "player-filter",
|
|
860
|
+
source: `#${this.getComponentId("", "player")}`,
|
|
861
|
+
target: {
|
|
862
|
+
data: this.getDataIdOfMain()
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
res.marks.push(markSpec), res.interactions.push(interactionSpec);
|
|
808
866
|
}
|
|
809
867
|
}
|
|
810
868
|
return res;
|
|
811
869
|
}
|
|
812
870
|
parseTitleSpec() {
|
|
813
|
-
const title = this.spec.title, res =
|
|
871
|
+
const title = this.spec.title, res = {
|
|
872
|
+
marks: [],
|
|
873
|
+
interactions: []
|
|
874
|
+
};
|
|
814
875
|
if (title) {
|
|
815
876
|
const {option: option, layout: layout} = this.parseOption(title);
|
|
816
877
|
if (option) {
|
|
@@ -844,7 +905,7 @@ class SemanticMark {
|
|
|
844
905
|
}
|
|
845
906
|
}
|
|
846
907
|
};
|
|
847
|
-
markSpec.layout = markLayout, res.push(markSpec);
|
|
908
|
+
markSpec.layout = markLayout, res.marks.push(markSpec);
|
|
848
909
|
}
|
|
849
910
|
}
|
|
850
911
|
return res;
|
|
@@ -962,11 +1023,23 @@ class SemanticMark {
|
|
|
962
1023
|
const filteredDataId = this.getDataIdOfFiltered();
|
|
963
1024
|
this.viewSpec.data = this.parseDataSpec(), this.viewSpec.scales = this.parseScaleSpec(),
|
|
964
1025
|
this.viewSpec.coordinates = this.parseCoordinateSpec();
|
|
965
|
-
let marks = [];
|
|
966
|
-
|
|
967
|
-
marks = marks.concat(
|
|
968
|
-
|
|
969
|
-
marks = marks.concat(
|
|
1026
|
+
let marks = [], interactions = [];
|
|
1027
|
+
const legendSpec = this.parseLegendSpec();
|
|
1028
|
+
marks = marks.concat(legendSpec.marks), interactions = interactions.concat(legendSpec.interactions);
|
|
1029
|
+
const axisSpec = this.parseAxisSpec();
|
|
1030
|
+
marks = marks.concat(axisSpec.marks), interactions = interactions.concat(axisSpec.interactions);
|
|
1031
|
+
const gridSpec = this.parseGridSpec();
|
|
1032
|
+
marks = marks.concat(gridSpec.marks), interactions = interactions.concat(gridSpec.interactions);
|
|
1033
|
+
const crosshairSpec = this.parseCrosshairSpec();
|
|
1034
|
+
marks = marks.concat(crosshairSpec.marks), interactions = interactions.concat(crosshairSpec.interactions);
|
|
1035
|
+
const sliderSpec = this.parseSliderSpec();
|
|
1036
|
+
marks = marks.concat(sliderSpec.marks), interactions = interactions.concat(sliderSpec.interactions);
|
|
1037
|
+
const datazoomSpec = this.parseDatazoomSpec();
|
|
1038
|
+
marks = marks.concat(datazoomSpec.marks), interactions = interactions.concat(datazoomSpec.interactions);
|
|
1039
|
+
const playerSpec = this.parsePlayerSpec();
|
|
1040
|
+
marks = marks.concat(playerSpec.marks), interactions = interactions.concat(playerSpec.interactions);
|
|
1041
|
+
const titleSpec = this.parseTitleSpec();
|
|
1042
|
+
marks = marks.concat(titleSpec.marks), interactions = interactions.concat(titleSpec.interactions),
|
|
970
1043
|
marks.push(Object.assign({
|
|
971
1044
|
id: this.getMarkId(),
|
|
972
1045
|
type: this.setMarkType(),
|
|
@@ -988,8 +1061,12 @@ class SemanticMark {
|
|
|
988
1061
|
})
|
|
989
1062
|
}, this.setMainMarkSpec()));
|
|
990
1063
|
const otherMarks = this.setMultiMarksSpec();
|
|
991
|
-
|
|
992
|
-
|
|
1064
|
+
otherMarks && (marks = marks.concat(otherMarks));
|
|
1065
|
+
const labelSpec = this.parseLabelSpec();
|
|
1066
|
+
marks = marks.concat(labelSpec.marks), interactions = interactions.concat(labelSpec.interactions);
|
|
1067
|
+
const tooltipSpec = this.parseTooltipSpec();
|
|
1068
|
+
return marks = marks.concat(tooltipSpec.marks), interactions = interactions.concat(tooltipSpec.interactions),
|
|
1069
|
+
this.viewSpec.marks = marks, this.viewSpec.interactions = interactions, this.viewSpec;
|
|
993
1070
|
}
|
|
994
1071
|
clear() {
|
|
995
1072
|
this.spec = {
|