@visactor/vchart 1.11.6-alpha.5 → 1.11.6

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 (69) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.js +210 -153
  3. package/build/index.min.js +1 -1
  4. package/build/tsconfig.tsbuildinfo +1 -1
  5. package/cjs/chart/base/base-chart.js +6 -4
  6. package/cjs/chart/base/base-chart.js.map +1 -1
  7. package/cjs/chart/stack.js +2 -1
  8. package/cjs/compile/grammar-item.js +1 -2
  9. package/cjs/component/label/util.d.ts +0 -9
  10. package/cjs/component/label/util.js +8 -35
  11. package/cjs/component/label/util.js.map +1 -1
  12. package/cjs/component/tooltip/interface/theme.d.ts +2 -2
  13. package/cjs/component/tooltip/interface/theme.js.map +1 -1
  14. package/cjs/core/index.d.ts +1 -1
  15. package/cjs/core/index.js +1 -1
  16. package/cjs/core/index.js.map +1 -1
  17. package/cjs/core/vchart.js +1 -1
  18. package/cjs/core/vchart.js.map +1 -1
  19. package/cjs/series/sankey/sankey.d.ts +2 -6
  20. package/cjs/series/sankey/sankey.js +143 -40
  21. package/cjs/series/sankey/sankey.js.map +1 -1
  22. package/cjs/theme/interface.d.ts +2 -2
  23. package/cjs/theme/interface.js.map +1 -1
  24. package/cjs/typings/spec/common.d.ts +2 -2
  25. package/cjs/typings/spec/common.js.map +1 -1
  26. package/cjs/typings/visual.d.ts +2 -2
  27. package/cjs/typings/visual.js.map +1 -1
  28. package/cjs/util/spec/index.d.ts +0 -1
  29. package/cjs/util/spec/index.js +1 -1
  30. package/cjs/util/spec/index.js.map +1 -1
  31. package/esm/chart/base/base-chart.js +8 -6
  32. package/esm/chart/base/base-chart.js.map +1 -1
  33. package/esm/chart/stack.js +2 -1
  34. package/esm/compile/grammar-item.js +1 -2
  35. package/esm/component/label/util.d.ts +0 -9
  36. package/esm/component/label/util.js +5 -34
  37. package/esm/component/label/util.js.map +1 -1
  38. package/esm/component/tooltip/interface/theme.d.ts +2 -2
  39. package/esm/component/tooltip/interface/theme.js.map +1 -1
  40. package/esm/core/index.d.ts +1 -1
  41. package/esm/core/index.js +1 -1
  42. package/esm/core/index.js.map +1 -1
  43. package/esm/core/vchart.js +2 -2
  44. package/esm/core/vchart.js.map +1 -1
  45. package/esm/series/sankey/sankey.d.ts +2 -6
  46. package/esm/series/sankey/sankey.js +140 -43
  47. package/esm/series/sankey/sankey.js.map +1 -1
  48. package/esm/theme/interface.d.ts +2 -2
  49. package/esm/theme/interface.js.map +1 -1
  50. package/esm/typings/spec/common.d.ts +2 -2
  51. package/esm/typings/spec/common.js.map +1 -1
  52. package/esm/typings/visual.d.ts +2 -2
  53. package/esm/typings/visual.js.map +1 -1
  54. package/esm/util/spec/index.d.ts +0 -1
  55. package/esm/util/spec/index.js +0 -2
  56. package/esm/util/spec/index.js.map +1 -1
  57. package/package.json +2 -2
  58. package/cjs/series/sankey/sankey-transformer.d.ts +0 -5
  59. package/cjs/series/sankey/sankey-transformer.js +0 -16
  60. package/cjs/series/sankey/sankey-transformer.js.map +0 -1
  61. package/cjs/util/spec/background.d.ts +0 -4
  62. package/cjs/util/spec/background.js +0 -21
  63. package/cjs/util/spec/background.js.map +0 -1
  64. package/esm/series/sankey/sankey-transformer.d.ts +0 -5
  65. package/esm/series/sankey/sankey-transformer.js +0 -8
  66. package/esm/series/sankey/sankey-transformer.js.map +0 -1
  67. package/esm/util/spec/background.d.ts +0 -4
  68. package/esm/util/spec/background.js +0 -13
  69. package/esm/util/spec/background.js.map +0 -1
