@visactor/vgrammar-plot 0.6.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.
Files changed (173) hide show
  1. package/README.md +3 -0
  2. package/README.zh-CN.md +0 -0
  3. package/cjs/area.d.ts +14 -0
  4. package/cjs/area.js +83 -0
  5. package/cjs/area.js.map +1 -0
  6. package/cjs/cell.d.ts +14 -0
  7. package/cjs/cell.js +51 -0
  8. package/cjs/cell.js.map +1 -0
  9. package/cjs/circle-packing.d.ts +17 -0
  10. package/cjs/circle-packing.js +76 -0
  11. package/cjs/circle-packing.js.map +1 -0
  12. package/cjs/enums.d.ts +24 -0
  13. package/cjs/enums.js +17 -0
  14. package/cjs/enums.js.map +1 -0
  15. package/cjs/image.d.ts +13 -0
  16. package/cjs/image.js +77 -0
  17. package/cjs/image.js.map +1 -0
  18. package/cjs/index.d.ts +1 -0
  19. package/cjs/index.js +15 -0
  20. package/cjs/index.js.map +1 -0
  21. package/cjs/interval.d.ts +19 -0
  22. package/cjs/interval.js +102 -0
  23. package/cjs/interval.js.map +1 -0
  24. package/cjs/line.d.ts +14 -0
  25. package/cjs/line.js +52 -0
  26. package/cjs/line.js.map +1 -0
  27. package/cjs/path.d.ts +11 -0
  28. package/cjs/path.js +25 -0
  29. package/cjs/path.js.map +1 -0
  30. package/cjs/plot-all.d.ts +2 -0
  31. package/cjs/plot-all.js +19 -0
  32. package/cjs/plot-all.js.map +1 -0
  33. package/cjs/plot.d.ts +46 -0
  34. package/cjs/plot.js +265 -0
  35. package/cjs/plot.js.map +1 -0
  36. package/cjs/polygon.d.ts +12 -0
  37. package/cjs/polygon.js +44 -0
  38. package/cjs/polygon.js.map +1 -0
  39. package/cjs/rect-x.d.ts +13 -0
  40. package/cjs/rect-x.js +67 -0
  41. package/cjs/rect-x.js.map +1 -0
  42. package/cjs/rect-y.d.ts +13 -0
  43. package/cjs/rect-y.js +67 -0
  44. package/cjs/rect-y.js.map +1 -0
  45. package/cjs/rect.d.ts +13 -0
  46. package/cjs/rect.js +82 -0
  47. package/cjs/rect.js.map +1 -0
  48. package/cjs/rule-x.d.ts +12 -0
  49. package/cjs/rule-x.js +37 -0
  50. package/cjs/rule-x.js.map +1 -0
  51. package/cjs/rule-y.d.ts +12 -0
  52. package/cjs/rule-y.js +36 -0
  53. package/cjs/rule-y.js.map +1 -0
  54. package/cjs/rule.d.ts +12 -0
  55. package/cjs/rule.js +45 -0
  56. package/cjs/rule.js.map +1 -0
  57. package/cjs/sankey.d.ts +46 -0
  58. package/cjs/sankey.js +139 -0
  59. package/cjs/sankey.js.map +1 -0
  60. package/cjs/semantic-mark.d.ts +88 -0
  61. package/cjs/semantic-mark.js +846 -0
  62. package/cjs/semantic-mark.js.map +1 -0
  63. package/cjs/sunburst.d.ts +45 -0
  64. package/cjs/sunburst.js +134 -0
  65. package/cjs/sunburst.js.map +1 -0
  66. package/cjs/symbol.d.ts +13 -0
  67. package/cjs/symbol.js +53 -0
  68. package/cjs/symbol.js.map +1 -0
  69. package/cjs/text.d.ts +12 -0
  70. package/cjs/text.js +32 -0
  71. package/cjs/text.js.map +1 -0
  72. package/cjs/tree.d.ts +20 -0
  73. package/cjs/tree.js +128 -0
  74. package/cjs/tree.js.map +1 -0
  75. package/cjs/treemap.d.ts +41 -0
  76. package/cjs/treemap.js +109 -0
  77. package/cjs/treemap.js.map +1 -0
  78. package/cjs/util.d.ts +3 -0
  79. package/cjs/util.js +11 -0
  80. package/cjs/util.js.map +1 -0
  81. package/cjs/wordcloud-shape.d.ts +13 -0
  82. package/cjs/wordcloud-shape.js +85 -0
  83. package/cjs/wordcloud-shape.js.map +1 -0
  84. package/cjs/wordcloud.d.ts +13 -0
  85. package/cjs/wordcloud.js +81 -0
  86. package/cjs/wordcloud.js.map +1 -0
  87. package/dist/index.js +3291 -0
  88. package/dist/index.min.js +1 -0
  89. package/es/area.d.ts +14 -0
  90. package/es/area.js +83 -0
  91. package/es/area.js.map +1 -0
  92. package/es/cell.d.ts +14 -0
  93. package/es/cell.js +49 -0
  94. package/es/cell.js.map +1 -0
  95. package/es/circle-packing.d.ts +17 -0
  96. package/es/circle-packing.js +75 -0
  97. package/es/circle-packing.js.map +1 -0
  98. package/es/enums.d.ts +24 -0
  99. package/es/enums.js +13 -0
  100. package/es/enums.js.map +1 -0
  101. package/es/image.d.ts +13 -0
  102. package/es/image.js +74 -0
  103. package/es/image.js.map +1 -0
  104. package/es/index.d.ts +1 -0
  105. package/es/index.js +2 -0
  106. package/es/index.js.map +1 -0
  107. package/es/interval.d.ts +19 -0
  108. package/es/interval.js +103 -0
  109. package/es/interval.js.map +1 -0
  110. package/es/line.d.ts +14 -0
  111. package/es/line.js +50 -0
  112. package/es/line.js.map +1 -0
  113. package/es/path.d.ts +11 -0
  114. package/es/path.js +23 -0
  115. package/es/path.js.map +1 -0
  116. package/es/plot-all.d.ts +2 -0
  117. package/es/plot-all.js +50 -0
  118. package/es/plot-all.js.map +1 -0
  119. package/es/plot.d.ts +46 -0
  120. package/es/plot.js +263 -0
  121. package/es/plot.js.map +1 -0
  122. package/es/polygon.d.ts +12 -0
  123. package/es/polygon.js +43 -0
  124. package/es/polygon.js.map +1 -0
  125. package/es/rect-x.d.ts +13 -0
  126. package/es/rect-x.js +69 -0
  127. package/es/rect-x.js.map +1 -0
  128. package/es/rect-y.d.ts +13 -0
  129. package/es/rect-y.js +69 -0
  130. package/es/rect-y.js.map +1 -0
  131. package/es/rect.d.ts +13 -0
  132. package/es/rect.js +84 -0
  133. package/es/rect.js.map +1 -0
  134. package/es/rule-x.d.ts +12 -0
  135. package/es/rule-x.js +35 -0
  136. package/es/rule-x.js.map +1 -0
  137. package/es/rule-y.d.ts +12 -0
  138. package/es/rule-y.js +34 -0
  139. package/es/rule-y.js.map +1 -0
  140. package/es/rule.d.ts +12 -0
  141. package/es/rule.js +45 -0
  142. package/es/rule.js.map +1 -0
  143. package/es/sankey.d.ts +46 -0
  144. package/es/sankey.js +137 -0
  145. package/es/sankey.js.map +1 -0
  146. package/es/semantic-mark.d.ts +88 -0
  147. package/es/semantic-mark.js +833 -0
  148. package/es/semantic-mark.js.map +1 -0
  149. package/es/sunburst.d.ts +45 -0
  150. package/es/sunburst.js +133 -0
  151. package/es/sunburst.js.map +1 -0
  152. package/es/symbol.d.ts +13 -0
  153. package/es/symbol.js +51 -0
  154. package/es/symbol.js.map +1 -0
  155. package/es/text.d.ts +12 -0
  156. package/es/text.js +30 -0
  157. package/es/text.js.map +1 -0
  158. package/es/tree.d.ts +20 -0
  159. package/es/tree.js +127 -0
  160. package/es/tree.js.map +1 -0
  161. package/es/treemap.d.ts +41 -0
  162. package/es/treemap.js +108 -0
  163. package/es/treemap.js.map +1 -0
  164. package/es/util.d.ts +3 -0
  165. package/es/util.js +3 -0
  166. package/es/util.js.map +1 -0
  167. package/es/wordcloud-shape.d.ts +13 -0
  168. package/es/wordcloud-shape.js +84 -0
  169. package/es/wordcloud-shape.js.map +1 -0
  170. package/es/wordcloud.d.ts +13 -0
  171. package/es/wordcloud.js +80 -0
  172. package/es/wordcloud.js.map +1 -0
  173. package/package.json +73 -0
