@visactor/vgrammar-plot 0.7.0-alpha.2 → 0.7.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.d.ts +2 -2
- package/cjs/area.js +2 -2
- package/cjs/area.js.map +1 -1
- package/cjs/cell.d.ts +2 -2
- package/cjs/cell.js +2 -2
- package/cjs/cell.js.map +1 -1
- package/cjs/circle-packing.d.ts +2 -2
- package/cjs/circle-packing.js +3 -3
- package/cjs/circle-packing.js.map +1 -1
- package/cjs/image.d.ts +2 -2
- package/cjs/image.js +2 -2
- package/cjs/image.js.map +1 -1
- package/cjs/interval.d.ts +2 -2
- package/cjs/interval.js +2 -2
- package/cjs/interval.js.map +1 -1
- package/cjs/line.d.ts +2 -2
- package/cjs/line.js +2 -2
- package/cjs/line.js.map +1 -1
- package/cjs/path.d.ts +2 -2
- package/cjs/path.js +2 -2
- package/cjs/path.js.map +1 -1
- package/cjs/plot.d.ts +23 -23
- package/cjs/plot.js +27 -27
- package/cjs/plot.js.map +1 -1
- package/cjs/polygon.d.ts +2 -2
- package/cjs/polygon.js +2 -2
- package/cjs/polygon.js.map +1 -1
- package/cjs/rect-x.d.ts +2 -2
- package/cjs/rect-x.js +8 -4
- package/cjs/rect-x.js.map +1 -1
- package/cjs/rect-y.d.ts +2 -2
- package/cjs/rect-y.js +8 -4
- package/cjs/rect-y.js.map +1 -1
- package/cjs/rect.d.ts +2 -2
- package/cjs/rect.js +14 -6
- package/cjs/rect.js.map +1 -1
- package/cjs/rule-x.d.ts +2 -2
- package/cjs/rule-x.js +2 -2
- package/cjs/rule-x.js.map +1 -1
- package/cjs/rule-y.d.ts +2 -2
- package/cjs/rule-y.js +2 -2
- package/cjs/rule-y.js.map +1 -1
- package/cjs/rule.d.ts +2 -2
- package/cjs/rule.js +2 -2
- package/cjs/rule.js.map +1 -1
- package/cjs/sankey.d.ts +4 -4
- package/cjs/sankey.js +5 -5
- package/cjs/sankey.js.map +1 -1
- package/cjs/semantic-mark.d.ts +5 -1
- package/cjs/semantic-mark.js +163 -43
- package/cjs/semantic-mark.js.map +1 -1
- package/cjs/sunburst.d.ts +3 -3
- package/cjs/sunburst.js +4 -4
- package/cjs/sunburst.js.map +1 -1
- package/cjs/symbol.d.ts +2 -2
- package/cjs/symbol.js +2 -2
- package/cjs/symbol.js.map +1 -1
- package/cjs/text.d.ts +2 -2
- package/cjs/text.js +2 -2
- package/cjs/text.js.map +1 -1
- package/cjs/tree.d.ts +2 -2
- package/cjs/tree.js +4 -4
- package/cjs/tree.js.map +1 -1
- package/cjs/treemap.d.ts +3 -3
- package/cjs/treemap.js +4 -4
- package/cjs/treemap.js.map +1 -1
- package/cjs/wordcloud-shape.d.ts +2 -2
- package/cjs/wordcloud-shape.js +3 -3
- package/cjs/wordcloud-shape.js.map +1 -1
- package/cjs/wordcloud.d.ts +2 -2
- package/cjs/wordcloud.js +3 -3
- package/cjs/wordcloud.js.map +1 -1
- package/es/area.d.ts +2 -2
- package/es/area.js +1 -1
- package/es/area.js.map +1 -1
- package/es/cell.d.ts +2 -2
- package/es/cell.js +1 -1
- package/es/cell.js.map +1 -1
- package/es/circle-packing.d.ts +2 -2
- package/es/circle-packing.js +2 -2
- package/es/circle-packing.js.map +1 -1
- package/es/image.d.ts +2 -2
- package/es/image.js +1 -1
- package/es/image.js.map +1 -1
- package/es/interval.d.ts +2 -2
- package/es/interval.js +1 -1
- package/es/interval.js.map +1 -1
- package/es/line.d.ts +2 -2
- package/es/line.js +1 -1
- package/es/line.js.map +1 -1
- package/es/path.d.ts +2 -2
- package/es/path.js +1 -1
- package/es/path.js.map +1 -1
- package/es/plot.d.ts +23 -23
- package/es/plot.js +1 -1
- package/es/plot.js.map +1 -1
- package/es/polygon.d.ts +2 -2
- package/es/polygon.js +1 -1
- package/es/polygon.js.map +1 -1
- package/es/rect-x.d.ts +2 -2
- package/es/rect-x.js +9 -3
- package/es/rect-x.js.map +1 -1
- package/es/rect-y.d.ts +2 -2
- package/es/rect-y.js +9 -3
- package/es/rect-y.js.map +1 -1
- package/es/rect.d.ts +2 -2
- package/es/rect.js +15 -5
- package/es/rect.js.map +1 -1
- package/es/rule-x.d.ts +2 -2
- package/es/rule-x.js +1 -1
- package/es/rule-x.js.map +1 -1
- package/es/rule-y.d.ts +2 -2
- package/es/rule-y.js +1 -1
- package/es/rule-y.js.map +1 -1
- package/es/rule.d.ts +2 -2
- package/es/rule.js +1 -1
- package/es/rule.js.map +1 -1
- package/es/sankey.d.ts +4 -4
- package/es/sankey.js +3 -3
- package/es/sankey.js.map +1 -1
- package/es/semantic-mark.d.ts +5 -1
- package/es/semantic-mark.js +137 -18
- package/es/semantic-mark.js.map +1 -1
- package/es/sunburst.d.ts +3 -3
- package/es/sunburst.js +2 -2
- package/es/sunburst.js.map +1 -1
- package/es/symbol.d.ts +2 -2
- package/es/symbol.js +1 -1
- package/es/symbol.js.map +1 -1
- package/es/text.d.ts +2 -2
- package/es/text.js +1 -1
- package/es/text.js.map +1 -1
- package/es/tree.d.ts +2 -2
- package/es/tree.js +3 -3
- package/es/tree.js.map +1 -1
- package/es/treemap.d.ts +3 -3
- package/es/treemap.js +2 -2
- package/es/treemap.js.map +1 -1
- package/es/wordcloud-shape.d.ts +2 -2
- package/es/wordcloud-shape.js +2 -2
- package/es/wordcloud-shape.js.map +1 -1
- package/es/wordcloud.d.ts +2 -2
- package/es/wordcloud.js +2 -2
- package/es/wordcloud.js.map +1 -1
- package/package.json +8 -8
- package/dist/index.js +0 -3448
- package/dist/index.min.js +0 -1
package/cjs/semantic-mark.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.SemanticMark = void 0;
|
|
6
6
|
|
|
7
|
-
const vutils_1 = require("@visactor/vutils"), vscale_1 = require("@visactor/vscale"),
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), vscale_1 = require("@visactor/vscale"), vgrammar_core_1 = require("@visactor/vgrammar-core"), vgrammar_util_1 = require("@visactor/vgrammar-util");
|
|
8
8
|
|
|
9
9
|
let semanticMarkId = -1;
|
|
10
10
|
|
|
@@ -44,7 +44,7 @@ class SemanticMark {
|
|
|
44
44
|
return this.spec.transform = (0, vutils_1.array)(option), this;
|
|
45
45
|
}
|
|
46
46
|
state(state, option) {
|
|
47
|
-
if (![
|
|
47
|
+
if (![ vgrammar_core_1.BuiltInEncodeNames.enter, vgrammar_core_1.BuiltInEncodeNames.update, vgrammar_core_1.BuiltInEncodeNames.exit, vgrammar_core_1.BuiltInEncodeNames.group ].includes(state)) return this.spec.state || (this.spec.state = {}),
|
|
48
48
|
this.spec.state[state] = option, this;
|
|
49
49
|
this._logger.warn(`[VGrammar]: ${state} is a reserved keyword to specify the encode of different data state, \n don't use this keyword`);
|
|
50
50
|
}
|
|
@@ -54,50 +54,75 @@ class SemanticMark {
|
|
|
54
54
|
this);
|
|
55
55
|
}
|
|
56
56
|
axis(channel, option = !0, layout) {
|
|
57
|
-
return this.spec.axis || (this.spec.axis = {}),
|
|
57
|
+
return vgrammar_core_1.Factory.hasComponent("axis") ? (this.spec.axis || (this.spec.axis = {}),
|
|
58
|
+
this.spec.axis[channel] = {
|
|
58
59
|
option: option,
|
|
59
60
|
layout: layout
|
|
60
|
-
}, this;
|
|
61
|
+
}, this) : (this._logger.error('Please add this line of code: import { registerAxis } from \'@visactor/vgrammar-core\'; \n and run "registerAxis();" or "View.useRegisters([registerAxis]);" '),
|
|
62
|
+
this);
|
|
63
|
+
}
|
|
64
|
+
grid(channel, option = !0) {
|
|
65
|
+
return vgrammar_core_1.Factory.hasComponent("grid") ? (this.spec.grid || (this.spec.grid = {}),
|
|
66
|
+
this.spec.grid[channel] = option, this) : (this._logger.error('Please add this line of code: import { registerGrid } from \'@visactor/vgrammar-core\'; \n and run "registerGrid();" or "View.useRegisters([registerGrid]);" '),
|
|
67
|
+
this);
|
|
61
68
|
}
|
|
62
69
|
legend(channel, option = !0, layout) {
|
|
63
|
-
return this.spec.legend || (this.spec.legend = {}),
|
|
70
|
+
return vgrammar_core_1.Factory.hasComponent("legend") ? (this.spec.legend || (this.spec.legend = {}),
|
|
71
|
+
this.spec.legend[channel] = {
|
|
64
72
|
option: option,
|
|
65
73
|
layout: layout
|
|
66
|
-
}, this;
|
|
74
|
+
}, this) : (this._logger.error('Please add this line of code: import { registerLegend } from \'@visactor/vgrammar-core\'; \n and run "registerLegend();" or "View.useRegisters([registerLegend]);" '),
|
|
75
|
+
this);
|
|
67
76
|
}
|
|
68
77
|
crosshair(channel, option) {
|
|
69
|
-
return
|
|
70
|
-
this;
|
|
78
|
+
return vgrammar_core_1.Factory.hasComponent("crosshair") ? (this.spec.crosshair || (this.spec.crosshair = {}),
|
|
79
|
+
this.spec.crosshair[channel] = option, this) : (this._logger.error('Please add this line of code: import { registerCrosshair } from \'@visactor/vgrammar-core\'; \n and run "registerCrosshair();" or "View.useRegisters([registerCrosshair]);" '),
|
|
80
|
+
this);
|
|
71
81
|
}
|
|
72
82
|
tooltip(option) {
|
|
73
|
-
return this.spec.tooltip = option,
|
|
83
|
+
return vgrammar_core_1.Factory.hasComponent("tooltip") ? (this.spec.tooltip = option,
|
|
84
|
+
this) : (this._logger.error('Please add this line of code: import { registerTooltip } from \'@visactor/vgrammar-core\'; \n and run "registerTooltip();" or "View.useRegisters([registerTooltip]);" '),
|
|
85
|
+
this);
|
|
74
86
|
}
|
|
75
87
|
slider(channel, option, layout) {
|
|
76
|
-
return this.spec.slider || (this.spec.slider = {}),
|
|
88
|
+
return vgrammar_core_1.Factory.hasComponent("slider") ? (this.spec.slider || (this.spec.slider = {}),
|
|
89
|
+
this.spec.slider[channel] = {
|
|
77
90
|
option: option,
|
|
78
91
|
layout: layout
|
|
79
|
-
}, this;
|
|
92
|
+
}, this) : (this._logger.error('Please add this line of code: import { registerSlider } from \'@visactor/vgrammar-core\'; \n and run "registerSlider();" or "View.useRegisters([registerSlider]);" '),
|
|
93
|
+
this);
|
|
80
94
|
}
|
|
81
95
|
datazoom(channel, option, layout) {
|
|
82
|
-
return this.spec.datazoom || (this.spec.datazoom = {}),
|
|
96
|
+
return vgrammar_core_1.Factory.hasComponent("datazoom") ? (this.spec.datazoom || (this.spec.datazoom = {}),
|
|
97
|
+
this.spec.datazoom[channel] = {
|
|
83
98
|
option: option,
|
|
84
99
|
layout: layout
|
|
85
|
-
}, this;
|
|
100
|
+
}, this) : (this._logger.error('Please add this line of code: import { registerDataZoom } from \'@visactor/vgrammar-core\'; \n and run "registerDataZoom();" or "View.useRegisters([registerDataZoom]);" '),
|
|
101
|
+
this);
|
|
86
102
|
}
|
|
87
103
|
label(channel, option) {
|
|
88
|
-
return
|
|
89
|
-
this;
|
|
104
|
+
return vgrammar_core_1.Factory.hasComponent("label") ? (this.spec.label || (this.spec.label = {}),
|
|
105
|
+
this.spec.label[channel] = option, this) : (this._logger.error('Please add this line of code: import { registerLabel } from \'@visactor/vgrammar-core\'; \n and run "registerLabel();" or "View.useRegisters([registerLabel]);" '),
|
|
106
|
+
this);
|
|
90
107
|
}
|
|
91
108
|
player(data, option, layout) {
|
|
92
|
-
return this.spec.player = {
|
|
109
|
+
return vgrammar_core_1.Factory.hasComponent("player") ? (this.spec.player = {
|
|
93
110
|
data: data,
|
|
94
111
|
option: option,
|
|
95
112
|
layout: layout
|
|
96
|
-
}, this;
|
|
113
|
+
}, this) : (this._logger.error('Please add this line of code: import { registerPlayer } from \'@visactor/vgrammar-core\'; \n and run "registerPlayer();" or "View.useRegisters([registerPlayer]);" '),
|
|
114
|
+
this);
|
|
115
|
+
}
|
|
116
|
+
title(option, layout) {
|
|
117
|
+
return vgrammar_core_1.Factory.hasComponent("title") ? (this.spec.title = {
|
|
118
|
+
option: option,
|
|
119
|
+
layout: layout
|
|
120
|
+
}, this) : (this._logger.error('Please add this line of code: import { registerTitle } from \'@visactor/vgrammar-core\'; \n and run "registerTitle();" or "View.useRegisters([registerTitle]);" '),
|
|
121
|
+
this);
|
|
97
122
|
}
|
|
98
123
|
getPalette() {
|
|
99
124
|
var _a;
|
|
100
|
-
return null === (_a = (this.plot ? this.plot.view.getCurrentTheme() :
|
|
125
|
+
return null === (_a = (this.plot ? this.plot.view.getCurrentTheme() : vgrammar_core_1.ThemeManager.getDefaultTheme()).palette) || void 0 === _a ? void 0 : _a.default;
|
|
101
126
|
}
|
|
102
127
|
setDefaultDataTransform() {
|
|
103
128
|
return [];
|
|
@@ -172,7 +197,7 @@ class SemanticMark {
|
|
|
172
197
|
return {
|
|
173
198
|
type: "band",
|
|
174
199
|
id: this.getScaleId("x"),
|
|
175
|
-
dependency: [
|
|
200
|
+
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX ],
|
|
176
201
|
domain: {
|
|
177
202
|
data: this.getDataIdOfFiltered(),
|
|
178
203
|
field: option
|
|
@@ -186,7 +211,7 @@ class SemanticMark {
|
|
|
186
211
|
parseScaleOfEncodeY(option) {
|
|
187
212
|
return {
|
|
188
213
|
type: "linear",
|
|
189
|
-
dependency: [
|
|
214
|
+
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX ],
|
|
190
215
|
id: this.getScaleId("y"),
|
|
191
216
|
domain: {
|
|
192
217
|
data: this.getDataIdOfFiltered(),
|
|
@@ -244,9 +269,9 @@ class SemanticMark {
|
|
|
244
269
|
if (option) {
|
|
245
270
|
const axisMarkSpec = {
|
|
246
271
|
type: "component",
|
|
247
|
-
componentType:
|
|
272
|
+
componentType: vgrammar_core_1.ComponentEnum.axis,
|
|
248
273
|
scale: this.getScaleId(channel),
|
|
249
|
-
dependency: [
|
|
274
|
+
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX ],
|
|
250
275
|
tickCount: option.tickCount,
|
|
251
276
|
encode: {
|
|
252
277
|
update: (datum, elment, params) => {
|
|
@@ -285,6 +310,60 @@ class SemanticMark {
|
|
|
285
310
|
}
|
|
286
311
|
})), res;
|
|
287
312
|
}
|
|
313
|
+
parseGridSpec() {
|
|
314
|
+
const grid = this.spec.grid, res = [];
|
|
315
|
+
return grid && Object.keys(grid).forEach((channel => {
|
|
316
|
+
var _a, _b, _c, _d, _e;
|
|
317
|
+
const option = grid[channel];
|
|
318
|
+
if (option) {
|
|
319
|
+
const relatedAxisOption = null === (_b = this.parseOption(null === (_a = this.spec.axis) || void 0 === _a ? void 0 : _a[channel])) || void 0 === _b ? void 0 : _b.option, visiualChannel = this.getVisualChannel(channel), isCircleGrid = "radius" === visiualChannel, tickCount = null !== (_c = option.tickCount) && void 0 !== _c ? _c : null == relatedAxisOption ? void 0 : relatedAxisOption.tickCount, otherChannel = "x" === channel ? "y" : "x", otherScaleId = this.getScaleId(otherChannel), otherAxisOption = null === (_e = this.parseOption(null === (_d = this.spec.axis) || void 0 === _d ? void 0 : _d[otherChannel])) || void 0 === _e ? void 0 : _e.option, markSpec = {
|
|
320
|
+
type: "component",
|
|
321
|
+
componentType: vgrammar_core_1.ComponentEnum.grid,
|
|
322
|
+
scale: this.getScaleId(channel),
|
|
323
|
+
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX, otherScaleId ],
|
|
324
|
+
tickCount: tickCount,
|
|
325
|
+
inside: option.inside,
|
|
326
|
+
baseValue: option.baseValue,
|
|
327
|
+
gridType: "angle" === visiualChannel ? "circle" : "line",
|
|
328
|
+
gridShape: isCircleGrid ? "polygon" === option.type ? "polygon" : "circle" : "line",
|
|
329
|
+
encode: {
|
|
330
|
+
update: (datum, elment, params) => {
|
|
331
|
+
var _a, _b, _c;
|
|
332
|
+
const positionAttrs = this._coordinate ? {} : "x" === channel ? {
|
|
333
|
+
x: 0,
|
|
334
|
+
y: params.viewBox.height(),
|
|
335
|
+
start: {
|
|
336
|
+
x: 0,
|
|
337
|
+
y: 0
|
|
338
|
+
},
|
|
339
|
+
end: {
|
|
340
|
+
x: params.viewBox.width(),
|
|
341
|
+
y: 0
|
|
342
|
+
},
|
|
343
|
+
length: params.viewBox.height()
|
|
344
|
+
} : {
|
|
345
|
+
x: 0,
|
|
346
|
+
y: params.viewBox.height(),
|
|
347
|
+
start: {
|
|
348
|
+
x: 0,
|
|
349
|
+
y: 0
|
|
350
|
+
},
|
|
351
|
+
verticalFactor: -1,
|
|
352
|
+
end: {
|
|
353
|
+
x: 0,
|
|
354
|
+
y: -params.viewBox.height()
|
|
355
|
+
},
|
|
356
|
+
length: params.viewBox.width()
|
|
357
|
+
};
|
|
358
|
+
return isCircleGrid && "polygon" === option.type && (positionAttrs.sides = null !== (_a = null == option ? void 0 : option.sides) && void 0 !== _a ? _a : null === (_c = null === (_b = params[otherScaleId]) || void 0 === _b ? void 0 : _b.ticks(null == otherAxisOption ? void 0 : otherAxisOption.tickCount)) || void 0 === _c ? void 0 : _c.length),
|
|
359
|
+
(0, vutils_1.isPlainObject)(option) ? (0, vutils_1.merge)(positionAttrs, option) : positionAttrs;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
res.push(markSpec);
|
|
364
|
+
}
|
|
365
|
+
})), res;
|
|
366
|
+
}
|
|
288
367
|
parseOption(spec) {
|
|
289
368
|
let option, layout;
|
|
290
369
|
return (0, vutils_1.isPlainObject)(spec) ? (0, vutils_1.isNil)(spec.option) ? option = spec : (option = spec.option,
|
|
@@ -317,10 +396,10 @@ class SemanticMark {
|
|
|
317
396
|
align: "center"
|
|
318
397
|
}, markSpec = {
|
|
319
398
|
type: "component",
|
|
320
|
-
componentType:
|
|
399
|
+
componentType: vgrammar_core_1.ComponentEnum.legend,
|
|
321
400
|
scale: this.getScaleId(channel),
|
|
322
401
|
shapeScale: this.getScaleId("shape"),
|
|
323
|
-
dependency: [
|
|
402
|
+
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX ],
|
|
324
403
|
target: {
|
|
325
404
|
data: this.getDataIdOfFiltered(),
|
|
326
405
|
filter: null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a[channel]
|
|
@@ -369,9 +448,9 @@ class SemanticMark {
|
|
|
369
448
|
if (option) {
|
|
370
449
|
const scaleId = this.getScaleId(channel), scaleSpec = this.getScaleSpec(scaleId), markSpec = {
|
|
371
450
|
type: "component",
|
|
372
|
-
componentType:
|
|
451
|
+
componentType: vgrammar_core_1.ComponentEnum.crosshair,
|
|
373
452
|
scale: this.getScaleId(channel),
|
|
374
|
-
dependency: [
|
|
453
|
+
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX ],
|
|
375
454
|
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",
|
|
376
455
|
crosshairType: this.getVisualChannel(channel)
|
|
377
456
|
};
|
|
@@ -436,7 +515,7 @@ class SemanticMark {
|
|
|
436
515
|
}))) : null;
|
|
437
516
|
if (!0 !== tooltipSpec.disableGraphicTooltip && res.push({
|
|
438
517
|
type: "component",
|
|
439
|
-
componentType:
|
|
518
|
+
componentType: vgrammar_core_1.ComponentEnum.tooltip,
|
|
440
519
|
target: this.getMarkId(),
|
|
441
520
|
dependency: dependency,
|
|
442
521
|
title: title,
|
|
@@ -446,7 +525,7 @@ class SemanticMark {
|
|
|
446
525
|
const channel = null !== (_a = tooltipSpec.dimensionTooltipChannel) && void 0 !== _a ? _a : "x";
|
|
447
526
|
res.push({
|
|
448
527
|
type: "component",
|
|
449
|
-
componentType:
|
|
528
|
+
componentType: vgrammar_core_1.ComponentEnum.dimensionTooltip,
|
|
450
529
|
tooltipType: this.getVisualChannel(channel),
|
|
451
530
|
scale: this.getScaleId(channel),
|
|
452
531
|
dependency: dependency,
|
|
@@ -475,7 +554,7 @@ class SemanticMark {
|
|
|
475
554
|
if (option) {
|
|
476
555
|
const scaleId = this.getScaleId(channel), scaleSpec = this.getScaleSpec(scaleId), dataId = this.getDataIdOfMain();
|
|
477
556
|
if (!scaleSpec || !(0, vscale_1.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}`);
|
|
478
|
-
const theme = this.plot ? this.plot.view.getCurrentTheme() :
|
|
557
|
+
const theme = this.plot ? this.plot.view.getCurrentTheme() : vgrammar_core_1.ThemeManager.getDefaultTheme(), getter = (0,
|
|
479
558
|
vgrammar_util_1.field)(null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a[channel]), markLayout = null != layout ? layout : (0,
|
|
480
559
|
vutils_1.isPlainObject)(option) && !(0, vutils_1.isNil)(option.layout) ? "horizontal" === option.layout ? {
|
|
481
560
|
position: "top",
|
|
@@ -491,8 +570,8 @@ class SemanticMark {
|
|
|
491
570
|
align: "center"
|
|
492
571
|
}, markSpec = {
|
|
493
572
|
type: "component",
|
|
494
|
-
componentType:
|
|
495
|
-
dependency: [
|
|
573
|
+
componentType: vgrammar_core_1.ComponentEnum.slider,
|
|
574
|
+
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX, dataId ],
|
|
496
575
|
min: (datum, elment, params) => {
|
|
497
576
|
const data = params[dataId];
|
|
498
577
|
return Math.min.apply(null, data.map(getter));
|
|
@@ -571,10 +650,10 @@ class SemanticMark {
|
|
|
571
650
|
scale: x,
|
|
572
651
|
field: null !== (_d = null === (_c = this.spec.encode) || void 0 === _c ? void 0 : _c[channel]) && void 0 !== _d ? _d : channel
|
|
573
652
|
};
|
|
574
|
-
const theme = this.plot ? this.plot.view.getCurrentTheme() :
|
|
653
|
+
const theme = this.plot ? this.plot.view.getCurrentTheme() : vgrammar_core_1.ThemeManager.getDefaultTheme(), markSpec = {
|
|
575
654
|
type: "component",
|
|
576
|
-
componentType:
|
|
577
|
-
dependency: [
|
|
655
|
+
componentType: vgrammar_core_1.ComponentEnum.datazoom,
|
|
656
|
+
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX, dataId ],
|
|
578
657
|
target: {
|
|
579
658
|
data: this.getDataIdOfFiltered(),
|
|
580
659
|
filter: null === (_e = this.spec.encode) || void 0 === _e ? void 0 : _e[channel]
|
|
@@ -643,7 +722,7 @@ class SemanticMark {
|
|
|
643
722
|
if (option) {
|
|
644
723
|
const markSpec = {
|
|
645
724
|
type: "component",
|
|
646
|
-
componentType:
|
|
725
|
+
componentType: vgrammar_core_1.ComponentEnum.label,
|
|
647
726
|
target: this.getMarkId(),
|
|
648
727
|
layout: {
|
|
649
728
|
position: "content",
|
|
@@ -682,8 +761,8 @@ class SemanticMark {
|
|
|
682
761
|
position: "bottom"
|
|
683
762
|
}, markSpec = {
|
|
684
763
|
type: "component",
|
|
685
|
-
componentType:
|
|
686
|
-
dependency: [
|
|
764
|
+
componentType: vgrammar_core_1.ComponentEnum.player,
|
|
765
|
+
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX ],
|
|
687
766
|
target: {
|
|
688
767
|
data: this.getDataIdOfMain(),
|
|
689
768
|
source: this.getDataIdOfPlayer()
|
|
@@ -730,6 +809,46 @@ class SemanticMark {
|
|
|
730
809
|
}
|
|
731
810
|
return res;
|
|
732
811
|
}
|
|
812
|
+
parseTitleSpec() {
|
|
813
|
+
const title = this.spec.title, res = [];
|
|
814
|
+
if (title) {
|
|
815
|
+
const {option: option, layout: layout} = this.parseOption(title);
|
|
816
|
+
if (option) {
|
|
817
|
+
const markLayout = null != layout ? layout : {
|
|
818
|
+
position: "top"
|
|
819
|
+
}, markSpec = {
|
|
820
|
+
type: "component",
|
|
821
|
+
componentType: vgrammar_core_1.ComponentEnum.title,
|
|
822
|
+
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX ],
|
|
823
|
+
title: option.text,
|
|
824
|
+
subTitle: option.subtext,
|
|
825
|
+
encode: {
|
|
826
|
+
update: (datum, elment, params) => {
|
|
827
|
+
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;
|
|
828
|
+
const calculatedAttrs = "left" === markLayout.position ? {
|
|
829
|
+
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,
|
|
830
|
+
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
|
|
831
|
+
} : "right" === markLayout.position ? {
|
|
832
|
+
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(),
|
|
833
|
+
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
|
|
834
|
+
} : "bottom" === markLayout.position ? {
|
|
835
|
+
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,
|
|
836
|
+
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(),
|
|
837
|
+
width: params.viewBox.width()
|
|
838
|
+
} : {
|
|
839
|
+
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,
|
|
840
|
+
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,
|
|
841
|
+
width: params.viewBox.width()
|
|
842
|
+
};
|
|
843
|
+
return (0, vutils_1.isPlainObject)(option) ? (0, vutils_1.merge)({}, calculatedAttrs, option) : calculatedAttrs;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
markSpec.layout = markLayout, res.push(markSpec);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
return res;
|
|
851
|
+
}
|
|
733
852
|
parseDataSpec() {
|
|
734
853
|
var _a;
|
|
735
854
|
const {data: data, player: player} = this.spec, res = [];
|
|
@@ -784,10 +903,10 @@ class SemanticMark {
|
|
|
784
903
|
data: this.getDataIdOfMain(),
|
|
785
904
|
field: encode[k]
|
|
786
905
|
},
|
|
787
|
-
dependency: [
|
|
906
|
+
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX ],
|
|
788
907
|
range: (scale, params) => [ 0, params.viewBox.width() ]
|
|
789
908
|
}, encode.y) {
|
|
790
|
-
const theme = this.plot ? this.plot.view.getCurrentTheme() :
|
|
909
|
+
const theme = this.plot ? this.plot.view.getCurrentTheme() : vgrammar_core_1.ThemeManager.getDefaultTheme();
|
|
791
910
|
scales[yScaleId] = {
|
|
792
911
|
type: null !== (_b = null === (_a = scales[this.getScaleId("y")]) || void 0 === _a ? void 0 : _a.type) && void 0 !== _b ? _b : "linear",
|
|
793
912
|
id: yScaleId,
|
|
@@ -819,7 +938,7 @@ class SemanticMark {
|
|
|
819
938
|
type: null !== (_a = this._coordinate.type) && void 0 !== _a ? _a : "cartesian",
|
|
820
939
|
transpose: this._coordinate.transpose,
|
|
821
940
|
id: this._coordinate.id,
|
|
822
|
-
dependency: [
|
|
941
|
+
dependency: [ vgrammar_core_1.SIGNAL_VIEW_BOX ],
|
|
823
942
|
start: [ 0, 0 ],
|
|
824
943
|
end: (coord, params) => [ params.viewBox.width(), params.viewBox.height() ]
|
|
825
944
|
};
|
|
@@ -845,8 +964,9 @@ class SemanticMark {
|
|
|
845
964
|
this.viewSpec.coordinates = this.parseCoordinateSpec();
|
|
846
965
|
let marks = [];
|
|
847
966
|
marks = marks.concat(this.parseLegendSpec()), marks = marks.concat(this.parseAxisSpec()),
|
|
848
|
-
marks = marks.concat(this.
|
|
849
|
-
marks = marks.concat(this.
|
|
967
|
+
marks = marks.concat(this.parseGridSpec()), marks = marks.concat(this.parseCrosshairSpec()),
|
|
968
|
+
marks = marks.concat(this.parseSliderSpec()), marks = marks.concat(this.parseDataZoomSpec()),
|
|
969
|
+
marks = marks.concat(this.parsePlayerSpec()), marks = marks.concat(this.parseTitleSpec()),
|
|
850
970
|
marks.push(Object.assign({
|
|
851
971
|
id: this.getMarkId(),
|
|
852
972
|
type: this.setMarkType(),
|
|
@@ -859,7 +979,7 @@ class SemanticMark {
|
|
|
859
979
|
position: "content",
|
|
860
980
|
skipBeforeLayouted: !0
|
|
861
981
|
},
|
|
862
|
-
dependency: this.viewSpec.scales.map((scale => scale.id)).concat(
|
|
982
|
+
dependency: this.viewSpec.scales.map((scale => scale.id)).concat(vgrammar_core_1.SIGNAL_VIEW_BOX),
|
|
863
983
|
transform: this.convertMarkTransform(this.spec.transform, this.setDefaultMarkTransform()),
|
|
864
984
|
animation: this.convertMarkAnimation(),
|
|
865
985
|
encode: Object.assign({}, this.spec.state, {
|