@visactor/vgrammar-plot 0.7.7 → 0.8.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/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/es/semantic-mark.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ILogger } from '@visactor/vutils';
|
|
2
|
-
import type { ISemanticMark, ISemanticMarkSpec, ParsedSimpleEncode, WithDefaultEncode, SemanticTooltipOption, SemanticAxisOption, SemanticPlayerOption, SemanticLabelOption, SemanticDataZoomOption, SemanticSliderOption, SemanticLegendOption, SemanticCrosshairOption, CoordinateOption, AxisSpec, CrosshairSpec, DatazoomSpec,
|
|
3
|
-
import type { ITextAttribute } from '@visactor/vrender';
|
|
2
|
+
import type { ISemanticMark, ISemanticMarkSpec, ParsedSimpleEncode, WithDefaultEncode, SemanticTooltipOption, SemanticAxisOption, SemanticPlayerOption, SemanticLabelOption, SemanticDataZoomOption, SemanticSliderOption, SemanticLegendOption, SemanticCrosshairOption, CoordinateOption, AxisSpec, CrosshairSpec, DatazoomSpec, LabelSpec, LegendSpec, PlayerSpec, SliderSpec, CoordinateSpec, DataSpec, ChannelEncodeType, ScaleSpec, TransformSpec, MarkAnimationSpec, ViewSpec, MarkType, Nil, ValueOf, GenerateBaseEncodeSpec, IAnimationConfig, MarkSpec, MarkRelativeItemSpec, IPlot, SemanticGridOption, GridSpec, TitleSpec, SemanticTitleOption, InteractionSpec } from '@visactor/vgrammar-core';
|
|
3
|
+
import type { ITextAttribute } from '@visactor/vrender-core';
|
|
4
4
|
export declare abstract class SemanticMark<EncodeSpec, K extends string> implements ISemanticMark<EncodeSpec, K> {
|
|
5
5
|
spec: ISemanticMarkSpec<EncodeSpec, K>;
|
|
6
6
|
viewSpec?: ViewSpec;
|
|
@@ -29,7 +29,7 @@ export declare abstract class SemanticMark<EncodeSpec, K extends string> impleme
|
|
|
29
29
|
label(channel: string, option?: SemanticLabelOption | boolean): this;
|
|
30
30
|
player(data?: any[], option?: SemanticPlayerOption | boolean, layout?: MarkRelativeItemSpec): this;
|
|
31
31
|
title(option: SemanticTitleOption, layout?: MarkRelativeItemSpec): this;
|
|
32
|
-
protected getPalette(): import("@visactor/vrender").IColor[];
|
|
32
|
+
protected getPalette(): import("@visactor/vrender-core").IColor[];
|
|
33
33
|
abstract setMarkType(): MarkType;
|
|
34
34
|
abstract parseScaleByEncode(channel: K, option: ValueOf<WithDefaultEncode<EncodeSpec, K>, K>): ScaleSpec | Nil;
|
|
35
35
|
abstract convertMarkEncode(encode: WithDefaultEncode<EncodeSpec, K>): GenerateBaseEncodeSpec<EncodeSpec>;
|
|
@@ -48,6 +48,7 @@ export declare abstract class SemanticMark<EncodeSpec, K extends string> impleme
|
|
|
48
48
|
};
|
|
49
49
|
protected getScaleId(channel: string): any;
|
|
50
50
|
protected getMarkId(): string;
|
|
51
|
+
protected getComponentId(id: string, component?: string): string;
|
|
51
52
|
protected getScaleSpec(scaleId: string): ScaleSpec;
|
|
52
53
|
protected parseScaleOfEncodeX(option: ValueOf<WithDefaultEncode<EncodeSpec, K>, K>): ScaleSpec | Nil;
|
|
53
54
|
protected parseScaleOfEncodeY(option: ValueOf<WithDefaultEncode<EncodeSpec, K>, K>): ScaleSpec | Nil;
|
|
@@ -56,8 +57,14 @@ export declare abstract class SemanticMark<EncodeSpec, K extends string> impleme
|
|
|
56
57
|
protected parseScaleOfEncodeGroup(option: ValueOf<WithDefaultEncode<EncodeSpec, K>, K>): ScaleSpec | Nil;
|
|
57
58
|
protected parseScaleOfCommonEncode(channel: K, option: ValueOf<WithDefaultEncode<EncodeSpec, K>, K>): ScaleSpec | Nil;
|
|
58
59
|
protected setDefaultAxis(): Record<string, Partial<AxisSpec>>;
|
|
59
|
-
protected parseAxisSpec():
|
|
60
|
-
|
|
60
|
+
protected parseAxisSpec(): {
|
|
61
|
+
marks: AxisSpec[];
|
|
62
|
+
interactions: InteractionSpec[];
|
|
63
|
+
};
|
|
64
|
+
protected parseGridSpec(): {
|
|
65
|
+
marks: GridSpec[];
|
|
66
|
+
interactions: InteractionSpec[];
|
|
67
|
+
};
|
|
61
68
|
protected parseOption<T>(spec: {
|
|
62
69
|
option: T | boolean;
|
|
63
70
|
layout?: MarkRelativeItemSpec;
|
|
@@ -66,24 +73,48 @@ export declare abstract class SemanticMark<EncodeSpec, K extends string> impleme
|
|
|
66
73
|
layout: MarkRelativeItemSpec;
|
|
67
74
|
};
|
|
68
75
|
protected setDefaultLegend(): Record<string, Partial<LegendSpec>>;
|
|
69
|
-
protected parseLegendSpec():
|
|
76
|
+
protected parseLegendSpec(): {
|
|
77
|
+
marks: LegendSpec[];
|
|
78
|
+
interactions: InteractionSpec[];
|
|
79
|
+
};
|
|
70
80
|
protected setDefaultCrosshair(): Record<string, Pick<CrosshairSpec, 'crosshairShape' | 'crosshairType'>>;
|
|
71
81
|
protected getVisualChannel(channel: 'x' | 'y'): 'x' | 'y' | 'angle' | 'radius';
|
|
72
|
-
protected parseCrosshairSpec():
|
|
82
|
+
protected parseCrosshairSpec(): {
|
|
83
|
+
marks: MarkSpec[];
|
|
84
|
+
interactions: CrosshairSpec[];
|
|
85
|
+
};
|
|
73
86
|
protected setDefaultTooltip(): SemanticTooltipOption | Nil;
|
|
74
|
-
protected parseTooltipSpec():
|
|
87
|
+
protected parseTooltipSpec(): {
|
|
88
|
+
marks: MarkSpec[];
|
|
89
|
+
interactions: InteractionSpec[];
|
|
90
|
+
};
|
|
75
91
|
protected setDefaultSlider(): Record<string, Partial<SliderSpec>>;
|
|
76
|
-
protected parseSliderSpec():
|
|
92
|
+
protected parseSliderSpec(): {
|
|
93
|
+
marks: SliderSpec[];
|
|
94
|
+
interactions: InteractionSpec[];
|
|
95
|
+
};
|
|
77
96
|
protected setDefaultDataZoom(): Record<string, Partial<DatazoomSpec>>;
|
|
78
97
|
protected getVisiualPositionByDimension(channel: string): "left" | "bottom";
|
|
79
|
-
protected
|
|
98
|
+
protected parseDatazoomSpec(): {
|
|
99
|
+
marks: DatazoomSpec[];
|
|
100
|
+
interactions: InteractionSpec[];
|
|
101
|
+
};
|
|
80
102
|
protected setDefaultLabel(): Record<string, Partial<LabelSpec>>;
|
|
81
103
|
protected getLabelPosition(): string;
|
|
82
104
|
protected setLabelTextGetter(channel: string, option: SemanticLabelOption | boolean): ChannelEncodeType<ITextAttribute['text']>;
|
|
83
|
-
protected parseLabelSpec():
|
|
105
|
+
protected parseLabelSpec(): {
|
|
106
|
+
marks: LabelSpec[];
|
|
107
|
+
interactions: InteractionSpec[];
|
|
108
|
+
};
|
|
84
109
|
protected setDefaultPlayer(): Record<string, Partial<PlayerSpec>>;
|
|
85
|
-
protected parsePlayerSpec():
|
|
86
|
-
|
|
110
|
+
protected parsePlayerSpec(): {
|
|
111
|
+
marks: PlayerSpec[];
|
|
112
|
+
interactions: InteractionSpec[];
|
|
113
|
+
};
|
|
114
|
+
protected parseTitleSpec(): {
|
|
115
|
+
marks: TitleSpec[];
|
|
116
|
+
interactions: InteractionSpec[];
|
|
117
|
+
};
|
|
87
118
|
protected parseDataSpec(): DataSpec[];
|
|
88
119
|
protected parseScaleSpec(): (ScaleSpec & {
|
|
89
120
|
userScale?: ScaleSpec;
|
package/es/semantic-mark.js
CHANGED
|
@@ -187,6 +187,9 @@ export class SemanticMark {
|
|
|
187
187
|
getMarkId() {
|
|
188
188
|
return `${this.spec.id}-mark`;
|
|
189
189
|
}
|
|
190
|
+
getComponentId(id, component) {
|
|
191
|
+
return `${this.spec.id}-${null != component ? component : "component"}-${id}`;
|
|
192
|
+
}
|
|
190
193
|
getScaleSpec(scaleId) {
|
|
191
194
|
var _a, _b, _c;
|
|
192
195
|
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));
|
|
@@ -261,7 +264,10 @@ export class SemanticMark {
|
|
|
261
264
|
return {};
|
|
262
265
|
}
|
|
263
266
|
parseAxisSpec() {
|
|
264
|
-
const axis = this.spec.axis, res =
|
|
267
|
+
const axis = this.spec.axis, res = {
|
|
268
|
+
marks: [],
|
|
269
|
+
interactions: []
|
|
270
|
+
};
|
|
265
271
|
return axis && Object.keys(axis).forEach((channel => {
|
|
266
272
|
const {option: option, layout: layout} = this.parseOption(axis[channel]);
|
|
267
273
|
if (option) {
|
|
@@ -303,12 +309,15 @@ export class SemanticMark {
|
|
|
303
309
|
};
|
|
304
310
|
axisMarkSpec.layout = null != layout ? layout : {
|
|
305
311
|
position: this._coordinate ? "auto" : isPlainObject(layout) && !isNil(layout.orient) ? layout.orient : "x" === channel ? "bottom" : "left"
|
|
306
|
-
}, res.push(axisMarkSpec);
|
|
312
|
+
}, res.marks.push(axisMarkSpec);
|
|
307
313
|
}
|
|
308
314
|
})), res;
|
|
309
315
|
}
|
|
310
316
|
parseGridSpec() {
|
|
311
|
-
const grid = this.spec.grid, res =
|
|
317
|
+
const grid = this.spec.grid, res = {
|
|
318
|
+
marks: [],
|
|
319
|
+
interactions: []
|
|
320
|
+
};
|
|
312
321
|
return grid && Object.keys(grid).forEach((channel => {
|
|
313
322
|
var _a, _b, _c, _d, _e;
|
|
314
323
|
const option = grid[channel];
|
|
@@ -357,7 +366,7 @@ export class SemanticMark {
|
|
|
357
366
|
}
|
|
358
367
|
}
|
|
359
368
|
};
|
|
360
|
-
res.push(markSpec);
|
|
369
|
+
res.marks.push(markSpec);
|
|
361
370
|
}
|
|
362
371
|
})), res;
|
|
363
372
|
}
|
|
@@ -373,7 +382,10 @@ export class SemanticMark {
|
|
|
373
382
|
return {};
|
|
374
383
|
}
|
|
375
384
|
parseLegendSpec() {
|
|
376
|
-
const legend = this.spec.legend, res =
|
|
385
|
+
const legend = this.spec.legend, res = {
|
|
386
|
+
marks: [],
|
|
387
|
+
interactions: []
|
|
388
|
+
};
|
|
377
389
|
return legend && Object.keys(legend).forEach((channel => {
|
|
378
390
|
var _a;
|
|
379
391
|
const {option: option, layout: layout} = this.parseOption(legend[channel]);
|
|
@@ -392,14 +404,11 @@ export class SemanticMark {
|
|
|
392
404
|
align: "center"
|
|
393
405
|
}, markSpec = {
|
|
394
406
|
type: "component",
|
|
407
|
+
id: this.getComponentId(channel, "legend"),
|
|
395
408
|
componentType: ComponentEnum.legend,
|
|
396
409
|
scale: this.getScaleId(channel),
|
|
397
410
|
shapeScale: this.getScaleId("shape"),
|
|
398
411
|
dependency: [ SIGNAL_VIEW_BOX ],
|
|
399
|
-
target: {
|
|
400
|
-
data: this.getDataIdOfFiltered(),
|
|
401
|
-
filter: null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a[channel]
|
|
402
|
-
},
|
|
403
412
|
encode: {
|
|
404
413
|
update: (datum, element, params) => {
|
|
405
414
|
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;
|
|
@@ -424,7 +433,16 @@ export class SemanticMark {
|
|
|
424
433
|
}
|
|
425
434
|
}
|
|
426
435
|
};
|
|
427
|
-
markSpec.layout = markLayout
|
|
436
|
+
markSpec.layout = markLayout;
|
|
437
|
+
const interactionSpec = {
|
|
438
|
+
type: "legend-filter",
|
|
439
|
+
source: `#${this.getComponentId(channel, "legend")}`,
|
|
440
|
+
target: {
|
|
441
|
+
data: this.getDataIdOfFiltered(),
|
|
442
|
+
filter: null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a[channel]
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
res.marks.push(markSpec), res.interactions.push(interactionSpec);
|
|
428
446
|
}
|
|
429
447
|
})), res;
|
|
430
448
|
}
|
|
@@ -437,38 +455,38 @@ export class SemanticMark {
|
|
|
437
455
|
}
|
|
438
456
|
parseCrosshairSpec() {
|
|
439
457
|
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),
|
|
440
|
-
res)), defaultKeys) : defaultKeys, res =
|
|
458
|
+
res)), defaultKeys) : defaultKeys, res = {
|
|
459
|
+
marks: [],
|
|
460
|
+
interactions: []
|
|
461
|
+
};
|
|
441
462
|
return crosshairKeys.length && crosshairKeys.forEach((channel => {
|
|
442
463
|
var _a, _b;
|
|
443
464
|
const userOption = null === (_a = this.spec.crosshair) || void 0 === _a ? void 0 : _a[channel], option = null != userOption ? userOption : defaultCrosshair[channel];
|
|
444
465
|
if (option) {
|
|
445
|
-
const scaleId = this.getScaleId(channel), scaleSpec = this.getScaleSpec(scaleId),
|
|
446
|
-
type: "
|
|
447
|
-
componentType: ComponentEnum.crosshair,
|
|
466
|
+
const scaleId = this.getScaleId(channel), scaleSpec = this.getScaleSpec(scaleId), interactionSpec = {
|
|
467
|
+
type: "crosshair",
|
|
448
468
|
scale: this.getScaleId(channel),
|
|
449
|
-
dependency: [ SIGNAL_VIEW_BOX ],
|
|
450
469
|
crosshairShape: 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",
|
|
451
|
-
crosshairType: this.getVisualChannel(channel)
|
|
470
|
+
crosshairType: this.getVisualChannel(channel),
|
|
471
|
+
container: "#plotContainer"
|
|
452
472
|
};
|
|
453
|
-
if (isPlainObject(userOption) && (
|
|
454
|
-
|
|
455
|
-
}, "polygon" === userOption.type)) {
|
|
456
|
-
markSpec.crosshairType = "radius-polygon";
|
|
473
|
+
if (isPlainObject(userOption) && (interactionSpec.attributes = userOption, "polygon" === userOption.type)) {
|
|
474
|
+
interactionSpec.crosshairType = "radius-polygon";
|
|
457
475
|
const anotherDimScaleId = this.getScaleId("x" === channel ? "y" : "x");
|
|
458
|
-
|
|
476
|
+
interactionSpec.attributes.sides = (datum, params) => {
|
|
459
477
|
const scale = params[anotherDimScaleId];
|
|
460
478
|
return scale && isDiscrete(scale.type) ? scale.domain().length : void 0;
|
|
461
|
-
},
|
|
479
|
+
}, interactionSpec.attributes.startAngle = (datum, params) => {
|
|
462
480
|
var _a, _b;
|
|
463
481
|
const scale = params[anotherDimScaleId];
|
|
464
482
|
return scale && 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;
|
|
465
|
-
},
|
|
483
|
+
}, interactionSpec.attributes.endAngle = (datum, params) => {
|
|
466
484
|
var _a, _b;
|
|
467
485
|
const scale = params[anotherDimScaleId];
|
|
468
486
|
return scale && 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;
|
|
469
|
-
};
|
|
487
|
+
}, interactionSpec.dependencies = [ anotherDimScaleId ];
|
|
470
488
|
}
|
|
471
|
-
res.push(
|
|
489
|
+
res.interactions.push(interactionSpec);
|
|
472
490
|
}
|
|
473
491
|
})), res;
|
|
474
492
|
}
|
|
@@ -477,9 +495,12 @@ export class SemanticMark {
|
|
|
477
495
|
}
|
|
478
496
|
parseTooltipSpec() {
|
|
479
497
|
var _a, _b;
|
|
480
|
-
const defaultTooltipSpec = this.setDefaultTooltip(), userTooltipSpec = this.spec.tooltip
|
|
498
|
+
const defaultTooltipSpec = this.setDefaultTooltip(), userTooltipSpec = this.spec.tooltip, res = {
|
|
499
|
+
marks: [],
|
|
500
|
+
interactions: []
|
|
501
|
+
};
|
|
481
502
|
if (!1 !== userTooltipSpec && null !== userTooltipSpec && null !== defaultTooltipSpec) {
|
|
482
|
-
const
|
|
503
|
+
const 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 = {
|
|
483
504
|
visible: !!tooltipSpec.title || !!tooltipSpec.staticTitle,
|
|
484
505
|
key: "title",
|
|
485
506
|
value: isNil(tooltipSpec.staticTitle) ? {
|
|
@@ -490,11 +511,11 @@ export class SemanticMark {
|
|
|
490
511
|
const content = isArray(tooltipSpec.content) && tooltipSpec.content.length ? tooltipSpec.content.map(((entry, index) => ({
|
|
491
512
|
key: entry.key ? {
|
|
492
513
|
field: entry.key
|
|
493
|
-
} : isNil(tooltipSpec.staticContentKey) ? (datum,
|
|
514
|
+
} : isNil(tooltipSpec.staticContentKey) ? (datum, params) => colorAccessor ? colorAccessor(datum) : void 0 : isArray(tooltipSpec.staticContentKey) ? tooltipSpec.staticContentKey[index] : tooltipSpec.staticContentKey,
|
|
494
515
|
value: {
|
|
495
516
|
field: entry.value
|
|
496
517
|
},
|
|
497
|
-
symbol: (datum,
|
|
518
|
+
symbol: (datum, params) => {
|
|
498
519
|
var _a;
|
|
499
520
|
const scale = params[this.getScaleId(colorChannel)], shapeScale = params[this.getScaleId("shape")];
|
|
500
521
|
let symbolType = "circle";
|
|
@@ -505,41 +526,50 @@ export class SemanticMark {
|
|
|
505
526
|
};
|
|
506
527
|
}
|
|
507
528
|
}))) : null;
|
|
508
|
-
if (!0 !== tooltipSpec.disableGraphicTooltip
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
529
|
+
if (!0 !== tooltipSpec.disableGraphicTooltip) {
|
|
530
|
+
const interactionSpec = {
|
|
531
|
+
type: "tooltip",
|
|
532
|
+
selector: `#${this.getMarkId()}`,
|
|
533
|
+
title: title,
|
|
534
|
+
content: content,
|
|
535
|
+
attributes: {
|
|
536
|
+
zIndex: 1e3
|
|
537
|
+
},
|
|
538
|
+
dependencies: [ this.getScaleId(colorChannel), this.getScaleId("shape") ]
|
|
539
|
+
};
|
|
540
|
+
res.interactions.push(interactionSpec);
|
|
541
|
+
}
|
|
542
|
+
if (!0 !== tooltipSpec.disableDimensionTooltip) {
|
|
543
|
+
const channel = null !== (_a = tooltipSpec.dimensionTooltipChannel) && void 0 !== _a ? _a : "x", interactionSpec = {
|
|
544
|
+
type: "dimension-tooltip",
|
|
521
545
|
tooltipType: this.getVisualChannel(channel),
|
|
522
546
|
scale: this.getScaleId(channel),
|
|
523
|
-
dependency: dependency,
|
|
524
547
|
target: {
|
|
525
548
|
data: this.getDataIdOfFiltered(),
|
|
526
549
|
filter: null === (_b = this.spec.encode) || void 0 === _b ? void 0 : _b[channel]
|
|
527
550
|
},
|
|
528
551
|
title: title,
|
|
529
552
|
content: content,
|
|
530
|
-
avoidMark: tooltipSpec.disableGraphicTooltip ? [] : [ this.getMarkId() ],
|
|
531
|
-
|
|
532
|
-
|
|
553
|
+
avoidMark: tooltipSpec.disableGraphicTooltip ? [] : [ `#${this.getMarkId()}` ],
|
|
554
|
+
attributes: {
|
|
555
|
+
zIndex: 1e3
|
|
556
|
+
},
|
|
557
|
+
dependencies: [ this.getScaleId(colorChannel), this.getScaleId("shape") ]
|
|
558
|
+
};
|
|
559
|
+
res.interactions.push(interactionSpec);
|
|
533
560
|
}
|
|
534
561
|
return res;
|
|
535
562
|
}
|
|
536
|
-
return
|
|
563
|
+
return res;
|
|
537
564
|
}
|
|
538
565
|
setDefaultSlider() {
|
|
539
566
|
return {};
|
|
540
567
|
}
|
|
541
568
|
parseSliderSpec() {
|
|
542
|
-
const slider = this.spec.slider, res =
|
|
569
|
+
const slider = this.spec.slider, res = {
|
|
570
|
+
marks: [],
|
|
571
|
+
interactions: []
|
|
572
|
+
};
|
|
543
573
|
return slider && Object.keys(slider).forEach((channel => {
|
|
544
574
|
var _a, _b;
|
|
545
575
|
const {option: option, layout: layout} = this.parseOption(slider[channel]);
|
|
@@ -560,6 +590,7 @@ export class SemanticMark {
|
|
|
560
590
|
align: "center"
|
|
561
591
|
}, markSpec = {
|
|
562
592
|
type: "component",
|
|
593
|
+
id: this.getComponentId(channel, "slider"),
|
|
563
594
|
componentType: ComponentEnum.slider,
|
|
564
595
|
dependency: [ SIGNAL_VIEW_BOX, dataId ],
|
|
565
596
|
min: (datum, elment, params) => {
|
|
@@ -570,10 +601,6 @@ export class SemanticMark {
|
|
|
570
601
|
const data = params[dataId];
|
|
571
602
|
return Math.max.apply(null, data.map(getter));
|
|
572
603
|
},
|
|
573
|
-
target: {
|
|
574
|
-
data: this.getDataIdOfFiltered(),
|
|
575
|
-
filter: null === (_b = this.spec.encode) || void 0 === _b ? void 0 : _b[channel]
|
|
576
|
-
},
|
|
577
604
|
encode: {
|
|
578
605
|
update: (datum, elment, params) => {
|
|
579
606
|
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;
|
|
@@ -606,7 +633,16 @@ export class SemanticMark {
|
|
|
606
633
|
}
|
|
607
634
|
}
|
|
608
635
|
};
|
|
609
|
-
markSpec.layout = markLayout
|
|
636
|
+
markSpec.layout = markLayout;
|
|
637
|
+
const interactionSpec = {
|
|
638
|
+
type: "slider-filter",
|
|
639
|
+
source: `#${this.getComponentId(channel, "slider")}`,
|
|
640
|
+
target: {
|
|
641
|
+
data: this.getDataIdOfFiltered(),
|
|
642
|
+
filter: null === (_b = this.spec.encode) || void 0 === _b ? void 0 : _b[channel]
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
res.marks.push(markSpec), res.interactions.push(interactionSpec);
|
|
610
646
|
}
|
|
611
647
|
})), res;
|
|
612
648
|
}
|
|
@@ -616,8 +652,11 @@ export class SemanticMark {
|
|
|
616
652
|
getVisiualPositionByDimension(channel) {
|
|
617
653
|
return "y" === channel ? "left" : "bottom";
|
|
618
654
|
}
|
|
619
|
-
|
|
620
|
-
const datazoom = this.spec.datazoom, res =
|
|
655
|
+
parseDatazoomSpec() {
|
|
656
|
+
const datazoom = this.spec.datazoom, res = {
|
|
657
|
+
marks: [],
|
|
658
|
+
interactions: []
|
|
659
|
+
};
|
|
621
660
|
return datazoom && Object.keys(datazoom).forEach((channel => {
|
|
622
661
|
var _a, _b, _c, _d, _e;
|
|
623
662
|
const {option: option, layout: layout} = this.parseOption(datazoom[channel]);
|
|
@@ -641,12 +680,9 @@ export class SemanticMark {
|
|
|
641
680
|
};
|
|
642
681
|
const theme = this.plot ? this.plot.view.getCurrentTheme() : ThemeManager.getDefaultTheme(), markSpec = {
|
|
643
682
|
type: "component",
|
|
683
|
+
id: this.getComponentId(channel, "datazoom"),
|
|
644
684
|
componentType: ComponentEnum.datazoom,
|
|
645
685
|
dependency: [ SIGNAL_VIEW_BOX, dataId ],
|
|
646
|
-
target: {
|
|
647
|
-
data: this.getDataIdOfFiltered(),
|
|
648
|
-
filter: null === (_e = this.spec.encode) || void 0 === _e ? void 0 : _e[channel]
|
|
649
|
-
},
|
|
650
686
|
preview: preview,
|
|
651
687
|
encode: {
|
|
652
688
|
update: (datum, elment, params) => {
|
|
@@ -688,7 +724,16 @@ export class SemanticMark {
|
|
|
688
724
|
}
|
|
689
725
|
}
|
|
690
726
|
};
|
|
691
|
-
markSpec.layout = markLayout
|
|
727
|
+
markSpec.layout = markLayout;
|
|
728
|
+
const interactionSpec = {
|
|
729
|
+
type: "datazoom-filter",
|
|
730
|
+
source: `#${this.getComponentId(channel, "datazoom")}`,
|
|
731
|
+
target: {
|
|
732
|
+
data: this.getDataIdOfFiltered(),
|
|
733
|
+
filter: null === (_e = this.spec.encode) || void 0 === _e ? void 0 : _e[channel]
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
res.marks.push(markSpec), res.interactions.push(interactionSpec);
|
|
692
737
|
}
|
|
693
738
|
})), res;
|
|
694
739
|
}
|
|
@@ -705,7 +750,10 @@ export class SemanticMark {
|
|
|
705
750
|
};
|
|
706
751
|
}
|
|
707
752
|
parseLabelSpec() {
|
|
708
|
-
const label = this.spec.label, res =
|
|
753
|
+
const label = this.spec.label, res = {
|
|
754
|
+
marks: [],
|
|
755
|
+
interactions: []
|
|
756
|
+
};
|
|
709
757
|
return label && Object.keys(label).forEach((channel => {
|
|
710
758
|
const option = label[channel];
|
|
711
759
|
if (option) {
|
|
@@ -730,7 +778,7 @@ export class SemanticMark {
|
|
|
730
778
|
}
|
|
731
779
|
}
|
|
732
780
|
};
|
|
733
|
-
res.push(markSpec);
|
|
781
|
+
res.marks.push(markSpec);
|
|
734
782
|
}
|
|
735
783
|
})), res;
|
|
736
784
|
}
|
|
@@ -739,7 +787,10 @@ export class SemanticMark {
|
|
|
739
787
|
}
|
|
740
788
|
parsePlayerSpec() {
|
|
741
789
|
var _a;
|
|
742
|
-
const player = this.spec.player, res =
|
|
790
|
+
const player = this.spec.player, res = {
|
|
791
|
+
marks: [],
|
|
792
|
+
interactions: []
|
|
793
|
+
};
|
|
743
794
|
if (player) {
|
|
744
795
|
const option = null == player ? void 0 : player.option, layout = null == player ? void 0 : player.layout;
|
|
745
796
|
if (option) {
|
|
@@ -749,13 +800,11 @@ export class SemanticMark {
|
|
|
749
800
|
position: "bottom"
|
|
750
801
|
}, markSpec = {
|
|
751
802
|
type: "component",
|
|
803
|
+
id: this.getComponentId("", "player"),
|
|
752
804
|
componentType: ComponentEnum.player,
|
|
753
805
|
dependency: [ SIGNAL_VIEW_BOX ],
|
|
754
|
-
target: {
|
|
755
|
-
data: this.getDataIdOfMain(),
|
|
756
|
-
source: this.getDataIdOfPlayer()
|
|
757
|
-
},
|
|
758
806
|
playerType: isPlainObject(option) && null !== (_a = option.type) && void 0 !== _a ? _a : "auto",
|
|
807
|
+
source: this.getDataIdOfPlayer(),
|
|
759
808
|
encode: {
|
|
760
809
|
update: (datum, elment, params) => {
|
|
761
810
|
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;
|
|
@@ -792,13 +841,24 @@ export class SemanticMark {
|
|
|
792
841
|
}
|
|
793
842
|
}
|
|
794
843
|
};
|
|
795
|
-
markSpec.layout = markLayout
|
|
844
|
+
markSpec.layout = markLayout;
|
|
845
|
+
const interactionSpec = {
|
|
846
|
+
type: "player-filter",
|
|
847
|
+
source: `#${this.getComponentId("", "player")}`,
|
|
848
|
+
target: {
|
|
849
|
+
data: this.getDataIdOfMain()
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
res.marks.push(markSpec), res.interactions.push(interactionSpec);
|
|
796
853
|
}
|
|
797
854
|
}
|
|
798
855
|
return res;
|
|
799
856
|
}
|
|
800
857
|
parseTitleSpec() {
|
|
801
|
-
const title = this.spec.title, res =
|
|
858
|
+
const title = this.spec.title, res = {
|
|
859
|
+
marks: [],
|
|
860
|
+
interactions: []
|
|
861
|
+
};
|
|
802
862
|
if (title) {
|
|
803
863
|
const {option: option, layout: layout} = this.parseOption(title);
|
|
804
864
|
if (option) {
|
|
@@ -832,7 +892,7 @@ export class SemanticMark {
|
|
|
832
892
|
}
|
|
833
893
|
}
|
|
834
894
|
};
|
|
835
|
-
markSpec.layout = markLayout, res.push(markSpec);
|
|
895
|
+
markSpec.layout = markLayout, res.marks.push(markSpec);
|
|
836
896
|
}
|
|
837
897
|
}
|
|
838
898
|
return res;
|
|
@@ -948,11 +1008,23 @@ export class SemanticMark {
|
|
|
948
1008
|
const filteredDataId = this.getDataIdOfFiltered();
|
|
949
1009
|
this.viewSpec.data = this.parseDataSpec(), this.viewSpec.scales = this.parseScaleSpec(),
|
|
950
1010
|
this.viewSpec.coordinates = this.parseCoordinateSpec();
|
|
951
|
-
let marks = [];
|
|
952
|
-
|
|
953
|
-
marks = marks.concat(
|
|
954
|
-
|
|
955
|
-
marks = marks.concat(
|
|
1011
|
+
let marks = [], interactions = [];
|
|
1012
|
+
const legendSpec = this.parseLegendSpec();
|
|
1013
|
+
marks = marks.concat(legendSpec.marks), interactions = interactions.concat(legendSpec.interactions);
|
|
1014
|
+
const axisSpec = this.parseAxisSpec();
|
|
1015
|
+
marks = marks.concat(axisSpec.marks), interactions = interactions.concat(axisSpec.interactions);
|
|
1016
|
+
const gridSpec = this.parseGridSpec();
|
|
1017
|
+
marks = marks.concat(gridSpec.marks), interactions = interactions.concat(gridSpec.interactions);
|
|
1018
|
+
const crosshairSpec = this.parseCrosshairSpec();
|
|
1019
|
+
marks = marks.concat(crosshairSpec.marks), interactions = interactions.concat(crosshairSpec.interactions);
|
|
1020
|
+
const sliderSpec = this.parseSliderSpec();
|
|
1021
|
+
marks = marks.concat(sliderSpec.marks), interactions = interactions.concat(sliderSpec.interactions);
|
|
1022
|
+
const datazoomSpec = this.parseDatazoomSpec();
|
|
1023
|
+
marks = marks.concat(datazoomSpec.marks), interactions = interactions.concat(datazoomSpec.interactions);
|
|
1024
|
+
const playerSpec = this.parsePlayerSpec();
|
|
1025
|
+
marks = marks.concat(playerSpec.marks), interactions = interactions.concat(playerSpec.interactions);
|
|
1026
|
+
const titleSpec = this.parseTitleSpec();
|
|
1027
|
+
marks = marks.concat(titleSpec.marks), interactions = interactions.concat(titleSpec.interactions),
|
|
956
1028
|
marks.push(Object.assign({
|
|
957
1029
|
id: this.getMarkId(),
|
|
958
1030
|
type: this.setMarkType(),
|
|
@@ -974,8 +1046,12 @@ export class SemanticMark {
|
|
|
974
1046
|
})
|
|
975
1047
|
}, this.setMainMarkSpec()));
|
|
976
1048
|
const otherMarks = this.setMultiMarksSpec();
|
|
977
|
-
|
|
978
|
-
|
|
1049
|
+
otherMarks && (marks = marks.concat(otherMarks));
|
|
1050
|
+
const labelSpec = this.parseLabelSpec();
|
|
1051
|
+
marks = marks.concat(labelSpec.marks), interactions = interactions.concat(labelSpec.interactions);
|
|
1052
|
+
const tooltipSpec = this.parseTooltipSpec();
|
|
1053
|
+
return marks = marks.concat(tooltipSpec.marks), interactions = interactions.concat(tooltipSpec.interactions),
|
|
1054
|
+
this.viewSpec.marks = marks, this.viewSpec.interactions = interactions, this.viewSpec;
|
|
979
1055
|
}
|
|
980
1056
|
clear() {
|
|
981
1057
|
this.spec = {
|