@@ -0,0 +1,846 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.SemanticMark = void 0;
6
+
7
+ const vutils_1 = require("@visactor/vutils"), vscale_1 = require("@visactor/vscale"), vgrammar_1 = require("@visactor/vgrammar"), vgrammar_util_1 = require("@visactor/vgrammar-util"), defaultTheme = (0,
8
+ vgrammar_1.getTheme)("default");
9
+
10
+ let semanticMarkId = -1;
11
+
12
+ class SemanticMark {
13
+ constructor(type, id) {
14
+ this.type = type, this.uid = ++semanticMarkId, this._logger = vutils_1.Logger.getInstance(),
15
+ this.spec = {
16
+ id: null != id ? id : `${this.type}-${this.uid}`
17
+ };
18
+ }
19
+ parseSpec(spec) {
20
+ return (0, vutils_1.isNil)(spec.id) && (spec.id = this.spec.id), this.spec = spec,
21
+ this;
22
+ }
23
+ coordinate(option) {
24
+ return this._coordinate = option, this;
25
+ }
26
+ data(values, transform, id) {
27
+ return (0, vutils_1.isNil)(values) || (this.spec.data = {
28
+ values: values,
29
+ transform: transform,
30
+ id: id
31
+ }), this;
32
+ }
33
+ encode(channel, option) {
34
+ return this.spec.encode || (this.spec.encode = {}), this.spec.encode[channel] = option,
35
+ this;
36
+ }
37
+ scale(channel, option) {
38
+ return this.spec.scale || (this.spec.scale = {}), this.spec.scale[channel] = option,
39
+ this;
40
+ }
41
+ style(style) {
42
+ return this.spec.style = style, this;
43
+ }
44
+ transform(option) {
45
+ return this.spec.transform = (0, vutils_1.array)(option), this;
46
+ }
47
+ state(state, option) {
48
+ if (![ vgrammar_1.BuiltInEncodeNames.enter, vgrammar_1.BuiltInEncodeNames.update, vgrammar_1.BuiltInEncodeNames.exit, vgrammar_1.BuiltInEncodeNames.group ].includes(state)) return this.spec.state || (this.spec.state = {}),
49
+ this.spec.state[state] = option, this;
50
+ this._logger.warn(`[VGrammar]: ${state} is a reserved keyword to specify the encode of different data state, \n don't use this keyword`);
51
+ }
52
+ animate(state, option) {
53
+ return "state" === state ? (this._logger.warn(`[VGrammar]: ${state} is a keyword use to specify state animation config, don't use this keyword`),
54
+ this) : (this.spec.animation || (this.spec.animation = {}), this.spec.animation[state] = option,
55
+ this);
56
+ }
57
+ axis(channel, option = !0, layout) {
58
+ return this.spec.axis || (this.spec.axis = {}), this.spec.axis[channel] = {
59
+ option: option,
60
+ layout: layout
61
+ }, this;
62
+ }
63
+ legend(channel, option = !0, layout) {
64
+ return this.spec.legend || (this.spec.legend = {}), this.spec.legend[channel] = {
65
+ option: option,
66
+ layout: layout
67
+ }, this;
68
+ }
69
+ crosshair(channel, option) {
70
+ return this.spec.crosshair || (this.spec.crosshair = {}), this.spec.crosshair[channel] = option,
71
+ this;
72
+ }
73
+ tooltip(option) {
74
+ return this.spec.tooltip = option, this;
75
+ }
76
+ slider(channel, option, layout) {
77
+ return this.spec.slider || (this.spec.slider = {}), this.spec.slider[channel] = {
78
+ option: option,
79
+ layout: layout
80
+ }, this;
81
+ }
82
+ datazoom(channel, option, layout) {
83
+ return this.spec.datazoom || (this.spec.datazoom = {}), this.spec.datazoom[channel] = {
84
+ option: option,
85
+ layout: layout
86
+ }, this;
87
+ }
88
+ label(channel, option) {
89
+ return this.spec.label || (this.spec.label = {}), this.spec.label[channel] = option,
90
+ this;
91
+ }
92
+ player(data, option, layout) {
93
+ return this.spec.player = {
94
+ data: data,
95
+ option: option,
96
+ layout: layout
97
+ }, this;
98
+ }
99
+ setDefaultDataTransform() {
100
+ return [];
101
+ }
102
+ setMultipleData() {
103
+ return null;
104
+ }
105
+ setDefaultMarkTransform() {
106
+ return [];
107
+ }
108
+ convertMarkTransform(userTransform, defaultTransform = []) {
109
+ if (defaultTransform && defaultTransform.length) {
110
+ if (userTransform && userTransform.length) {
111
+ let transforms = [];
112
+ const excludeIndex = [];
113
+ for (let i = 0, len = userTransform.length; i < len; i++) {
114
+ const customizedSpec = userTransform[i], index = defaultTransform.findIndex((entry => entry.type === customizedSpec.type));
115
+ index >= 0 ? (transforms.push(Object.assign({}, defaultTransform[index], customizedSpec)),
116
+ excludeIndex.push(index)) : transforms.push(customizedSpec);
117
+ }
118
+ for (let j = 0, dlen = defaultTransform.length; j < dlen; j++) excludeIndex.includes(j) || (transforms = [ defaultTransform[j] ].concat(transforms));
119
+ return transforms;
120
+ }
121
+ return defaultTransform;
122
+ }
123
+ return userTransform;
124
+ }
125
+ convertMarkAnimation() {
126
+ return this.spec.animation ? this.spec.animation : null;
127
+ }
128
+ convertSimpleMarkEncode(encode) {
129
+ if (!encode) return {};
130
+ const markEncoder = {};
131
+ return Object.keys(encode).map((channel => {
132
+ markEncoder[channel] = {
133
+ field: encode[channel],
134
+ scale: this.getScaleId(channel)
135
+ };
136
+ })), markEncoder;
137
+ }
138
+ getDataIdOfFiltered() {
139
+ var _a, _b;
140
+ return `${null !== (_b = null === (_a = this.spec.data) || void 0 === _a ? void 0 : _a.id) && void 0 !== _b ? _b : this.spec.id}-data-filtered`;
141
+ }
142
+ getDataIdOfMain() {
143
+ var _a, _b;
144
+ return `${null !== (_b = null === (_a = this.spec.data) || void 0 === _a ? void 0 : _a.id) && void 0 !== _b ? _b : this.spec.id}-data`;
145
+ }
146
+ getDataIdOfPlayer() {
147
+ var _a, _b;
148
+ return `${null !== (_b = null === (_a = this.spec.data) || void 0 === _a ? void 0 : _a.id) && void 0 !== _b ? _b : this.spec.id}-player`;
149
+ }
150
+ getDataZoomScaleId(channel) {
151
+ return {
152
+ x: `datazoom-scale-${channel}-x`,
153
+ y: `datazoom-scale-${channel}-y`
154
+ };
155
+ }
156
+ getScaleId(channel) {
157
+ var _a, _b, _c;
158
+ return null !== (_c = null === (_b = null === (_a = this.spec.scale) || void 0 === _a ? void 0 : _a[channel]) || void 0 === _b ? void 0 : _b.id) && void 0 !== _c ? _c : `scale-${channel}`;
159
+ }
160
+ getMarkId() {
161
+ return `${this.spec.id}-mark`;
162
+ }
163
+ getScaleSpec(scaleId) {
164
+ var _a, _b, _c;
165
+ 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));
166
+ }
167
+ parseScaleOfEncodeX(option) {
168
+ return {
169
+ type: "band",
170
+ id: this.getScaleId("x"),
171
+ dependency: [ vgrammar_1.SIGNAL_VIEW_BOX ],
172
+ domain: {
173
+ data: this.getDataIdOfFiltered(),
174
+ field: option
175
+ },
176
+ range: this._coordinate ? {
177
+ coordinate: this._coordinate.id,
178
+ dimension: "x"
179
+ } : (scale, params) => [ 0, params.viewBox.width() ]
180
+ };
181
+ }
182
+ parseScaleOfEncodeY(option) {
183
+ return {
184
+ type: "linear",
185
+ dependency: [ vgrammar_1.SIGNAL_VIEW_BOX ],
186
+ id: this.getScaleId("y"),
187
+ domain: {
188
+ data: this.getDataIdOfFiltered(),
189
+ field: option
190
+ },
191
+ range: this._coordinate ? {
192
+ coordinate: this._coordinate.id,
193
+ dimension: "y"
194
+ } : (scale, params) => [ params.viewBox.height(), 0 ]
195
+ };
196
+ }
197
+ parseScaleOfEncodeColor(option) {
198
+ return {
199
+ type: "ordinal",
200
+ id: this.getScaleId("color"),
201
+ domain: {
202
+ data: this.getDataIdOfMain(),
203
+ field: option
204
+ },
205
+ range: (0, vgrammar_1.getPalette)()
206
+ };
207
+ }
208
+ parseScaleOfEncodeGroup(option) {
209
+ return {
210
+ type: "ordinal",
211
+ id: this.getScaleId("group"),
212
+ domain: {
213
+ data: this.getDataIdOfMain(),
214
+ field: option
215
+ },
216
+ range: (0, vgrammar_1.getPalette)()
217
+ };
218
+ }
219
+ 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;
221
+ }
222
+ setDefaultAxis() {
223
+ return {};
224
+ }
225
+ parseAxisSpec() {
226
+ const axis = this.spec.axis, res = [];
227
+ return axis && Object.keys(axis).forEach((channel => {
228
+ const {option: option, layout: layout} = this.parseOption(axis[channel]);
229
+ if (option) {
230
+ const axisMarkSpec = {
231
+ type: "component",
232
+ componentType: vgrammar_1.ComponentEnum.axis,
233
+ scale: this.getScaleId(channel),
234
+ dependency: [ vgrammar_1.SIGNAL_VIEW_BOX ],
235
+ tickCount: option.tickCount,
236
+ encode: {
237
+ update: (datum, elment, params) => {
238
+ const positionAttrs = this._coordinate ? {} : "x" === channel ? {
239
+ x: 0,
240
+ y: params.viewBox.height(),
241
+ start: {
242
+ x: 0,
243
+ y: 0
244
+ },
245
+ end: {
246
+ x: params.viewBox.width(),
247
+ y: 0
248
+ }
249
+ } : {
250
+ x: 0,
251
+ y: params.viewBox.height(),
252
+ start: {
253
+ x: 0,
254
+ y: 0
255
+ },
256
+ verticalFactor: -1,
257
+ end: {
258
+ x: 0,
259
+ y: -params.viewBox.height()
260
+ }
261
+ };
262
+ return (0, vutils_1.isPlainObject)(option) ? Object.assign(positionAttrs, option) : positionAttrs;
263
+ }
264
+ }
265
+ };
266
+ axisMarkSpec.layout = null != layout ? layout : {
267
+ position: this._coordinate ? "auto" : (0, vutils_1.isPlainObject)(layout) && !(0,
268
+ vutils_1.isNil)(layout.orient) ? layout.orient : "x" === channel ? "bottom" : "left"
269
+ }, res.push(axisMarkSpec);
270
+ }
271
+ })), res;
272
+ }
273
+ parseOption(spec) {
274
+ let option, layout;
275
+ return (0, vutils_1.isPlainObject)(spec) ? (0, vutils_1.isNil)(spec.option) ? option = spec : (option = spec.option,
276
+ layout = spec.layout) : option = spec, {
277
+ option: option,
278
+ layout: layout
279
+ };
280
+ }
281
+ setDefaultLegend() {
282
+ return {};
283
+ }
284
+ parseLegendSpec() {
285
+ const legend = this.spec.legend, res = [];
286
+ return legend && Object.keys(legend).forEach((channel => {
287
+ var _a;
288
+ const {option: option, layout: layout} = this.parseOption(legend[channel]);
289
+ if (option) {
290
+ const markLayout = null != layout ? layout : (0, vutils_1.isPlainObject)(option) && !(0,
291
+ vutils_1.isNil)(option.layout) ? "horizontal" === option.layout ? {
292
+ position: "top",
293
+ align: "center"
294
+ } : "vertical" === option.layout ? {
295
+ position: "right",
296
+ align: "middle"
297
+ } : {
298
+ position: "top",
299
+ align: "center"
300
+ } : {
301
+ position: "top",
302
+ align: "center"
303
+ }, markSpec = {
304
+ type: "component",
305
+ componentType: vgrammar_1.ComponentEnum.legend,
306
+ scale: this.getScaleId(channel),
307
+ dependency: [ vgrammar_1.SIGNAL_VIEW_BOX ],
308
+ target: {
309
+ data: this.getDataIdOfFiltered(),
310
+ filter: null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a[channel]
311
+ },
312
+ encode: {
313
+ update: (datum, element, params) => {
314
+ 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;
315
+ const calculatedAttrs = "left" === markLayout.position ? {
316
+ layout: "vertical",
317
+ x: null !== (_c = null === (_b = null === (_a = element.mark) || void 0 === _a ? void 0 : _a.relativePosition) || void 0 === _b ? void 0 : _b.left) && void 0 !== _c ? _c : 0,
318
+ y: null !== (_f = null === (_e = null === (_d = element.mark) || void 0 === _d ? void 0 : _d.relativePosition) || void 0 === _e ? void 0 : _e.top) && void 0 !== _f ? _f : 0
319
+ } : "right" === markLayout.position ? {
320
+ layout: "vertical",
321
+ x: null !== (_j = null === (_h = null === (_g = element.mark) || void 0 === _g ? void 0 : _g.relativePosition) || void 0 === _h ? void 0 : _h.left) && void 0 !== _j ? _j : params.viewBox.width(),
322
+ y: null !== (_m = null === (_l = null === (_k = element.mark) || void 0 === _k ? void 0 : _k.relativePosition) || void 0 === _l ? void 0 : _l.top) && void 0 !== _m ? _m : 0
323
+ } : "bottom" === markLayout.position ? {
324
+ layout: "horizontal",
325
+ x: null !== (_q = null === (_p = null === (_o = element.mark) || void 0 === _o ? void 0 : _o.relativePosition) || void 0 === _p ? void 0 : _p.left) && void 0 !== _q ? _q : 0,
326
+ y: null !== (_t = null === (_s = null === (_r = element.mark) || void 0 === _r ? void 0 : _r.relativePosition) || void 0 === _s ? void 0 : _s.top) && void 0 !== _t ? _t : params.viewBox.height()
327
+ } : {
328
+ layout: "horizontal",
329
+ 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,
330
+ 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
331
+ };
332
+ return (0, vutils_1.isPlainObject)(option) ? Object.assign({}, calculatedAttrs, option) : calculatedAttrs;
333
+ }
334
+ }
335
+ };
336
+ markSpec.layout = markLayout, res.push(markSpec);
337
+ }
338
+ })), res;
339
+ }
340
+ setDefaultCrosshair() {
341
+ return {};
342
+ }
343
+ getVisualChannel(channel) {
344
+ var _a, _b;
345
+ return "polar" === (null === (_a = this._coordinate) || void 0 === _a ? void 0 : _a.type) ? this._coordinate.transpose ? "x" === channel ? "radius" : "angle" : "x" === channel ? "angle" : "radius" : (null === (_b = this._coordinate) || void 0 === _b ? void 0 : _b.transpose) ? "x" === channel ? "y" : "x" : channel;
346
+ }
347
+ parseCrosshairSpec() {
348
+ 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),
349
+ res)), defaultKeys) : defaultKeys, res = [];
350
+ return crosshairKeys.length && crosshairKeys.forEach((channel => {
351
+ var _a, _b;
352
+ const userOption = null === (_a = this.spec.crosshair) || void 0 === _a ? void 0 : _a[channel], option = null != userOption ? userOption : defaultCrosshair[channel];
353
+ if (option) {
354
+ const scaleId = this.getScaleId(channel), scaleSpec = this.getScaleSpec(scaleId), markSpec = {
355
+ type: "component",
356
+ componentType: vgrammar_1.ComponentEnum.crosshair,
357
+ scale: this.getScaleId(channel),
358
+ dependency: [ vgrammar_1.SIGNAL_VIEW_BOX ],
359
+ 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",
360
+ crosshairType: this.getVisualChannel(channel)
361
+ };
362
+ if ((0, vutils_1.isPlainObject)(userOption) && (markSpec.encode = {
363
+ update: userOption
364
+ }, "polygon" === userOption.type)) {
365
+ markSpec.crosshairType = "radius-polygon";
366
+ const anotherDimScaleId = this.getScaleId("x" === channel ? "y" : "x");
367
+ markSpec.dependency.push(anotherDimScaleId), markSpec.encode.update.sides = (datum, el, params) => {
368
+ const scale = params[anotherDimScaleId];
369
+ return scale && (0, vscale_1.isDiscrete)(scale.type) ? scale.domain().length : void 0;
370
+ }, markSpec.encode.update.startAngle = (datum, el, params) => {
371
+ var _a, _b;
372
+ const scale = params[anotherDimScaleId];
373
+ 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;
374
+ }, markSpec.encode.update.endAngle = (datum, el, params) => {
375
+ var _a, _b;
376
+ const scale = params[anotherDimScaleId];
377
+ 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;
378
+ };
379
+ }
380
+ res.push(markSpec);
381
+ }
382
+ })), res;
383
+ }
384
+ setDefaultTooltip() {
385
+ return null;
386
+ }
387
+ parseTooltipSpec() {
388
+ var _a;
389
+ const defaultTooltipSpec = this.setDefaultTooltip(), userTooltipSpec = this.spec.tooltip;
390
+ if (!1 !== userTooltipSpec && null !== userTooltipSpec && null !== defaultTooltipSpec) {
391
+ const res = [], tooltipSpec = Object.assign({}, defaultTooltipSpec, !0 === userTooltipSpec ? {} : userTooltipSpec), colorChannel = (0,
392
+ vutils_1.isNil)(this.spec.encode.color) ? "group" : "color", colorEncode = this.spec.encode[colorChannel], dependency = colorEncode ? [ this.getScaleId(colorChannel) ] : [], colorAccessor = colorEncode ? (0,
393
+ vgrammar_util_1.field)(colorEncode) : null, title = {
394
+ visible: !!tooltipSpec.title || !!tooltipSpec.staticTitle,
395
+ key: "title",
396
+ value: (0, vutils_1.isNil)(tooltipSpec.staticTitle) ? {
397
+ field: (datum, el, params) => tooltipSpec.title && (null == datum ? void 0 : datum.length) ? (0,
398
+ vgrammar_util_1.field)(tooltipSpec.title)(datum[0]) : void 0
399
+ } : tooltipSpec.staticTitle
400
+ }, content = (0, vutils_1.isArray)(tooltipSpec.content) && tooltipSpec.content.length ? tooltipSpec.content.map(((entry, index) => ({
401
+ key: entry.key ? {
402
+ field: entry.key
403
+ } : (0, vutils_1.isNil)(tooltipSpec.staticContentKey) ? (datum, el, params) => colorAccessor ? colorAccessor(datum) : void 0 : (0,
404
+ vutils_1.isArray)(tooltipSpec.staticContentKey) ? tooltipSpec.staticContentKey[index] : tooltipSpec.staticContentKey,
405
+ value: {
406
+ field: entry.value
407
+ },
408
+ symbol: (datum, el, params) => {
409
+ var _a;
410
+ const scale = params[this.getScaleId(colorChannel)];
411
+ return {
412
+ symbolType: entry.symbol && null !== (_a = (0, vgrammar_util_1.field)(entry.symbol)(datum)) && void 0 !== _a ? _a : "circle",
413
+ fill: scale && colorAccessor ? scale.scale(colorAccessor(datum)) : (0, vgrammar_1.getPalette)()[0]
414
+ };
415
+ }
416
+ }))) : null;
417
+ return !0 !== tooltipSpec.disableGraphicTooltip && res.push({
418
+ type: "component",
419
+ componentType: vgrammar_1.ComponentEnum.tooltip,
420
+ target: this.getMarkId(),
421
+ dependency: dependency,
422
+ title: title,
423
+ content: content,
424
+ zIndex: 1e3
425
+ }), !0 !== tooltipSpec.disableDimensionTooltip && res.push({
426
+ type: "component",
427
+ componentType: vgrammar_1.ComponentEnum.dimensionTooltip,
428
+ tooltipType: this.getVisualChannel("x"),
429
+ scale: this.getScaleId("x"),
430
+ dependency: dependency,
431
+ target: {
432
+ data: this.getDataIdOfFiltered(),
433
+ filter: null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a.x
434
+ },
435
+ title: title,
436
+ content: content,
437
+ avoidMark: tooltipSpec.disableGraphicTooltip ? [] : [ this.getMarkId() ],
438
+ zIndex: 1e3
439
+ }), res;
440
+ }
441
+ return [];
442
+ }
443
+ setDefaultSlider() {
444
+ return {};
445
+ }
446
+ parseSliderSpec() {
447
+ const slider = this.spec.slider, res = [];
448
+ return slider && Object.keys(slider).forEach((channel => {
449
+ var _a, _b;
450
+ const {option: option, layout: layout} = this.parseOption(slider[channel]);
451
+ if (option) {
452
+ const scaleId = this.getScaleId(channel), scaleSpec = this.getScaleSpec(scaleId), dataId = this.getDataIdOfMain();
453
+ 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}`);
454
+ const getter = (0, vgrammar_util_1.field)(null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a[channel]), markLayout = null != layout ? layout : (0,
455
+ vutils_1.isPlainObject)(option) && !(0, vutils_1.isNil)(option.layout) ? "horizontal" === option.layout ? {
456
+ position: "top",
457
+ align: "center"
458
+ } : "vertical" === option.layout ? {
459
+ position: "right",
460
+ align: "middle"
461
+ } : {
462
+ position: "top",
463
+ align: "center"
464
+ } : {
465
+ position: "top",
466
+ align: "center"
467
+ }, markSpec = {
468
+ type: "component",
469
+ componentType: vgrammar_1.ComponentEnum.slider,
470
+ dependency: [ vgrammar_1.SIGNAL_VIEW_BOX, dataId ],
471
+ min: (datum, elment, params) => {
472
+ const data = params[dataId];
473
+ return Math.min.apply(null, data.map(getter));
474
+ },
475
+ max: (datum, elment, params) => {
476
+ const data = params[dataId];
477
+ return Math.max.apply(null, data.map(getter));
478
+ },
479
+ target: {
480
+ data: this.getDataIdOfFiltered(),
481
+ filter: null === (_b = this.spec.encode) || void 0 === _b ? void 0 : _b[channel]
482
+ },
483
+ encode: {
484
+ update: (datum, elment, params) => {
485
+ 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;
486
+ const calculatedAttrs = "left" === markLayout.position ? {
487
+ layout: "vertical",
488
+ 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,
489
+ 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,
490
+ railWidth: defaultTheme.slider.railHeight,
491
+ railHeight: params.viewBox.height()
492
+ } : "right" === markLayout.position ? {
493
+ layout: "vertical",
494
+ 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(),
495
+ 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,
496
+ railWidth: defaultTheme.slider.railHeight,
497
+ railHeight: params.viewBox.height()
498
+ } : "bottom" === markLayout.position ? {
499
+ layout: "horizontal",
500
+ 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,
501
+ 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(),
502
+ railHeight: defaultTheme.slider.railHeight,
503
+ railWidth: params.viewBox.width()
504
+ } : {
505
+ layout: "horizontal",
506
+ 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,
507
+ 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,
508
+ railHeight: defaultTheme.slider.railHeight,
509
+ railWidth: params.viewBox.width()
510
+ };
511
+ return (0, vutils_1.isPlainObject)(option) ? Object.assign({}, calculatedAttrs, option) : calculatedAttrs;
512
+ }
513
+ }
514
+ };
515
+ markSpec.layout = markLayout, res.push(markSpec);
516
+ }
517
+ })), res;
518
+ }
519
+ setDefaultDataZoom() {
520
+ return {};
521
+ }
522
+ getVisiualPositionByDimension(channel) {
523
+ return "y" === channel ? "left" : "bottom";
524
+ }
525
+ parseDataZoomSpec() {
526
+ const datazoom = this.spec.datazoom, res = [];
527
+ return datazoom && Object.keys(datazoom).forEach((channel => {
528
+ var _a, _b, _c, _d, _e;
529
+ const {option: option, layout: layout} = this.parseOption(datazoom[channel]);
530
+ if (option) {
531
+ const dataId = this.getDataIdOfMain(), markLayout = null != layout ? layout : (0,
532
+ vutils_1.isPlainObject)(option) && !(0, vutils_1.isNil)(option.orient) ? {
533
+ position: option.orient
534
+ } : {
535
+ position: this.getVisiualPositionByDimension(channel)
536
+ }, preview = {
537
+ data: dataId
538
+ }, {x: x, y: y} = this.getDataZoomScaleId(channel);
539
+ "x" === channel ? (preview.x = {
540
+ scale: x,
541
+ field: null === (_a = this.spec.encode) || void 0 === _a ? void 0 : _a[channel]
542
+ }, preview.y = {
543
+ scale: y,
544
+ field: null === (_b = this.spec.encode) || void 0 === _b ? void 0 : _b.y
545
+ }) : preview["top" === markLayout.position || "bottom" === markLayout.position ? "x" : "y"] = {
546
+ scale: x,
547
+ field: null !== (_d = null === (_c = this.spec.encode) || void 0 === _c ? void 0 : _c[channel]) && void 0 !== _d ? _d : channel
548
+ };
549
+ const markSpec = {
550
+ type: "component",
551
+ componentType: vgrammar_1.ComponentEnum.datazoom,
552
+ dependency: [ vgrammar_1.SIGNAL_VIEW_BOX, dataId ],
553
+ target: {
554
+ data: this.getDataIdOfFiltered(),
555
+ filter: null === (_e = this.spec.encode) || void 0 === _e ? void 0 : _e[channel]
556
+ },
557
+ preview: preview,
558
+ encode: {
559
+ update: (datum, elment, params) => {
560
+ 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;
561
+ const calculatedAttrs = "left" === markLayout.position ? {
562
+ orient: markLayout.position,
563
+ 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,
564
+ 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,
565
+ size: {
566
+ height: params.viewBox.height(),
567
+ width: defaultTheme.datazoom.size.height
568
+ }
569
+ } : "right" === markLayout.position ? {
570
+ orient: markLayout.position,
571
+ 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(),
572
+ 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,
573
+ size: {
574
+ height: params.viewBox.height(),
575
+ width: defaultTheme.datazoom.size.height
576
+ }
577
+ } : "bottom" === markLayout.position ? {
578
+ orient: markLayout.position,
579
+ 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,
580
+ 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(),
581
+ size: {
582
+ width: params.viewBox.width(),
583
+ height: defaultTheme.datazoom.size.height
584
+ }
585
+ } : {
586
+ orient: markLayout.position,
587
+ 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,
588
+ 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,
589
+ size: {
590
+ width: params.viewBox.width(),
591
+ height: defaultTheme.datazoom.size.height
592
+ }
593
+ };
594
+ return (0, vutils_1.isPlainObject)(option) ? Object.assign({}, calculatedAttrs, option) : calculatedAttrs;
595
+ }
596
+ }
597
+ };
598
+ markSpec.layout = markLayout, res.push(markSpec);
599
+ }
600
+ })), res;
601
+ }
602
+ setDefaultLabel() {
603
+ return {};
604
+ }
605
+ getLabelPosition() {
606
+ var _a, _b;
607
+ 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";
608
+ }
609
+ setLabelTextGetter(channel, option) {
610
+ return null;
611
+ }
612
+ parseLabelSpec() {
613
+ const label = this.spec.label, res = [];
614
+ return label && Object.keys(label).forEach((channel => {
615
+ const option = label[channel];
616
+ if (option) {
617
+ const markSpec = {
618
+ type: "component",
619
+ componentType: vgrammar_1.ComponentEnum.label,
620
+ target: this.getMarkId(),
621
+ layout: {
622
+ position: "content",
623
+ skipBeforeLayouted: !0
624
+ },
625
+ labelStyle: (0, vutils_1.isPlainObject)(option) ? Object.assign({
626
+ position: this.getLabelPosition()
627
+ }, option) : {
628
+ position: this.getLabelPosition()
629
+ },
630
+ encode: {
631
+ update: {
632
+ text: this.spec.encode[channel] ? {
633
+ field: this.spec.encode[channel]
634
+ } : this.setLabelTextGetter(channel, option)
635
+ }
636
+ }
637
+ };
638
+ res.push(markSpec);
639
+ }
640
+ })), res;
641
+ }
642
+ setDefaultPlayer() {
643
+ return {};
644
+ }
645
+ parsePlayerSpec() {
646
+ var _a;
647
+ const player = this.spec.player, res = [];
648
+ if (player) {
649
+ const option = null == player ? void 0 : player.option, layout = null == player ? void 0 : player.layout;
650
+ if (option) {
651
+ const markLayout = null != layout ? layout : (0, vutils_1.isPlainObject)(option) && !(0,
652
+ vutils_1.isNil)(option.orient) ? {
653
+ position: option.orient
654
+ } : {
655
+ position: "bottom"
656
+ }, markSpec = {
657
+ type: "component",
658
+ componentType: vgrammar_1.ComponentEnum.player,
659
+ dependency: [ vgrammar_1.SIGNAL_VIEW_BOX ],
660
+ target: {
661
+ data: this.getDataIdOfMain(),
662
+ source: this.getDataIdOfPlayer()
663
+ },
664
+ playerType: (0, vutils_1.isPlainObject)(option) && null !== (_a = option.type) && void 0 !== _a ? _a : "auto",
665
+ encode: {
666
+ update: (datum, elment, params) => {
667
+ 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;
668
+ const calculatedAttrs = "left" === markLayout.position ? {
669
+ 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,
670
+ 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,
671
+ size: {
672
+ height: params.viewBox.height(),
673
+ width: 20
674
+ }
675
+ } : "right" === markLayout.position ? {
676
+ 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(),
677
+ 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,
678
+ size: {
679
+ height: params.viewBox.height(),
680
+ width: 20
681
+ }
682
+ } : "bottom" === markLayout.position ? {
683
+ 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,
684
+ 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(),
685
+ size: {
686
+ width: params.viewBox.width(),
687
+ height: 20
688
+ }
689
+ } : {
690
+ 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,
691
+ 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,
692
+ size: {
693
+ width: params.viewBox.width(),
694
+ height: 20
695
+ }
696
+ };
697
+ return (0, vutils_1.isPlainObject)(option) ? Object.assign({}, calculatedAttrs, option) : calculatedAttrs;
698
+ }
699
+ }
700
+ };
701
+ markSpec.layout = markLayout, res.push(markSpec);
702
+ }
703
+ }
704
+ return res;
705
+ }
706
+ parseDataSpec() {
707
+ var _a;
708
+ const {data: data, player: player} = this.spec, res = [];
709
+ if (null == player ? void 0 : player.data) res.push({
710
+ id: this.getDataIdOfPlayer(),
711
+ values: player.data
712
+ }), res.push({
713
+ id: this.getDataIdOfMain(),
714
+ values: null === (_a = player.data) || void 0 === _a ? void 0 : _a[0]
715
+ }), res.push({
716
+ id: this.getDataIdOfFiltered(),
717
+ source: this.getDataIdOfMain()
718
+ }); else if (data) {
719
+ const dataId = this.getDataIdOfMain(), userTransforms = data.transform, transform = this.convertMarkTransform(userTransforms, this.setDefaultDataTransform());
720
+ res.push({
721
+ id: dataId,
722
+ values: data.values,
723
+ transform: transform
724
+ }), res.push({
725
+ id: this.getDataIdOfFiltered(),
726
+ source: dataId
727
+ });
728
+ }
729
+ const multiDatas = this.setMultipleData();
730
+ return multiDatas && multiDatas.forEach((entry => {
731
+ entry.id && (entry.id === this.getDataIdOfFiltered() && res.length ? res[res.length - 1].transform = entry.transform : res.push(entry));
732
+ })), res;
733
+ }
734
+ parseScaleSpec() {
735
+ const {encode: encode, scale: scale, datazoom: datazoom} = this.spec, scales = {};
736
+ return encode && Object.keys(encode).forEach((k => {
737
+ var _a;
738
+ const encodeOption = encode[k], scaleId = this.getScaleId(k);
739
+ scales[scaleId] = Object.assign({
740
+ id: scaleId
741
+ }, this.parseScaleByEncode(k, encodeOption), null === (_a = this.spec.scale) || void 0 === _a ? void 0 : _a[k]);
742
+ })), scale && Object.keys(scale).forEach((k => {
743
+ const scaleId = this.getScaleId(k);
744
+ scales[scaleId] || (scales[scaleId] = scale[k]);
745
+ })), datazoom && Object.keys(datazoom).forEach((k => {
746
+ var _a, _b, _c, _d;
747
+ const scaleId = this.getScaleId(k), {x: xScaleId, y: yScaleId} = this.getDataZoomScaleId(k);
748
+ "x" === k && encode[k] ? (scales[xScaleId] = {
749
+ type: scales[scaleId].type,
750
+ id: xScaleId,
751
+ domain: {
752
+ data: this.getDataIdOfMain(),
753
+ field: encode[k]
754
+ },
755
+ dependency: [ vgrammar_1.SIGNAL_VIEW_BOX ],
756
+ range: (scale, params) => [ 0, params.viewBox.width() ]
757
+ }, encode.y && (scales[yScaleId] = {
758
+ type: null !== (_b = null === (_a = scales[this.getScaleId("y")]) || void 0 === _a ? void 0 : _a.type) && void 0 !== _b ? _b : "linear",
759
+ id: yScaleId,
760
+ domain: {
761
+ data: this.getDataIdOfMain(),
762
+ field: null == encode ? void 0 : encode.y
763
+ },
764
+ range: (scale, params) => {
765
+ var _a, _b;
766
+ const option = this.parseOption(datazoom[k]).option;
767
+ return [ 0, (0, vutils_1.isPlainObject)(option) && null !== (_b = null === (_a = option.size) || void 0 === _a ? void 0 : _a.height) && void 0 !== _b ? _b : defaultTheme.datazoom.size.height ];
768
+ }
769
+ })) : scales[xScaleId] = {
770
+ type: null !== (_c = scales[scaleId].type) && void 0 !== _c ? _c : "band",
771
+ id: xScaleId,
772
+ domain: {
773
+ data: this.getDataIdOfMain(),
774
+ field: null !== (_d = null == encode ? void 0 : encode[k]) && void 0 !== _d ? _d : k
775
+ }
776
+ };
777
+ })), Array.from(Object.values(scales));
778
+ }
779
+ parseCoordinateSpec() {
780
+ var _a;
781
+ if (!this._coordinate) return [];
782
+ const coordinate = {
783
+ type: null !== (_a = this._coordinate.type) && void 0 !== _a ? _a : "cartesian",
784
+ transpose: this._coordinate.transpose,
785
+ id: this._coordinate.id,
786
+ dependency: [ vgrammar_1.SIGNAL_VIEW_BOX ],
787
+ start: [ 0, 0 ],
788
+ end: (coord, params) => [ params.viewBox.width(), params.viewBox.height() ]
789
+ };
790
+ return "polar" === this._coordinate.type && this._coordinate.origin && (coordinate.origin = (coord, params) => [ (0,
791
+ vgrammar_util_1.toPercent)(this._coordinate.origin[0], params.viewBox.width()), (0,
792
+ vgrammar_util_1.toPercent)(this._coordinate.origin[1], params.viewBox.height()) ]),
793
+ [ coordinate ];
794
+ }
795
+ setMainMarkEnterEncode() {
796
+ return this.spec.style;
797
+ }
798
+ setMainMarkSpec() {
799
+ return {};
800
+ }
801
+ setMultiMarksSpec() {
802
+ return null;
803
+ }
804
+ toViewSpec() {
805
+ var _a, _b;
806
+ this.viewSpec = {};
807
+ const filteredDataId = this.getDataIdOfFiltered();
808
+ this.viewSpec.data = this.parseDataSpec(), this.viewSpec.scales = this.parseScaleSpec(),
809
+ this.viewSpec.coordinates = this.parseCoordinateSpec();
810
+ let marks = [];
811
+ marks = marks.concat(this.parseLegendSpec()), marks = marks.concat(this.parseAxisSpec()),
812
+ marks = marks.concat(this.parseCrosshairSpec()), marks = marks.concat(this.parseSliderSpec()),
813
+ marks = marks.concat(this.parseDataZoomSpec()), marks = marks.concat(this.parsePlayerSpec()),
814
+ marks.push(Object.assign({
815
+ id: this.getMarkId(),
816
+ type: this.setMarkType(),
817
+ coordinate: null === (_a = this._coordinate) || void 0 === _a ? void 0 : _a.id,
818
+ from: {
819
+ data: filteredDataId
820
+ },
821
+ groupBy: null === (_b = this.spec.encode) || void 0 === _b ? void 0 : _b.group,
822
+ layout: {
823
+ position: "content",
824
+ skipBeforeLayouted: !0
825
+ },
826
+ dependency: this.viewSpec.scales.map((scale => scale.id)).concat(vgrammar_1.SIGNAL_VIEW_BOX),
827
+ transform: this.convertMarkTransform(this.spec.transform, this.setDefaultMarkTransform()),
828
+ animation: this.convertMarkAnimation(),
829
+ encode: Object.assign({}, this.spec.state, {
830
+ enter: this.setMainMarkEnterEncode(),
831
+ update: this.convertMarkEncode(this.spec.encode)
832
+ })
833
+ }, this.setMainMarkSpec()));
834
+ const otherMarks = this.setMultiMarksSpec();
835
+ return otherMarks && (marks = marks.concat(otherMarks)), marks = marks.concat(this.parseLabelSpec()),
836
+ marks = marks.concat(this.parseTooltipSpec()), this.viewSpec.marks = marks, this.viewSpec;
837
+ }
838
+ clear() {
839
+ this.spec = {
840
+ id: this.spec.id
841
+ };
842
+ }
843
+ }
844
+
845
+ exports.SemanticMark = SemanticMark;
846
+ //# sourceMappingURL=semantic-mark.js.map