@visactor/vchart 1.4.1 → 1.4.2-beta.1

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 (55) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.js +73 -23
  3. package/build/index.min.js +1 -1
  4. package/build/tsconfig.tsbuildinfo +1 -1
  5. package/cjs/compile/compiler.js +9 -3
  6. package/cjs/compile/compiler.js.map +1 -1
  7. package/cjs/compile/mark/compilable-mark.d.ts +1 -0
  8. package/cjs/compile/mark/compilable-mark.js +3 -0
  9. package/cjs/compile/mark/compilable-mark.js.map +1 -1
  10. package/cjs/compile/mark/interface.d.ts +1 -0
  11. package/cjs/compile/mark/interface.js.map +1 -1
  12. package/cjs/component/axis/base-axis.d.ts +2 -0
  13. package/cjs/component/axis/base-axis.js +7 -5
  14. package/cjs/component/axis/base-axis.js.map +1 -1
  15. package/cjs/constant/event.d.ts +3 -1
  16. package/cjs/constant/event.js +2 -1
  17. package/cjs/constant/event.js.map +1 -1
  18. package/cjs/core/index.d.ts +1 -1
  19. package/cjs/core/index.js +1 -1
  20. package/cjs/core/index.js.map +1 -1
  21. package/cjs/core/vchart.js +8 -7
  22. package/cjs/core/vchart.js.map +1 -1
  23. package/cjs/series/gauge/gauge.d.ts +1 -0
  24. package/cjs/series/gauge/gauge.js +9 -2
  25. package/cjs/series/gauge/gauge.js.map +1 -1
  26. package/cjs/series/gauge/interface.d.ts +4 -0
  27. package/cjs/series/gauge/interface.js.map +1 -1
  28. package/cjs/series/sankey/sankey.js +14 -7
  29. package/cjs/series/sankey/sankey.js.map +1 -1
  30. package/esm/compile/compiler.js +10 -2
  31. package/esm/compile/compiler.js.map +1 -1
  32. package/esm/compile/mark/compilable-mark.d.ts +1 -0
  33. package/esm/compile/mark/compilable-mark.js +4 -1
  34. package/esm/compile/mark/compilable-mark.js.map +1 -1
  35. package/esm/compile/mark/interface.d.ts +1 -0
  36. package/esm/compile/mark/interface.js.map +1 -1
  37. package/esm/component/axis/base-axis.d.ts +2 -0
  38. package/esm/component/axis/base-axis.js +7 -5
  39. package/esm/component/axis/base-axis.js.map +1 -1
  40. package/esm/constant/event.d.ts +3 -1
  41. package/esm/constant/event.js +2 -1
  42. package/esm/constant/event.js.map +1 -1
  43. package/esm/core/index.d.ts +1 -1
  44. package/esm/core/index.js +1 -1
  45. package/esm/core/index.js.map +1 -1
  46. package/esm/core/vchart.js +8 -7
  47. package/esm/core/vchart.js.map +1 -1
  48. package/esm/series/gauge/gauge.d.ts +1 -0
  49. package/esm/series/gauge/gauge.js +10 -3
  50. package/esm/series/gauge/gauge.js.map +1 -1
  51. package/esm/series/gauge/interface.d.ts +4 -0
  52. package/esm/series/gauge/interface.js.map +1 -1
  53. package/esm/series/sankey/sankey.js +12 -5
  54. package/esm/series/sankey/sankey.js.map +1 -1
  55. package/package.json +4 -4
package/build/index.js CHANGED
@@ -47471,13 +47471,25 @@
47471
47471
  const leftArcs = Array.from(this._arcLeft.values()),
47472
47472
  rightArcs = Array.from(this._arcRight.values()),
47473
47473
  arcs = [];
