@visactor/vchart 2.0.5 → 2.0.7-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 (62) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.es.js +124 -48
  3. package/build/index.js +124 -48
  4. package/build/index.min.js +2 -2
  5. package/build/tsconfig.tsbuildinfo +1 -1
  6. package/cjs/animation/interface.js +2 -1
  7. package/cjs/chart/waterfall/waterfall-transformer.js +1 -1
  8. package/cjs/chart/waterfall/waterfall-transformer.js.map +1 -1
  9. package/cjs/compile/grammar-item.js +1 -2
  10. package/cjs/component/marker/mark-line/cartesian-mark-line.js +7 -5
  11. package/cjs/component/marker/mark-line/cartesian-mark-line.js.map +1 -1
  12. package/cjs/constant/attribute.js +2 -1
  13. package/cjs/constant/gradient.js +1 -2
  14. package/cjs/constant/sunburst.js +1 -1
  15. package/cjs/constant/waterfall.js +2 -1
  16. package/cjs/constant/word-cloud.js +1 -1
  17. package/cjs/core/expression-function.js +1 -2
  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 +1 -1
  22. package/cjs/data/initialize.js +1 -1
  23. package/cjs/data/register.js +1 -1
  24. package/cjs/data/transforms/waterfall.d.ts +2 -0
  25. package/cjs/data/transforms/waterfall.js +23 -9
  26. package/cjs/data/transforms/waterfall.js.map +1 -1
  27. package/cjs/plugin/chart/formatter/formatter.d.ts +3 -0
  28. package/cjs/plugin/chart/formatter/formatter.js +23 -1
  29. package/cjs/plugin/chart/formatter/formatter.js.map +1 -1
  30. package/cjs/series/waterfall/interface.d.ts +1 -0
  31. package/cjs/series/waterfall/interface.js.map +1 -1
  32. package/cjs/series/waterfall/waterfall.js +10 -6
  33. package/cjs/series/waterfall/waterfall.js.map +1 -1
  34. package/esm/animation/interface.js +2 -1
  35. package/esm/chart/waterfall/waterfall-transformer.js +1 -1
  36. package/esm/chart/waterfall/waterfall-transformer.js.map +1 -1
  37. package/esm/compile/grammar-item.js +1 -2
  38. package/esm/component/marker/mark-line/cartesian-mark-line.js +7 -5
  39. package/esm/component/marker/mark-line/cartesian-mark-line.js.map +1 -1
  40. package/esm/constant/attribute.js +2 -1
  41. package/esm/constant/gradient.js +1 -2
  42. package/esm/constant/sunburst.js +1 -1
  43. package/esm/constant/waterfall.js +2 -1
  44. package/esm/constant/word-cloud.js +1 -1
  45. package/esm/core/expression-function.js +1 -2
  46. package/esm/core/index.d.ts +1 -1
  47. package/esm/core/index.js +1 -1
  48. package/esm/core/index.js.map +1 -1
  49. package/esm/core/vchart.js +1 -1
  50. package/esm/data/initialize.js +1 -1
  51. package/esm/data/register.js +1 -1
  52. package/esm/data/transforms/waterfall.d.ts +2 -0
  53. package/esm/data/transforms/waterfall.js +23 -8
  54. package/esm/data/transforms/waterfall.js.map +1 -1
  55. package/esm/plugin/chart/formatter/formatter.d.ts +3 -0
  56. package/esm/plugin/chart/formatter/formatter.js +23 -1
  57. package/esm/plugin/chart/formatter/formatter.js.map +1 -1
  58. package/esm/series/waterfall/interface.d.ts +1 -0
  59. package/esm/series/waterfall/interface.js.map +1 -1
  60. package/esm/series/waterfall/waterfall.js +10 -6
  61. package/esm/series/waterfall/waterfall.js.map +1 -1
  62. package/package.json +7 -7
package/build/index.es.js CHANGED
@@ -7587,7 +7587,15 @@ const EnvContribution = Symbol.for("EnvContribution");
7587
7587
  const VGlobal = Symbol.for("VGlobal");