package/build/index.js CHANGED
@@ -54901,24 +54901,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
54901
54901
  return {};
54902
54902
  }
54903
54903
 
54904
- function convertBackgroundSpec(bg) {
54905
- if (!bg) {
54906
- return null;
54907
- }
54908
- if (typeof bg === 'string') {
54909
- return {
54910
- fill: bg,
54911
- fillOpacity: 1
54912
- };
54913
- }
54914
- if (typeof bg !== 'object') {
54915
- return null;
54916
- }
54917
- const result = pickWithout(bg, ['x', 'y', 'width', 'height', 'x1', 'y1', 'image']);
54918
- result.background = bg.image;
54919
- return result;
54920
- }
54921
-
54922
54904
  function specTransform(spec, special = {
54923
54905
  data: v => v
54924
54906
  }) {
@@ -61778,7 +61760,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
61778
61760
  return resize;
61779
61761
  }
61780
61762
  _getBackground() {
61781
- const specBackground = typeof this._spec.background === 'string' ? this._spec.background : null;
61763
+ const specBackground = typeof this._spec.background === 'string' || (isObject$2(this._spec.background) && this._spec.background.gradient)
61764
+ ? this._spec.background
61765
+ : null;
61782
61766
  return specBackground || this._currentTheme.background || this._option.background;
61783
61767
  }
61784
61768
  getCurrentTheme() {
@@ -66426,7 +66410,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
66426
66410
  registerComponentPlugin(CanvasTooltipHandler);
66427
66411
  };
66428
66412
 
66429
- const version = "1.11.6-alpha.5";
66413
+ const version = "1.11.6";
66430
66414
 
66431
66415
  const addVChartProperty = (data, op) => {
66432
66416
  const context = op.beforeCall();
@@ -71765,7 +71749,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
71765
71749
  this._transformer = new this.transformerConstructor(Object.assign(Object.assign({}, this._option), { type: this.type, seriesType: this.seriesType }));
71766
71750
  this._chartData.parseData(this._spec.data);
71767
71751
  this._createGlobalScale();
71768
- this._spec.background && typeof this._spec.background === 'object' && this._createBackground();
71752
+ this._createBackground();
71769
71753
  this._createLayout();
71770
71754
  this._transformer.forEachRegionInSpec(this._spec, this._createRegion.bind(this));
71771
71755
  this._transformer.forEachSeriesInSpec(this._spec, this._createSeries.bind(this));
@@ -71802,17 +71786,20 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
71802
71786
  this.setLayoutTag(true, null, reLayout);
71803
71787
  }