47474
- return "inside" === position ? (arcs.push(...this._layoutInsideLabels(rightArcs, attribute, currentMarks)), arcs.push(...this._layoutInsideLabels(leftArcs, attribute, currentMarks))) : (arcs.push(...this._layoutOutsideLabels(rightArcs, attribute, currentMarks)), arcs.push(...this._layoutOutsideLabels(leftArcs, attribute, currentMarks))), arcs;
47474
+ switch (position) {
47475
+ case "inside":
47476
+ case "inside-inner":
47477
+ case "inside-outer":
47478
+ arcs.push(...this._layoutInsideLabels(rightArcs, attribute, currentMarks)), arcs.push(...this._layoutInsideLabels(leftArcs, attribute, currentMarks));
47479
+ break;
47480
+ default:
47481
+ arcs.push(...this._layoutOutsideLabels(rightArcs, attribute, currentMarks)), arcs.push(...this._layoutOutsideLabels(leftArcs, attribute, currentMarks));
47482
+ }
47483
+ return arcs;
47475
47484
  }
47476
47485
  _layoutInsideLabels(arcs, attribute, currentMarks) {
47486
+ var _a, _b;
47477
47487
  const labelConfig = attribute,
47478
- spaceWidth = labelConfig.spaceWidth;
47488
+ spaceWidth = labelConfig.spaceWidth,
47489
+ position = null !== (_a = null == labelConfig ? void 0 : labelConfig.position) && void 0 !== _a ? _a : "inside",
47490
+ offsetRadius = null !== (_b = null == labelConfig ? void 0 : labelConfig.offsetRadius) && void 0 !== _b ? _b : -spaceWidth;
47479
47491
  return arcs.forEach(arc => {
47480
- var _a, _b;
47492
+ var _a, _b, _c;
47481
47493
  const {
47482
47494
  labelSize: labelSize,
47483
47495
  radian: radian
@@ -47493,9 +47505,12 @@
47493
47505
  const text = this._getFormatLabelText(arc.refDatum, limit);
47494
47506
  arc.labelText = text;
47495
47507
  const labelWidth = Math.min(limit, arc.labelSize.width),
47496
- align = this._computeAlign(arc, attribute),
47497
- labelRadius = outerRadius - spaceWidth - ("left" === align ? labelWidth : "right" === align ? 0 : labelWidth / 2);
47498
- arc.labelPosition = circlePoint(arc.circleCenter.x, arc.circleCenter.y, labelRadius, arc.middleAngle), arc.labelLimit = labelWidth, isGreater(labelWidth, 0) || (arc.labelVisible = !1), arc.angle = null !== (_b = null === (_a = null == attribute ? void 0 : attribute.textStyle) || void 0 === _a ? void 0 : _a.angle) && void 0 !== _b ? _b : arc.middleAngle;
47508
+ align = this._computeAlign(arc, attribute);
47509
+ let labelRadius,
47510
+ alignOffset = 0;
47511
+ "inside" === position && (alignOffset = "left" === align ? labelWidth : "right" === align ? 0 : labelWidth / 2), labelRadius = "inside-inner" === position ? innerRadius - offsetRadius + alignOffset : outerRadius + offsetRadius - alignOffset, arc.labelPosition = circlePoint(arc.circleCenter.x, arc.circleCenter.y, labelRadius, arc.middleAngle), arc.labelLimit = labelWidth, isGreater(labelWidth, 0) || (arc.labelVisible = !1), arc.angle = null !== (_b = null === (_a = null == attribute ? void 0 : attribute.textStyle) || void 0 === _a ? void 0 : _a.angle) && void 0 !== _b ? _b : arc.middleAngle;
47512
+ let offsetAngle = null !== (_c = null == labelConfig ? void 0 : labelConfig.offsetAngle) && void 0 !== _c ? _c : 0;
47513
+ ["inside-inner", "inside-outer"].includes(position) && (offsetAngle += Math.PI / 2), arc.angle += offsetAngle;
47499
47514
  }), arcs;
47500
47515
  }
47501
47516
  _layoutOutsideLabels(arcs, attribute, currentMarks) {
@@ -47549,7 +47564,7 @@
47549
47564
  const width = 2 * center_x;
47550
47565
  return arcs.forEach(arc => {
47551
47566
  var _a, _b;
47552
- arc.labelVisible && (isLess(arc.pointB.x, line2MinLength + spaceWidth) || isGreater(arc.pointB.x, width - line2MinLength - spaceWidth)) && (arc.labelVisible = !1), arc.angle = null !== (_b = null === (_a = null == attribute ? void 0 : attribute.textStyle) || void 0 === _a ? void 0 : _a.angle) && void 0 !== _b ? _b : 0, arc.labelLine = Object.assign({}, null == attribute ? void 0 : attribute.line);
47567
+ arc.labelVisible && (isLess(arc.pointB.x, line2MinLength + spaceWidth) || isGreater(arc.pointB.x, width - line2MinLength - spaceWidth)) && (arc.labelVisible = !1), arc.angle = null !== (_b = null === (_a = null == attribute ? void 0 : attribute.textStyle) || void 0 === _a ? void 0 : _a.angle) && void 0 !== _b ? _b : 0, (null == attribute ? void 0 : attribute.offsetAngle) && (arc.angle += attribute.offsetAngle), arc.labelLine = Object.assign({}, null == attribute ? void 0 : attribute.line);
47553
47568
  }), arcs;
47554
47569
  }
47555
47570
  _computeX(arc, attribute, currentMarks) {
@@ -55276,6 +55291,8 @@
55276
55291
  ChartEvent["tooltipShow"] = "tooltipShow";
55277
55292
  ChartEvent["tooltipHide"] = "tooltipHide";
55278
55293
  ChartEvent["tooltipRelease"] = "tooltipRelease";
55294
+ ChartEvent["afterResize"] = "afterResize";
55295
+ ChartEvent["afterRender"] = "afterRender";
55279
55296
  })(ChartEvent || (ChartEvent = {}));