7588
7588
  const DEFAULT_TEXT_FONT_FAMILY$1 = "PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol";
7589
7589
 
7590
- class Application {}
7590
+ const container = new Container();
7591
+
7592
+ const RenderService = Symbol.for("RenderService");
7593
+
7594
+ class Application {
7595
+ get renderService() {
7596
+ return this._renderService || (this._renderService = container.get(RenderService)), this._renderService;
7597
+ }
7598
+ }
7591
7599
  const application = new Application();
7592
7600
 
7593
7601
  let idx = 0;
@@ -10005,6 +10013,9 @@ var __decorate$1u = undefined && undefined.__decorate || function (decorators, t
10005
10013
  return c > 3 && r && Object.defineProperty(target, key, r), r;
10006
10014
  };
10007
10015
  let ATextMeasure = class {
10016
+ constructor() {
10017
+ this.id = "ATextMeasure";
10018
+ }
10008
10019
  configure(service, env) {
10009
10020
  this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
10010
10021
  }
@@ -10397,11 +10408,13 @@ var __decorate$1t = undefined && undefined.__decorate || function (decorators, t
10397
10408
  return c > 3 && r && Object.defineProperty(target, key, r), r;
10398
10409
  };
10399
10410
  const TextMeasureContribution = Symbol.for("TextMeasureContribution");
10400
- let DefaultTextMeasureContribution = class extends ATextMeasure {};
10411
+ let DefaultTextMeasureContribution = class extends ATextMeasure {
10412
+ constructor() {
10413
+ super(...arguments), this.id = "DefaultTextMeasureContribution";
10414
+ }
10415
+ };
10401
10416
  DefaultTextMeasureContribution = __decorate$1t([injectable()], DefaultTextMeasureContribution);
10402
10417
 
10403
- const container = new Container();
10404
-
10405
10418
  const CanvasFactory = Symbol.for("CanvasFactory");
10406
10419
  const Context2dFactory = Symbol.for("Context2dFactory");
10407
10420
 
@@ -10978,13 +10991,17 @@ let DefaultGraphicUtil = class {
10978
10991
  return this.tryInitCanvas(), this._context;
10979
10992
  }
10980
10993
  constructor(contributions) {
10981
- this.contributions = contributions, this.configured = !1, this.global = application.global, this.global.hooks.onSetEnv.tap("graphic-util", (lastEnv, env, global) => {
10994
+ this.contributions = contributions, this.configured = !1, this.global = application.global, this._textMeasureMap = new Map(), this.global.hooks.onSetEnv.tap("graphic-util", (lastEnv, env, global) => {
10982
10995
  this.configured = !1, this.configure(global, env);
10983
10996
  });
10984
10997
  }
10985
10998
  get textMeasure() {
10986
10999
  return this._textMeasure || this.configure(this.global, this.global.env), this._textMeasure;
10987
11000
  }
11001
+ getTextMeasureInstance(textMeasureId) {
11002
+ if (!textMeasureId) return this.textMeasure;
11003
+ return this._textMeasureMap.get(textMeasureId) || this.textMeasure;
11004
+ }
10988
11005
  configure(global, env) {
10989
11006
  this.configured || (this.contributions.getContributions().forEach(contribution => {
10990
11007
  contribution.configure(this, env);
@@ -10997,7 +11014,7 @@ let DefaultGraphicUtil = class {
10997
11014
  }
10998
11015
  }
10999
11016
  bindTextMeasure(tm) {
11000
- this._textMeasure = tm;
11017
+ this._textMeasure && "DefaultTextMeasureContribution" !== tm.id || (this._textMeasure = tm), this._textMeasureMap.has(tm.id) || this._textMeasureMap.set(tm.id, tm);
11001
11018
  }
11002
11019
  measureText(text, tc, method = "native") {
11003
11020
  var _a;
@@ -15623,7 +15640,7 @@ class Text extends Graphic {
15623
15640
  this.cache.layoutData.lines.forEach(item => {
15624
15641
  mergedText += item.str;
15625
15642
  });
15626
- return (Array.isArray(text) ? text.join("") : text) !== mergedText;
15643
+ return (Array.isArray(text) ? text.join("") : text).toString() !== mergedText;
15627
15644
  }
15628
15645
  return "vertical" === attribute.direction && this.cache.verticalList && this.cache.verticalList[0] ? this.cache.verticalList[0].map(item => item.text).join("") !== attribute.text.toString() : null != this.clipedText && this.clipedText !== attribute.text.toString();
15629
15646
  }
@@ -15722,7 +15739,7 @@ class Text extends Graphic {
15722
15739
  return fontSize ? .1 * fontSize : 0;
15723
15740
  }
15724
15741
  updateHorizontalMultilineAABBBounds(text) {
15725
- var _a;
15742
+ var _a, _b;
15726
15743
  const textTheme = this.getGraphicTheme(),
15727
15744
  attribute = this.attribute,
15728
15745
  {
@@ -15749,7 +15766,7 @@ class Text extends Graphic {
15749
15766
  const bbox = this.cache.layoutData.bbox;
15750
15767
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
15751
15768
  }
15752
- const textMeasure = application.graphicUtil.textMeasure,
15769
+ const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_b = this.stage) || void 0 === _b ? void 0 : _b.textMeasureId)),
15753
15770
  layoutData = new CanvasTextLayout(fontFamily, {
15754
15771
  fontSize: fontSize,
15755
15772
  fontWeight: fontWeight,
@@ -15767,7 +15784,7 @@ class Text extends Graphic {
15767
15784
  return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
15768
15785
  }
15769
15786
  updateWrapAABBBounds(text) {
15770
- var _a, _b, _c;
15787
+ var _a, _b, _c, _d;
15771
15788
  const textTheme = this.getGraphicTheme(),
15772
15789
  {
15773
15790
  fontFamily = textTheme.fontFamily,
@@ -15793,7 +15810,7 @@ class Text extends Graphic {
15793
15810
  const bbox = this.cache.layoutData.bbox;
15794
15811
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
15795
15812
  }
15796
- const textMeasure = application.graphicUtil.textMeasure,
15813
+ const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_b = this.stage) || void 0 === _b ? void 0 : _b.textMeasureId)),
15797
15814
  textOptions = {
15798
15815
  fontSize: fontSize,
15799
15816
  fontWeight: fontWeight,
@@ -15825,7 +15842,7 @@ class Text extends Graphic {
15825
15842
  if ("" !== str && "" === clip.str || clip.wordBreaked) {
15826
15843
  if (ellipsis) {
15827
15844
  const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
15828
- clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
15845
+ clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
15829
15846
  } else clip.str = "", clip.width = 0;
15830
15847
  needCut = !1;
15831
15848
  }
@@ -15888,9 +15905,9 @@ class Text extends Graphic {
15888
15905
  return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
15889
15906
  }
15890
15907
  updateVerticalMultilineAABBBounds(text) {
15891
- var _a, _b;
15908
+ var _a, _b, _c;
15892
15909
  const textTheme = this.getGraphicTheme(),
15893
- textMeasure = application.graphicUtil.textMeasure;
15910
+ textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_a = this.stage) || void 0 === _a ? void 0 : _a.textMeasureId));
15894
15911
  let width;
15895
15912
  const attribute = this.attribute,
15896
15913
  {
@@ -15911,7 +15928,7 @@ class Text extends Graphic {
15911
15928
  } = attribute;
15912
15929
  if (!verticalMode) {
15913
15930
  const t = textAlign;
15914
- textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
15931
+ textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
15915
15932
  }
15916
15933
  if (width = 0, !this.shouldUpdateShape() && this.cache) {
15917
15934
  this.cache.verticalList.forEach(item => {
@@ -18922,7 +18939,7 @@ let DefaultCanvasArcRender = class extends BaseRender {
18922
18939
  doFill && (fillCb ? fillCb(context, arc.attribute, arcAttribute) : fVisible && (context.setCommonStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.fill()));
18923
18940
  }
18924
18941
  _runStroke(arc, context, x, y, arcAttribute, doStroke, isFullStroke, sVisible, strokeCb) {
18925
- doStroke && isFullStroke && (strokeCb || sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke()));
18942
+ doStroke && isFullStroke && (strokeCb ? strokeCb(context, arc.attribute, arcAttribute) : sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke()));
18926
18943
  }
18927
18944
  draw(arc, renderService, drawContext, params) {
18928
18945
  const arcAttribute = getTheme$1(arc, null == params ? void 0 : params.theme).arc;
@@ -20583,7 +20600,6 @@ var __decorate$19 = undefined && undefined.__decorate || function (decorators, t
20583
20600
  decorator(target, key, paramIndex);
20584
20601
  };
20585
20602
  };
20586
- const RenderService = Symbol.for("RenderService");
20587
20603
  let DefaultRenderService = class {
20588
20604
  constructor(drawContribution) {
20589
20605
  this.drawContribution = drawContribution;
@@ -21472,8 +21488,6 @@ const transformUtil = container.get(TransformUtil);
21472
21488
  application.transformUtil = transformUtil;
21473
21489
  const graphicService = container.get(GraphicService);
21474
21490
  application.graphicService = graphicService;
21475
- const renderService = container.get(RenderService);
21476
- application.renderService = renderService;
21477
21491
  const layerService = container.get(LayerService);
21478
21492
  application.layerService = layerService;
21479
21493
 
@@ -32560,12 +32574,12 @@ class AnimateExecutor {
32560
32574
  const parsedParams = this.parseParams(params, isTimeline);
32561
32575
  return animate = isTimeline ? this.executeTimelineItem(parsedParams, graphic, index, count) : this.executeTypeConfigItem(parsedParams, graphic, index, count), animate && this._trackAnimation(animate), animate;
32562
32576
  }
32563
- stop(type) {
32577
+ stop(type, callEnd = !0) {
32564
32578
  for (; this._animates.length > 0;) {
32565
32579
  const animate = this._animates.pop();
32566
- null == animate || animate.stop(type);
32580
+ !1 === callEnd && (animate.status = AnimateStatus.END), null == animate || animate.stop(type);
32567
32581
  }
32568
- this._animates = [], this._activeCount = 0, this._started && (this._started = !1, this.onEnd());
32582
+ this._animates = [], this._activeCount = 0, this._started && (this._started = !1, callEnd && this.onEnd());
32569
32583
  }
32570
32584
  }
32571
32585
  AnimateExecutor.builtInAnimateMap = {};
@@ -32625,7 +32639,7 @@ class AnimationStateManager {
32625
32639
  executor: new AnimateExecutor(this.graphic)
32626
32640
  });
32627
32641
  }), shouldStopState.forEach(state => {
32628
- state.executor.stop();
32642
+ state.executor.stop(null, !1);
32629
32643
  }), shouldApplyState.length) {
32630
32644
  shouldApplyState[0].executor.execute(shouldApplyState[0].animationConfig);
32631
32645
  for (let i = 0; i < shouldApplyState.length; i++) {
@@ -32676,7 +32690,7 @@ class AnimationStateManager {
32676
32690
  clearState() {
32677
32691
  var _a;
32678
32692
  null === (_a = this.stateList) || void 0 === _a || _a.forEach(state => {
32679
- state.executor.stop();
32693
+ state.executor.stop(null, !1);
32680
32694
  }), this.stateList = null;
32681
32695
  }
32682
32696
  reApplyState(state) {
@@ -40634,7 +40648,7 @@ class LabelBase extends AnimateComponent {
40634
40648
  const text = result[i],
40635
40649
  bounds = text.AABBBounds,
40636
40650
  range = boundToRange(bmpTool, bounds, !0);
40637
- if (canPlace(bmpTool, bitmap, bounds, clampForce, overlapPadding)) bitmap.setRange(range);else {
40651
+ if (canPlace(bmpTool, bitmap, bounds, clampForce || hideOnOverflow, overlapPadding)) bitmap.setRange(range);else {
40638
40652
  if (hideOnOverflow) {
40639
40653
  if (this._processHideOnOverflow(text, bmpTool)) continue;
40640
40654
  } else if (clampForce && this._processClampForce(text, bmpTool, bitmap, overlapPadding)) continue;
@@ -40697,7 +40711,7 @@ class LabelBase extends AnimateComponent {
40697
40711
  const text = labels[i],
40698
40712
  baseMark = this.getRelatedGraphic(text.attribute);
40699
40713
  if (text.update(), !this.isMarkInsideRect(baseMark, bmpTool)) continue;
40700
- if (canPlace(bmpTool, bitmap, text.AABBBounds, clampForce, overlapPadding)) {
40714
+ if (canPlace(bmpTool, bitmap, text.AABBBounds, clampForce || hideOnOverflow, overlapPadding)) {
40701
40715
  if (!checkBounds) {
40702
40716
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
40703
40717
  continue;
@@ -45605,7 +45619,7 @@ let DiscreteLegend$1 = class DiscreteLegend extends LegendBase {
45605
45619
  width: width,
45606
45620
  height: height
45607
45621
  } = item.attribute;
45608
- contentWidth < startX + width && (startX = 0, startY += height + spaceRow, pages += 1), index > 0 && item.setAttributes({
45622
+ contentWidth < startX + width && index > 0 && (startX = 0, startY += height + spaceRow, pages += 1), index > 0 && item.setAttributes({
45609
45623
  x: startX,
45610
45624
  y: startY
45611
45625
  }), startX += spaceCol + width;
@@ -45616,9 +45630,10 @@ let DiscreteLegend$1 = class DiscreteLegend extends LegendBase {
45616
45630
  if (compWidth = this._itemMaxWidth * maxCol + (maxCol - 1) * spaceCol, compHeight = maxHeight, contentWidth = compWidth, comp = this._createPager(compStyle), this._pagerComponent = comp, this._innerView.add(comp), contentHeight = maxHeight - comp.AABBBounds.height() - pagerSpace - renderStartY, contentHeight <= 0) return this._innerView.removeChild(comp), !1;
45617
45631
  itemsContainer.getChildren().forEach((item, index) => {
45618
45632
  const {
45633
+ width: width,
45619
45634
  height: height
45620
45635
  } = item.attribute;
45621
- contentHeight < startY + height && (startY = 0, startX += this._itemMaxWidth + spaceCol, pages += 1), index > 0 && item.setAttributes({
45636
+ contentHeight < startY + height && index > 0 && (startY = 0, startX += this._itemMaxWidth + spaceCol, pages += 1), index > 0 && item.setAttributes({
45622
45637
  x: startX,
45623
45638
  y: startY
45624
45639
  }), startY += spaceRow + height;
@@ -58310,7 +58325,7 @@ const lookup = (data, opt) => {
58310
58325
  });
58311
58326
  };
58312
58327
 
58313
- const version = "2.0.5";
58328
+ const version = "2.0.7-alpha.0";
58314
58329
 
58315
58330
  const addVChartProperty = (data, op) => {
58316
58331
  const context = op.beforeCall();
@@ -71418,10 +71433,13 @@ const waterfall$1 = (lastData, op) => {
71418
71433
  if (!lastData || lastData.length === 0) {
71419
71434
  return lastData;
71420
71435
  }
71421
- const { indexField, total: totalSpec, groupData } = op;
71436
+ const { indexField, total: totalSpec, groupData, calculationMode } = op;
71422
71437
  const totalData = [];
71423
71438
  const { dimensionValues, dimensionData } = groupData().latestData;
71424
- const indexValues = Array.from(dimensionValues[indexField]);
71439
+ let indexValues = Array.from(dimensionValues[indexField]);
71440
+ if (calculationMode === 'decrease') {
71441
+ indexValues = indexValues.reverse();
71442
+ }
71425
71443
  let temp = {
71426
71444
  start: 0,
71427
71445
  end: 0,
@@ -71479,9 +71497,9 @@ function computeTotalWithMultipleData(indexData, key, total, totalData, temp, in
71479
71497
  const { valueField, startAs, endAs, total: totalSpec } = op;
71480
71498
  const _normalTemp = [];
71481
71499
  const _totalTemp = [];
71482
- indexData.forEach(d => {
71500
+ indexData.forEach((d, index) => {
71483
71501
  if (isTotalCheck(d)) {
71484
- _totalTemp.push(d);
71502
+ _totalTemp.push(Object.assign(Object.assign({}, d), { [`_vchart_waterfall_waterfall_temp`]: index }));
71485
71503
  }
71486
71504
  else {
71487
71505
  _normalTemp.push(d);
@@ -71503,6 +71521,15 @@ function computeTotalWithMultipleData(indexData, key, total, totalData, temp, in
71503
71521
  let positive = start;
71504
71522
  let navigate = start;
71505
71523
  let valueTemp = end - start;
71524
+ const tempTotalValue = _normalTemp.reduce((pre, cur) => precisionSub(pre, +cur[valueField]), valueTemp);
71525
+ _totalTemp.forEach(d => {
71526
+ const tempTotalData = {
71527
+ [startAs]: start,
71528
+ [endAs]: end,
71529
+ [valueField]: tempTotalValue
71530
+ };
71531
+ _normalTemp.splice(d._vchart_waterfall_waterfall_temp, 0, tempTotalData);
71532
+ });
71506
71533
  _normalTemp.forEach(d => {
71507
71534
  const value = +d[valueField];
71508
71535
  if (value >= 0) {
@@ -71517,10 +71544,13 @@ function computeTotalWithMultipleData(indexData, key, total, totalData, temp, in
71517
71544
  start = precisionAdd(start, value);
71518
71545
  valueTemp = precisionSub(valueTemp, value);
71519
71546
  });
71520
- _totalTemp.forEach(d => {
71521
- d[startAs] = +start;
71522
- d[endAs] = precisionAdd(d[startAs], valueTemp);
71523
- d[valueField] = valueTemp;
71547
+ _totalTemp.forEach(_d => {
71548
+ const index = _d._vchart_waterfall_waterfall_temp;
71549
+ _d = _normalTemp[index];
71550
+ const d = indexData[index];
71551
+ d[startAs] = _d[startAs];
71552
+ d[endAs] = _d[endAs];
71553
+ d[valueField] = _d[valueField];
71524
71554
  });
71525
71555
  return Object.assign(Object.assign({}, total), { lastIndex: key });
71526
71556
  }
@@ -71628,7 +71658,7 @@ const waterfallFillTotal = (data, op) => {
71628
71658
  if (!data) {
71629
71659
  return data;
71630
71660
  }
71631
- const { indexField, valueField, total, seriesField } = op;
71661
+ const { indexField, valueField, total, seriesField, calculationMode } = op;
71632
71662
  const totalData = {
71633
71663
  [indexField]: (total === null || total === void 0 ? void 0 : total.text) || 'total',
71634
71664
  [valueField]: data.reduce((pre, cur) => precisionAdd(pre, +cur[valueField]), 0)
@@ -71636,7 +71666,12 @@ const waterfallFillTotal = (data, op) => {
71636
71666
  if (seriesField) {
71637
71667
  totalData[seriesField] = 'total';
71638
71668
  }
71639
- data.push(totalData);
71669
+ if (calculationMode === 'decrease') {
71670
+ data.unshift(totalData);
71671
+ }
71672
+ else {
71673
+ data.push(totalData);
71674
+ }
71640
71675
  return data;
71641
71676
  };
71642
71677
 
@@ -72247,7 +72282,7 @@ class WaterfallSeries extends BarSeries {
72247
72282
  return super.getSeriesKeys();
72248
72283
  }
72249
72284
  initData() {
72250
- var _a;
72285
+ var _a, _b, _c;
72251
72286
  super.initData();
72252
72287
  registerDataSetInstanceTransform(this._dataSet, 'waterfallFillTotal', waterfallFillTotal);
72253
72288
  registerDataSetInstanceTransform(this._dataSet, 'waterfall', waterfall$1);
@@ -72260,6 +72295,7 @@ class WaterfallSeries extends BarSeries {
72260
72295
  seriesField: this.getSeriesField(),
72261
72296
  seriesFieldName: this._theme.seriesFieldName,
72262
72297
  total: this._spec.total,
72298
+ calculationMode: (_b = this._spec.calculationMode) !== null && _b !== void 0 ? _b : 'increase',
72263
72299
  stackInverse: this.getRegion().getStackInverse()
72264
72300
  }
72265
72301
  }, false);
@@ -72279,6 +72315,7 @@ class WaterfallSeries extends BarSeries {
72279
72315
  startAs: STACK_FIELD_START,
72280
72316
  endAs: STACK_FIELD_END,
72281
72317
  total: this._spec.total,
72318
+ calculationMode: (_c = this._spec.calculationMode) !== null && _c !== void 0 ? _c : 'increase',
72282
72319
  groupData: () => this.getGroups().groupData,
72283
72320
  stackInverse: this.getRegion().getStackInverse()
72284
72321
  }
@@ -72403,6 +72440,7 @@ class WaterfallSeries extends BarSeries {
72403
72440
  }
72404
72441
  initMarkStyle() {
72405
72442
  super.initMarkStyle();
72443
+ const isDecrease = this._spec.calculationMode === 'decrease';
72406
72444
  if (this._leaderLineMark) {
72407
72445
  if (this._direction === "horizontal") {
72408
72446
  this.setMarkStyle(this._leaderLineMark, {
@@ -72413,9 +72451,9 @@ class WaterfallSeries extends BarSeries {
72413
72451
  if (!datum.lastIndex) {
72414
72452
  return 0;
72415
72453
  }
72416
- return this.totalPositionY(datum, 'lastIndex', 1);
72454
+ return this.totalPositionY(datum, 'lastIndex', isDecrease ? 0 : 1);
72417
72455
  },
72418
- y1: (datum) => this.totalPositionY(datum, 'index', 0)
72456
+ y1: (datum) => this.totalPositionY(datum, 'index', isDecrease ? 1 : 0)
72419
72457
  }, 'normal', AttributeLevel.Series);
72420
72458
  }
72421
72459
  else {
@@ -72425,9 +72463,9 @@ class WaterfallSeries extends BarSeries {
72425
72463
  if (!datum.lastIndex) {
72426
72464
  return 0;
72427
72465
  }
72428
- return this.totalPositionX(datum, 'lastIndex', 1);
72466
+ return this.totalPositionX(datum, 'lastIndex', isDecrease ? 0 : 1);
72429
72467
  },
72430
- x1: (datum) => this.totalPositionX(datum, 'index', 0),
72468
+ x1: (datum) => this.totalPositionX(datum, 'index', isDecrease ? 1 : 0),
72431
72469
  y: (datum) => this.totalPositionY(datum, 'lastEnd', 0),
72432
72470
  y1: (datum) => this.totalPositionY(datum, datum.isTotal ? 'end' : 'start', 0)
72433
72471
  }, 'normal', AttributeLevel.Series);
@@ -89395,6 +89433,7 @@ class WaterfallChartSpecTransformer extends BarChartSpecTransformer {
89395
89433
  series.stackLabel = spec.stackLabel;
89396
89434
  series.leaderLine = spec.leaderLine;
89397
89435
  series.total = spec.total;
89436
+ series.calculationMode = spec.calculationMode;
89398
89437
  return series;
89399
89438
  }
89400
89439
  }
@@ -95728,7 +95767,7 @@ class CartesianMarkLine extends BaseMarkLine {
95728
95767
  return { points };
95729
95768
  }
95730
95769
  _markerLayout() {
95731
- var _a, _b, _c, _d;
95770
+ var _a, _b, _c, _d, _e;
95732
95771
  const updateAttrs = this._getUpdateMarkerAttrs();
95733
95772
  if (this._spec.type === 'type-step') {
95734
95773
  const startRelativeSeries = this._startRelativeSeries;
@@ -95756,6 +95795,10 @@ class CartesianMarkLine extends BaseMarkLine {
95756
95795
  expandDistanceValue = expandDistance;
95757
95796
  }
95758
95797
  const { points, limitRect } = updateAttrs;
95798
+ if (!points || points.length < 2) {
95799
+ (_a = this._markerComponent) === null || _a === void 0 ? void 0 : _a.setAttributes(updateAttrs);
95800
+ return;
95801
+ }
95759
95802
  const joinPoints = getInsertPoints(points[0], points[1], connectDirection, expandDistanceValue);
95760
95803
  let labelPositionAttrs;
95761
95804
  if (multiSegment && isValid$1(mainSegmentIndex)) {
@@ -95767,11 +95810,11 @@ class CartesianMarkLine extends BaseMarkLine {
95767
95810
  else {
95768
95811
  labelPositionAttrs = Object.assign({ position: 'start', autoRotate: false }, getTextOffset(points[0], points[1], connectDirection, expandDistanceValue));
95769
95812
  }
95770
- const markerComponentAttr = (_b = (_a = this._markerComponent) === null || _a === void 0 ? void 0 : _a.attribute) !== null && _b !== void 0 ? _b : {};
95813
+ const markerComponentAttr = (_c = (_b = this._markerComponent) === null || _b === void 0 ? void 0 : _b.attribute) !== null && _c !== void 0 ? _c : {};
95771
95814
  const prevLabelAttrs = array(markerComponentAttr.label);
95772
95815
  const updateLabels = array(updateAttrs.label);
95773
95816
  const labelsInSpec = array(this._spec.label);
95774
- (_c = this._markerComponent) === null || _c === void 0 ? void 0 : _c.setAttributes({
95817
+ (_d = this._markerComponent) === null || _d === void 0 ? void 0 : _d.setAttributes({
95775
95818
  points: multiSegment
95776
95819
  ? [
95777
95820
  [joinPoints[0], joinPoints[1]],
@@ -95811,7 +95854,7 @@ class CartesianMarkLine extends BaseMarkLine {
95811
95854
  });
95812
95855
  }
95813
95856
  else {
95814
- (_d = this._markerComponent) === null || _d === void 0 ? void 0 : _d.setAttributes(updateAttrs);
95857
+ (_e = this._markerComponent) === null || _e === void 0 ? void 0 : _e.setAttributes(updateAttrs);
95815
95858
  }
95816
95859
  }
95817
95860
  _computeOptions() {
@@ -100264,8 +100307,41 @@ class FormatterPlugin extends BasePlugin {
100264
100307
  else if (formatter.includes('%') && this._timeFormatter) {
100265
100308
  return this._timeFormatter(formatter, text);
100266
100309
  }
100310
+ else if (formatter.startsWith('calc(')) {
100311
+ return this._calcFormatter(formatter, text);
100312
+ }
100267
100313
  return text;
100268
100314
  }
100315
+ _calcFormatter(formatter, text) {
100316
+ try {
100317
+ const expression = formatter.slice(5, -1).replace(/v/g, String(text));
100318
+ return this._calculateMathExpression(expression, text);
100319
+ }
100320
+ catch (e) {
100321
+ return text;
100322
+ }
100323
+ }
100324
+ _calculateMathExpression(expression, text) {
100325
+ const cleanExpression = expression.replace(/\s+/g, '');
100326
+ if (!this._isValidMathExpression(cleanExpression)) {
100327
+ return text;
100328
+ }
100329
+ try {
100330
+ const safeFunction = new Function('return (' + cleanExpression + ')');
100331
+ const result = safeFunction();
100332
+ if (typeof result !== 'number' || isNaN(result) || !isFinite(result)) {
100333
+ throw new Error('Invalid calculation result');
100334
+ }
100335
+ return result;
100336
+ }
100337
+ catch (error) {
100338
+ return text;
100339
+ }
100340
+ }
100341
+ _isValidMathExpression(expression) {
100342
+ const validPattern = /^[0-9+\-*/().]+$/;
100343
+ return validPattern.test(expression);
100344
+ }
100269
100345
  release() {
100270
100346
  super.release();
100271
100347
  this._format = null;