71804
71788
  _createBackground() {
71805
- const backgroundStyle = convertBackgroundSpec(this._spec.background);
71806
- if (backgroundStyle) {
71807
- this._backgroundMark = Factory.createMark("group", 'chart-background', {
71808
- model: this,
71809
- map: this._option.map,
71810
- getCompiler: this.getCompiler,
71811
- globalScale: this._globalScale
71812
- });
71813
- this._backgroundMark.created();
71814
- this._backgroundMark.setStyle(Object.assign(Object.assign({}, backgroundStyle), { x: () => this._viewBox.x1, y: () => this._viewBox.y1, width: () => this._viewBox.x2 - this._viewBox.x1, height: () => this._viewBox.y2 - this._viewBox.y1 }));
71789
+ const bg = this._spec.background;
71790
+ if (!bg || typeof bg !== 'object' || isValid$1(bg.gradient)) {
71791
+ return;
71815
71792
  }
71793
+ const backgroundStyle = pickWithout(bg, ['x', 'y', 'width', 'height', 'x1', 'y1', 'image']);
71794
+ backgroundStyle.background = bg.image;
71795
+ this._backgroundMark = Factory.createMark("group", 'chart-background', {
71796
+ model: this,
71797
+ map: this._option.map,
71798
+ getCompiler: this.getCompiler,
71799
+ globalScale: this._globalScale
71800
+ });
71801
+ this._backgroundMark.created();
71802
+ this._backgroundMark.setStyle(Object.assign(Object.assign({}, backgroundStyle), { x: () => this._viewBox.x1, y: () => this._viewBox.y1, width: () => this._viewBox.x2 - this._viewBox.x1, height: () => this._viewBox.y2 - this._viewBox.y1 }));
71816
71803
  }
71817
71804
  _createRegion(constructor, specInfo) {
71818
71805
  if (!constructor) {
@@ -76215,9 +76202,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
76215
76202
  labelSpec.overlap = {};
76216
76203
  }
76217
76204
  const processor = (_a = labelRuleMap[rule]) !== null && _a !== void 0 ? _a : labelRuleMap.point;
76218
- if (labelInfo.series.type === exports.SeriesTypeEnum.sankey) {
76219
- return sankeyLabel(labelInfo);
76220
- }
76221
76205
  return processor(labelInfo);
76222
76206
  }
76223
76207
  function textAttribute(labelInfo, datum, formatMethod, formatter) {
@@ -76230,11 +76214,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
76230
76214
  const attr = labelMark.getAttribute(key, datum);
76231
76215
  textAttribute[key] = attr;
76232
76216
  }
76233
- if (series.type !== exports.SeriesTypeEnum.sankey) {
76234
- const { formatFunc, args } = getFormatFunction(formatMethod, formatter, textAttribute.text, datum);
76235
- if (formatFunc) {
76236
- textAttribute.text = formatFunc(...args, { series });
76237
- }
76217
+ const { formatFunc, args } = getFormatFunction(formatMethod, formatter, textAttribute.text, datum);
76218
+ if (formatFunc) {
76219
+ textAttribute.text = formatFunc(...args, { series });
76238
76220
  }
76239
76221
  return textAttribute;
76240
76222
  }
@@ -76466,83 +76448,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
76466
76448
  const data = seriesData ? seriesData.map((d, index) => ({ [series.getSeriesField()]: d, index })) : [];
76467
76449
  return { position: (_d = labelSpec.position) !== null && _d !== void 0 ? _d : 'end', data };
76468
76450
  }
76469
- function sankeyLabel(labelInfo) {
76470
- var _a, _b, _c;
76471
- const { series, labelSpec = {} } = labelInfo;
76472
- const originPosition = (_a = uniformLabelPosition(labelSpec.position)) !== null && _a !== void 0 ? _a : 'outside';
76473
- const direction = series.direction;
76474
- let position = originPosition;
76475
- if (isString$1(originPosition)) {
76476
- if (direction === 'vertical') {
76477
- if (originPosition === 'inside-start') {
76478
- position = (datum) => {
76479
- return 'inside-left';
76480
- };
76481
- }
76482
- else if (originPosition === 'inside-middle') {
76483
- position = (datum) => {
76484
- return 'center';
76485
- };
76486
- }
76487
- else if (originPosition === 'inside-end') {
76488
- position = (datum) => {
76489
- return 'inside-right';
76490
- };
76491
- }
76492
- else {
76493
- position = (datum) => {
76494
- return 'bottom';
76495
- };
76496
- }
76497
- }
76498
- else {
76499
- if (originPosition === 'inside-start') {
76500
- position = (datum) => {
76501
- return 'inside-left';
76502
- };
76503
- }
76504
- else if (originPosition === 'inside-middle') {
76505
- position = (datum) => {
76506
- return 'center';
76507
- };
76508
- }
76509
- else if (originPosition === 'inside-end') {
76510
- position = (datum) => {
76511
- return 'inside-right';
76512
- };
76513
- }
76514
- else if (originPosition === 'outside') {
76515
- position = (datum) => {
76516
- return 'right';
76517
- };
76518
- }
76519
- }
76520
- }
76521
- let overlap;
76522
- if (labelSpec.overlap === false) {
76523
- overlap = false;
76524
- }
76525
- else {
76526
- overlap =
76527
- isString$1(originPosition) && originPosition.includes('inside')
76528
- ? false
76529
- : {
76530
- strategy: (_c = (_b = labelSpec.overlap) === null || _b === void 0 ? void 0 : _b.strategy) !== null && _c !== void 0 ? _c : sankeyLabelOverlapStrategy(series)
76531
- };
76532
- }
76533
- return { position, overlap, smartInvert: false, offset: 0, syncState: true };
76534
- }
76535
- function sankeyLabelOverlapStrategy(series) {
76536
- const strategy = [
76537
- {
76538
- type: 'position',
76539
- position: (data) => {
76540
- return series.direction === 'horizontal' ? ['right', 'left'] : ['bottom', 'top'];
76541
- }
76542
- }
76543
- ];
76544
- return strategy;
76545
- }
76546
76451
 