55280
55297
  var Event_Source_Type;
55281
55298
  (function (Event_Source_Type) {
@@ -58925,7 +58942,8 @@
58925
58942
  const logger = new Logger((_a = this._option.logLevel) !== null && _a !== void 0 ? _a : LoggerLevel.Error);
58926
58943
  if ((_b = this._option) === null || _b === void 0 ? void 0 : _b.onError) {
58927
58944
  logger.addErrorHandler((...args) => {
58928
- this._option.onError(...args);
58945
+ var _a, _b;
58946
+ (_b = (_a = this._option) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, ...args);
58929
58947
  });
58930
58948
  }
58931
58949
  this._view = new View(Object.assign(Object.assign({ width: this._width, height: this._height, hover: false, select: false, container: (_c = this._container.dom) !== null && _c !== void 0 ? _c : null, renderCanvas: (_d = this._container.canvas) !== null && _d !== void 0 ? _d : null, hooks: this._option.performanceHook, cursor: false }, this._option), { mode: toRenderMode(this._option.mode), autoFit: false, eventConfig: {
@@ -58936,6 +58954,10 @@
58936
58954
  (_a = this._compileChart) === null || _a === void 0 ? void 0 : _a.onLayout(this._view);
58937
58955
  }, logger: logger, logLevel: logger.level() }));
58938
58956
  this._setCanvasStyle();
58957
+ this.getStage().hooks.afterRender.tap('chart-event', () => {
58958
+ var _a, _b;
58959
+ (_b = (_a = this._compileChart) === null || _a === void 0 ? void 0 : _a.getEvent()) === null || _b === void 0 ? void 0 : _b.emit(ChartEvent.afterRender, { chart: this._compileChart });
58960
+ });
58939
58961
  const interactive = this._option.interactive;
58940
58962
  if (interactive !== false) {
58941
58963
  this._viewListeners.forEach(listener => {
@@ -59361,8 +59383,8 @@
59361
59383
  this._onResize = debounce((...args) => {
59362
59384
  const { width, height } = this._getCurSize();
59363
59385
  if (this._curSize.width !== width || this._curSize.height !== height) {
59364
- this.resize(width, height);
59365
59386
  this._curSize = { width, height };
59387
+ this.resize(width, height);
59366
59388
  }
59367
59389
  }, 100);
59368
59390
  this._option = merge$1(this._option, options);
@@ -59886,6 +59908,7 @@
59886
59908
  this._chart.onResize(width, height);
59887
59909
  (_d = (_c = this._option.performanceHook) === null || _c === void 0 ? void 0 : _c.afterResizeWithUpdate) === null || _d === void 0 ? void 0 : _d.call(_c);
59888
59910
  yield ((_f = (_e = this._compiler).resize) === null || _f === void 0 ? void 0 : _f.call(_e, width, height));
59911
+ this._event.emit(ChartEvent.afterResize, { chart: this._chart });
59889
59912
  return this;
59890
59913
  });
59891
59914
  }
@@ -59905,7 +59928,11 @@
59905
59928
  }
59906
59929
  on(eType, query, handler) {
59907
59930
  var _a;
59908
- this._userEvents.push({ eType, query, handler });
59931
+ this._userEvents.push({
59932
+ eType,
59933
+ query: typeof query === 'function' ? null : query,
59934
+ handler: typeof query === 'function' ? query : handler
59935
+ });
59909
59936
  (_a = this._event) === null || _a === void 0 ? void 0 : _a.on(eType, query, handler);
59910
59937
  }
59911
59938
  off(eType, handler) {
@@ -62753,6 +62780,9 @@
62753
62780
  getLabelSpec() {
62754
62781
  return this._label;
62755
62782
  }
62783
+ setLabelSpec(label) {
62784
+ this._label = array(label);
62785
+ }
62756
62786
  addLabelSpec(label) {
62757
62787
  if (!this._label) {
62758
62788
  this._label = [];
@@ -63432,7 +63462,7 @@
63432
63462
  VChart.useMark([ComponentMark, GroupMark, ImageMark]);
63433
63463
  Factory.registerRegion('region', Region);
63434
63464
  Factory.registerLayout('base', Layout);
63435
- const version = "1.4.1";
63465
+ const version = "1.4.2-beta.1";
63436
63466
  Logger.getInstance(LoggerLevel.Error);
63437
63467
 
63438
63468
  const WordCloud3dAnimation = (params) => {
@@ -72552,7 +72582,8 @@
72552
72582
  });
72553
72583
  this._segmentMark = this._createMark(GaugeSeries.mark.segment, {
72554
72584
  parent: this._arcGroupMark,
72555
- isSeriesMark: true
72585
+ isSeriesMark: true,
72586
+ label: this._preprocessLabelSpec()
72556
72587
  });
72557
72588
  }
72558
72589
  initMarkStyle() {
@@ -72578,6 +72609,7 @@
72578
72609
  zIndex: 200,
72579
72610
  forceShowCap: true
72580
72611
  });
72612
+ segmentMark.setLabelSpec(this._preprocessLabelSpec());
72581
72613
  this._trigger.registerMark(segmentMark);
72582
72614
  (_b = this._tooltipHelper) === null || _b === void 0 ? void 0 : _b.activeTriggerSet.mark.add(segmentMark);
72583
72615
  }
