@visactor/vgrammar-plot 0.6.6-alpha.0 → 0.7.0-alpha.0

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