76547
76452
  class WaterfallSeries extends BarSeries {
76548
76453
  constructor() {
@@ -86943,17 +86848,10 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
86943
86848
  Factory.registerMark(LinkPathMark.type, LinkPathMark);
86944
86849
  };
86945
86850
 
86946
- class SankeySeriesSpecTransformer extends BaseSeriesSpecTransformer {
86947
- _transformLabelSpec(spec) {
86948
- this._addMarkLabelSpec(spec, "node");
86949
- }
86950
- }
86951
-
86952
86851
  class SankeySeries extends CartesianSeries {
86953
86852
  constructor() {
86954
86853
  super(...arguments);
86955
86854
  this.type = exports.SeriesTypeEnum.sankey;
86956
- this.transformerConstructor = SankeySeriesSpecTransformer;
86957
86855
  this._nodeLayoutZIndex = exports.LayoutZIndex.Node;
86958
86856
  this._labelLayoutZIndex = exports.LayoutZIndex.Label;
86959
86857
  this._viewBox = new Bounds();
@@ -87016,7 +86914,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87016
86914
  }
87017
86915
  };
87018
86916
  this._handleClearEmpty = () => {
87019
- var _a, _b;
86917
+ var _a, _b, _c;
87020
86918
  const allNodeElements = (_a = this._nodeMark) === null || _a === void 0 ? void 0 : _a.getProductElements();
87021
86919
  if (!allNodeElements || !allNodeElements.length) {
87022
86920
  return;
@@ -87025,6 +86923,10 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87025
86923
  if (!allLinkElements || !allLinkElements.length) {
87026
86924
  return;
87027
86925
  }
86926
+ const allLabelElements = (_c = this._labelMark) === null || _c === void 0 ? void 0 : _c.getProductElements();
86927
+ if (!allLabelElements || !allLabelElements.length) {
86928
+ return;
86929
+ }
87028
86930
  const states = [STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE];
87029
86931
  allNodeElements.forEach(el => {
87030
86932
  el.removeState(states);
@@ -87032,6 +86934,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87032
86934
  allLinkElements.forEach(el => {
87033
86935
  el.removeState(states);
87034
86936
  });
86937
+ allLabelElements.forEach(el => {
86938
+ el.removeState(states);
86939
+ });
87035
86940
  };
87036
86941
  this._handleNodeAdjacencyClick = (element) => {
87037
86942
  const nodeDatum = element.getDatum();
@@ -87081,6 +86986,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87081
86986
  if (this._nodeMark) {
87082
86987
  this._highLightElements(this._nodeMark.getProductElements(), highlightNodes);
87083
86988
  }
86989
+ if (this._labelMark) {
86990
+ this._highLightElements(this._labelMark.getProductElements(), highlightNodes);
86991
+ }
87084
86992
  };
87085
86993
  this._handleLinkAdjacencyClick = (element) => {
87086
86994
  const curLinkDatum = element.getDatum();
@@ -87104,6 +87012,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87104
87012
  if (this._nodeMark) {
87105
87013
  this._highLightElements(this._nodeMark.getProductElements(), highlightNodes);
87106
87014
  }
87015
+ if (this._labelMark) {
87016
+ this._highLightElements(this._labelMark.getProductElements(), highlightNodes);
87017
+ }
87107
87018
  };
87108
87019
  this._handleNodeRelatedClick = (element) => {
87109
87020
  var _a;
@@ -87220,6 +87131,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87220
87131
  if (this._nodeMark) {
87221
87132
  this._highLightElements(this._nodeMark.getProductElements(), highlightNodes);
87222
87133
  }
87134
+ if (this._labelMark) {
87135
+ this._highLightElements(this._labelMark.getProductElements(), highlightNodes);
87136
+ }
87223
87137
  }
87224
87138
  else {
87225
87139
  const highlightNodes = [nodeDatum.key];
@@ -87286,6 +87200,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87286
87200
  if (this._nodeMark) {
87287
87201
  this._highLightElements(this._nodeMark.getProductElements(), highlightNodes);
87288
87202
  }
87203
+ if (this._labelMark) {
87204
+ this._highLightElements(this._labelMark.getProductElements(), highlightNodes);
87205
+ }
87289
87206
  }
87290
87207
  };
87291
87208
  this._handleLinkRelatedClick = (element) => {
@@ -87311,6 +87228,15 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87311
87228
  el.removeState(states);
87312
87229
  });
87313
87230
  }
87231
+ if (this._labelMark) {
87232
+ const allLabelElements = this._labelMark.getProductElements();
87233
+ if (!allLabelElements || !allLabelElements.length) {
87234
+ return;
87235
+ }
87236
+ allLabelElements.forEach(el => {
87237
+ el.removeState(states);
87238
+ });
87239
+ }
87314
87240
  }