@@ -72608,6 +72640,10 @@
72608
72640
  const angle = this.angleAxisHelper.dataToPosition([datum[SEGMENT_FIELD_END]]);
72609
72641
  return angle - ((_a = this._spec.padAngle) !== null && _a !== void 0 ? _a : 0) / 2;
72610
72642
  }
72643
+ _preprocessLabelSpec() {
72644
+ const labelSpec = mergeSpec({ animation: this._spec.animation }, this._spec.label);
72645
+ return labelSpec;
72646
+ }
72611
72647
  initAnimation() {
72612
72648
  var _a, _b;
72613
72649
  const appearPreset = (_b = (_a = this._spec) === null || _a === void 0 ? void 0 : _a.animationAppear) === null || _b === void 0 ? void 0 : _b.preset;
@@ -77468,19 +77504,31 @@
77468
77504
  this._tooltipHelper = new SankeySeriesTooltipHelper(this);
77469
77505
  }
77470
77506
  getNodeOrdinalColorScale(item) {
77471
- var _a, _b, _c, _d, _e, _f, _g, _h;
77472
- const colorDomain = !isNil$1((_b = (_a = this._option.globalScale.getScale('color')) === null || _a === void 0 ? void 0 : _a.domain()) === null || _b === void 0 ? void 0 : _b[0])
77507
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
77508
+ if (!isNil$1((_c = (_b = (_a = this._option) === null || _a === void 0 ? void 0 : _a.globalScale) === null || _b === void 0 ? void 0 : _b.getScale('color')) === null || _c === void 0 ? void 0 : _c._specified)) {
77509
+ const specified = this._option.globalScale.getScale('color')._specified;
77510
+ const colorDomain = [];
77511
+ const colorRange = [];
77512
+ for (const key in specified) {
77513
+ colorDomain.push(key);
77514
+ colorRange.push(specified[key]);
77515
+ }
77516
+ const ordinalScale = new ColorOrdinalScale();
77517
+ (_e = (_d = ordinalScale.domain(colorDomain)).range) === null || _e === void 0 ? void 0 : _e.call(_d, colorRange);
77518
+ return ordinalScale.scale(item);
77519
+ }
77520
+ const colorDomain = !isNil$1((_g = (_f = this._option.globalScale.getScale('color')) === null || _f === void 0 ? void 0 : _f.domain()) === null || _g === void 0 ? void 0 : _g[0])
77473
77521
  ? this._option.globalScale.getScale('color').domain()
77474
77522
  : this.getNodeList();
77475
- let colorRange = (_d = (_c = this._option.globalScale.getScale('color')) === null || _c === void 0 ? void 0 : _c.range()) !== null && _d !== void 0 ? _d : getDataScheme(this._option.getTheme().colorScheme, this.type);
77476
- if (((_e = this._option.globalScale.getScale('color')) === null || _e === void 0 ? void 0 : _e.domain().length) === 0 ||
77523
+ let colorRange = (_j = (_h = this._option.globalScale.getScale('color')) === null || _h === void 0 ? void 0 : _h.range()) !== null && _j !== void 0 ? _j : getDataScheme(this._option.getTheme().colorScheme, this.type);
77524
+ if (((_k = this._option.globalScale.getScale('color')) === null || _k === void 0 ? void 0 : _k.domain().length) === 0 ||
77477
77525
  isNil$1(this._option.globalScale.getScale('color').domain()[0])) {
77478
77526
  if (colorDomain.length > 10) {
77479
- colorRange = (_f = getDataScheme(this._option.getTheme().colorScheme, this.type)[1]) === null || _f === void 0 ? void 0 : _f.scheme;
77527
+ colorRange = (_l = getDataScheme(this._option.getTheme().colorScheme, this.type)[1]) === null || _l === void 0 ? void 0 : _l.scheme;
77480
77528
  }
77481
77529
  }
77482
77530
  const ordinalScale = new ColorOrdinalScale();
77483
- (_h = (_g = ordinalScale.domain(colorDomain)).range) === null || _h === void 0 ? void 0 : _h.call(_g, colorRange);
77531
+ (_o = (_m = ordinalScale.domain(colorDomain)).range) === null || _o === void 0 ? void 0 : _o.call(_m, colorRange);
77484
77532
  return ordinalScale.scale(item);
77485
77533
  }
77486
77534
  getNodeList() {
@@ -85964,7 +86012,7 @@
85964
86012
  component.addEventListener('*', ((event, type) => this._delegateEvent(component, event, type)));
85965
86013
  }
85966
86014
  _getAxisAttributes() {
85967
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
86015
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
85968
86016
  const spec = this._spec;
85969
86017
  let titleAngle = spec.title.angle;
85970
86018
  let titleTextStyle;
@@ -86041,12 +86089,14 @@
86041
86089
  text: transformStateStyle(spec.title.state),
86042
86090
  shape: transformStateStyle((_g = spec.title.shape) === null || _g === void 0 ? void 0 : _g.state),
86043
86091
  background: transformStateStyle((_h = spec.title.background) === null || _h === void 0 ? void 0 : _h.state)
86044
- }
86092
+ },
86093
+ pickable: ((_j = spec.title.style) === null || _j === void 0 ? void 0 : _j.pickable) !== false,
86094
+ childrenPickable: ((_k = spec.title.style) === null || _k === void 0 ? void 0 : _k.pickable) !== false
86045
86095
  },
86046
86096
  panel: {
86047
- visible: (_j = spec.background) === null || _j === void 0 ? void 0 : _j.visible,
86048
- style: transformToGraphic((_k = spec.background) === null || _k === void 0 ? void 0 : _k.style),
86049
- state: transformStateStyle((_l = spec.background) === null || _l === void 0 ? void 0 : _l.state)
86097
+ visible: (_l = spec.background) === null || _l === void 0 ? void 0 : _l.visible,
86098
+ style: transformToGraphic((_m = spec.background) === null || _m === void 0 ? void 0 : _m.style),
86099
+ state: transformStateStyle((_o = spec.background) === null || _o === void 0 ? void 0 : _o.state)
86050
86100
  }
86051
86101
  };
86052
86102
  }