87315
87241
  else {
87316
87242
  const curLinkDatum = element.getDatum();
@@ -87393,13 +87319,12 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87393
87319
  return;
87394
87320
  });
87395
87321
  this._highLightElements(allNodeElements, highlightNodes);
87322
+ if (this._labelMark) {
87323
+ this._highLightElements(this._labelMark.getProductElements(), highlightNodes);
87324
+ }
87396
87325
  }
87397
87326
  };
87398
87327
  }
87399
- get direction() {
87400
- var _a;
87401
- return (_a = this._spec.direction) !== null && _a !== void 0 ? _a : 'horizontal';
87402
- }
87403
87328
  getCategoryField() {
87404
87329
  return this._categoryField;
87405
87330
  }
@@ -87447,7 +87372,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87447
87372
  sourceField: this._spec.sourceField,
87448
87373
  targetField: this._spec.targetField,
87449
87374
  valueField: this._spec.valueField,
87450
- direction: this.direction,
87375
+ direction: this._spec.direction,
87451
87376
  nodeAlign: (_a = this._spec.nodeAlign) !== null && _a !== void 0 ? _a : 'justify',
87452
87377
  nodeGap: (_b = this._spec.nodeGap) !== null && _b !== void 0 ? _b : 8,
87453
87378
  nodeWidth: (_c = this._spec.nodeWidth) !== null && _c !== void 0 ? _c : 10,
@@ -87538,6 +87463,15 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87538
87463
  if (linkMark) {
87539
87464
  this._linkMark = linkMark;
87540
87465
  }
87466
+ if (this._spec.label && this._spec.label.visible) {
87467
+ const labelMark = this._createMark(SankeySeries.mark.label, {
87468
+ dataView: this._nodesSeriesData.getDataView(),
87469
+ dataProductId: this._nodesSeriesData.getProductId()
87470
+ });
87471
+ if (labelMark) {
87472
+ this._labelMark = labelMark;
87473
+ }
87474
+ }
87541
87475
  }
87542
87476
  _buildMarkAttributeContext() {
87543
87477
  super._buildMarkAttributeContext();
@@ -87566,6 +87500,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87566
87500
  initMarkStyle() {
87567
87501
  this._initNodeMarkStyle();
87568
87502
  this._initLinkMarkStyle();
87503
+ this._initLabelMarkStyle();
87569
87504
  }
87570
87505
  _initNodeMarkStyle() {
87571
87506
  const nodeMark = this._nodeMark;
@@ -87583,6 +87518,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87583
87518
  }, STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Mark);
87584
87519
  }
87585
87520
  _initLinkMarkStyle() {
87521
+ var _a;
87586
87522
  const linkMark = this._linkMark;
87587
87523
  if (!linkMark) {
87588
87524
  return;
@@ -87594,44 +87530,162 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87594
87530
  y1: (datum) => datum.y1,
87595
87531
  thickness: (datum) => datum.thickness,
87596
87532
  fill: this._fillByLink,
87597
- direction: this.direction
87533
+ direction: (_a = this._spec.direction) !== null && _a !== void 0 ? _a : 'horizontal'
87598
87534
  }, STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Series);
87599
87535
  }
87600
- initLabelMarkStyle(textMark) {
87601
- if (!textMark) {
87536
+ _initLabelMarkStyle() {
87537
+ if (!this._labelMark) {
87602
87538
  return;
87603
87539
  }
87604
- const position = this._spec.label.position;
87605
- if (position && position.includes('inside')) {
87606
- this.setMarkStyle(textMark, {
87607
- fill: '#ffffff',
87608
- text: (datum) => this._createText(datum),
87609
- maxLineWidth: (datum) => { var _a; return (_a = this._spec.label.limit) !== null && _a !== void 0 ? _a : datum.x1 - datum.x0; }
87610
- });
87540
+ if (this._spec.direction === 'vertical') {
87541
+ if (this._spec.label.position === 'inside-start') {
87542
+ this.setMarkStyle(this._labelMark, {
87543
+ x: (datum) => datum.x0,
87544
+ y: (datum) => (datum.y0 + datum.y1) / 2,
87545
+ fill: '#ffffff',
87546
+ text: (datum) => this._createText(datum),
87547
+ limit: (datum) => { var _a; return (_a = this._spec.label.limit) !== null && _a !== void 0 ? _a : datum.x1 - datum.x0; },
87548
+ textAlign: 'left',
87549
+ textBaseline: 'middle'
87550
+ }, STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Series);
87551
+ }
87552
+ else if (this._spec.label.position === 'inside-middle') {
87553
+ this.setMarkStyle(this._labelMark, {
87554
+ x: (datum) => (datum.x0 + datum.x1) / 2,
87555
+ y: (datum) => (datum.y0 + datum.y1) / 2,
87556
+ fill: '#ffffff',
87557
+ text: (datum) => this._createText(datum),
87558
+ limit: (datum) => { var _a; return (_a = this._spec.label.limit) !== null && _a !== void 0 ? _a : datum.x1 - datum.x0; },
87559
+ textAlign: 'center',
87560
+ textBaseline: 'middle'
87561
+ }, STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Series);
87562
+ }
87563
+ else if (this._spec.label.position === 'inside-end') {
87564
+ this.setMarkStyle(this._labelMark, {
87565
+ x: (datum) => datum.x1,
87566
+ y: (datum) => (datum.y0 + datum.y1) / 2,
87567
+ fill: '#ffffff',
87568
+ text: (datum) => this._createText(datum),
87569
+ limit: (datum) => { var _a; return (_a = this._spec.label.limit) !== null && _a !== void 0 ? _a : datum.x1 - datum.x0; },
87570
+ textAlign: 'right',
87571
+ textBaseline: 'middle'
87572
+ }, STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Series);
87573
+ }
87574
+ else {
87575
+ this.setMarkStyle(this._labelMark, {
87576
+ x: (datum) => (datum.x0 + datum.x1) / 2,
87577
+ y: (datum) => {
87578
+ if (datum.y1 >= this._viewBox.y2) {
87579
+ return datum.y0;
87580
+ }
87581
+ return datum.y1;
87582
+ },
87583
+ fill: this._fillByNode,
87584
+ text: (datum) => this._createText(datum),
87585
+ limit: this._labelLimit,
87586
+ textAlign: 'center',
87587
+ textBaseline: (datum) => {
87588
+ if (datum.y1 >= this._viewBox.y2) {
87589
+ return 'bottom';
87590
+ }
87591
+ return 'top';
87592
+ }
87593
+ }, STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Series);
87594
+ }
87611
87595
  }
87612
87596
  else {
87613
- this.setMarkStyle(textMark, {
87614
- fill: this._fillByNode,
87615
- text: (datum) => this._createText(datum),
87616
- maxLineWidth: this._labelLimit
87617
- });
87597
+ if (this._spec.label.position === 'inside-start') {
87598
+ this.setMarkStyle(this._labelMark, {
87599
+ x: (datum) => datum.x0,
87600
+ y: (datum) => (datum.y0 + datum.y1) / 2,
87601
+ fill: '#ffffff',
87602
+ text: (datum) => this._createText(datum),
87603
+ limit: (datum) => { var _a; return (_a = this._spec.label.limit) !== null && _a !== void 0 ? _a : datum.x1 - datum.x0; },
87604
+ textAlign: 'left',
87605
+ textBaseline: 'middle'
87606
+ }, STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Series);
87607
+ }
87608
+ else if (this._spec.label.position === 'inside-middle') {
87609
+ this.setMarkStyle(this._labelMark, {
87610
+ x: (datum) => (datum.x0 + datum.x1) / 2,
87611
+ y: (datum) => (datum.y0 + datum.y1) / 2,
87612
+ fill: '#ffffff',
87613
+ text: (datum) => this._createText(datum),
87614
+ limit: (datum) => { var _a; return (_a = this._spec.label.limit) !== null && _a !== void 0 ? _a : datum.x1 - datum.x0; },
87615
+ textAlign: 'center',
87616
+ textBaseline: 'middle'
87617
+ }, STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Series);
87618
+ }
87619
+ else if (this._spec.label.position === 'inside-end') {
87620
+ this.setMarkStyle(this._labelMark, {
87621
+ x: (datum) => datum.x1,
87622
+ y: (datum) => (datum.y0 + datum.y1) / 2,
87623
+ fill: '#ffffff',
87624
+ text: (datum) => this._createText(datum),
87625
+ limit: (datum) => { var _a; return (_a = this._spec.label.limit) !== null && _a !== void 0 ? _a : datum.x1 - datum.x0; },
87626
+ textAlign: 'right',
87627
+ textBaseline: 'middle'
87628
+ }, STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Series);
87629
+ }
87630
+ else if (this._spec.label.position === 'left') {
87631
+ this.setMarkStyle(this._labelMark, {
87632
+ x: (datum) => datum.x0,
87633
+ y: (datum) => (datum.y0 + datum.y1) / 2,
87634
+ fill: this._fillByNode,
87635
+ text: (datum) => this._createText(datum),
87636
+ limit: this._labelLimit,
87637
+ textAlign: 'right',
87638
+ textBaseline: 'middle'
87639
+ }, STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Series);
87640
+ }
87641
+ else if (this._spec.label.position === 'right') {
87642
+ this.setMarkStyle(this._labelMark, {
87643
+ x: (datum) => datum.x1,
87644
+ y: (datum) => (datum.y0 + datum.y1) / 2,
87645
+ fill: this._fillByNode,
87646
+ text: (datum) => this._createText(datum),
87647
+ limit: this._labelLimit,
87648
+ textAlign: 'left',
87649
+ textBaseline: 'middle'
87650
+ }, STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Series);
87651
+ }
87652
+ else {
87653
+ this.setMarkStyle(this._labelMark, {
87654
+ x: (datum) => {
87655
+ if (datum.x1 >= this._viewBox.x2) {
87656
+ return datum.x0;
87657
+ }
87658
+ return datum.x1;
87659
+ },
87660
+ y: (datum) => (datum.y0 + datum.y1) / 2,
87661
+ fill: this._fillByNode,
87662
+ text: (datum) => this._createText(datum),
87663
+ limit: this._labelLimit,
87664
+ textAlign: (datum) => {
87665
+ if (datum.x1 >= this._viewBox.x2) {
87666
+ return 'right';
87667
+ }
87668
+ return 'left';
87669
+ },
87670
+ textBaseline: 'middle'
87671
+ }, STATE_VALUE_ENUM.STATE_NORMAL, exports.AttributeLevel.Series);
87672
+ }
87618
87673
  }
87619
- textMark.setZIndex(this._labelLayoutZIndex);
87674
+ this._labelMark.setZIndex(this._labelLayoutZIndex);
87620
87675
  }
87621
87676
  _createText(datum) {
87677
+ var _a;
87622
87678
  if (isNil$1(datum) || isNil$1(datum.datum)) {
87623
87679
  return '';
87624
87680
  }
87625
87681
  let text = datum.datum[this._spec.categoryField] || '';
87626
- const { formatMethod, formatter } = this._spec.label || {};
87627
- const { formatFunc, args } = getFormatFunction(formatMethod, formatter, text, datum.datum);
87628
- if (formatFunc) {
87629
- text = formatFunc(...args, { series: this });
87682
+ if ((_a = this._spec.label) === null || _a === void 0 ? void 0 : _a.formatMethod) {
87683
+ text = this._spec.label.formatMethod(text, datum.datum);
87630
87684
  }
87631
87685
  return text;
87632
87686
  }
87633
87687
  initAnimation() {
87634
- var _a, _b, _c, _d;
87688
+ var _a, _b, _c, _d, _e;
87635
87689
  const animationParams = {
87636
87690
  direction: this.direction,
87637
87691
  growFrom: () => {
@@ -87648,6 +87702,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87648
87702
  if (this._linkMark) {
87649
87703
  this._linkMark.setAnimationConfig(animationConfig((_d = Factory.getAnimationInKey('sankeyLinkPath')) === null || _d === void 0 ? void 0 : _d(animationParams, appearPreset), userAnimationConfig("link", this._spec, this._markAttributeContext)));
87650
87704
  }
87705
+ if (this._labelMark) {
87706
+ this._labelMark.setAnimationConfig(animationConfig((_e = Factory.getAnimationInKey('fadeInOut')) === null || _e === void 0 ? void 0 : _e(), userAnimationConfig("label", this._spec, this._markAttributeContext)));
87707
+ }
87651
87708
  }
87652
87709
  initEvent() {
87653
87710
  var _a, _b, _c;
@@ -87686,6 +87743,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87686
87743
  this._tooltipHelper = new SankeySeriesTooltipHelper(this);
87687
87744
  this._nodeMark && this._tooltipHelper.activeTriggerSet.mark.add(this._nodeMark);
87688
87745
  this._linkMark && this._tooltipHelper.activeTriggerSet.mark.add(this._linkMark);
87746
+ this._labelMark && this._tooltipHelper.activeTriggerSet.mark.add(this._labelMark);
87689
87747
  }
87690
87748
  _setNodeOrdinalColorScale() {
87691
87749
  var _a, _b, _c, _d, _e;
@@ -87715,7 +87773,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87715
87773
  return;
87716
87774
  }
87717
87775
  getNodeList() {
87718
- var _a, _b;
87776
+ var _a;
87719
87777
  if (this._nodeList) {
87720
87778
  return this._nodeList;
87721
87779
  }
@@ -87728,7 +87786,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87728
87786
  })
87729
87787
  : (data === null || data === void 0 ? void 0 : data.links)
87730
87788
  ? Array.from(this.extractNamesFromLink(data.links))
87731
- : (_b = data === null || data === void 0 ? void 0 : data.values) === null || _b === void 0 ? void 0 : _b.map((datum, index) => {
87789
+ : data === null || data === void 0 ? void 0 : data.values.map((datum, index) => {
87732
87790
  return datum[this._spec.categoryField];
87733
87791
  });
87734
87792
  this._nodeList = nodeList;
@@ -87821,7 +87879,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87821
87879
  }
87822
87880
  }
87823
87881
  SankeySeries.type = exports.SeriesTypeEnum.sankey;
87824
- SankeySeries.transformerConstructor = SankeySeriesSpecTransformer;
87825
87882
  SankeySeries.mark = sankeySeriesMark;
87826
87883
  const registerSankeySeries = () => {
87827
87884
  registerSankeyTransforms();