@visactor/vchart 2.0.5 → 2.0.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.
- package/build/es5/index.js +1 -1
- package/build/index.es.js +106 -42
- package/build/index.js +106 -42
- package/build/index.min.js +2 -2
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/chart/waterfall/waterfall-transformer.js +1 -1
- package/cjs/chart/waterfall/waterfall-transformer.js.map +1 -1
- package/cjs/component/marker/mark-line/cartesian-mark-line.js +7 -5
- package/cjs/component/marker/mark-line/cartesian-mark-line.js.map +1 -1
- package/cjs/core/index.d.ts +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/index.js.map +1 -1
- package/cjs/data/transforms/waterfall.d.ts +2 -0
- package/cjs/data/transforms/waterfall.js +5 -3
- package/cjs/data/transforms/waterfall.js.map +1 -1
- package/cjs/plugin/chart/formatter/formatter.d.ts +3 -0
- package/cjs/plugin/chart/formatter/formatter.js +23 -1
- package/cjs/plugin/chart/formatter/formatter.js.map +1 -1
- package/cjs/series/waterfall/interface.d.ts +1 -0
- package/cjs/series/waterfall/interface.js.map +1 -1
- package/cjs/series/waterfall/waterfall.js +10 -6
- package/cjs/series/waterfall/waterfall.js.map +1 -1
- package/esm/chart/waterfall/waterfall-transformer.js +1 -1
- package/esm/chart/waterfall/waterfall-transformer.js.map +1 -1
- package/esm/component/marker/mark-line/cartesian-mark-line.js +7 -5
- package/esm/component/marker/mark-line/cartesian-mark-line.js.map +1 -1
- package/esm/core/index.d.ts +1 -1
- package/esm/core/index.js +1 -1
- package/esm/core/index.js.map +1 -1
- package/esm/data/transforms/waterfall.d.ts +2 -0
- package/esm/data/transforms/waterfall.js +5 -3
- package/esm/data/transforms/waterfall.js.map +1 -1
- package/esm/plugin/chart/formatter/formatter.d.ts +3 -0
- package/esm/plugin/chart/formatter/formatter.js +23 -1
- package/esm/plugin/chart/formatter/formatter.js.map +1 -1
- package/esm/series/waterfall/interface.d.ts +1 -0
- package/esm/series/waterfall/interface.js.map +1 -1
- package/esm/series/waterfall/waterfall.js +10 -6
- package/esm/series/waterfall/waterfall.js.map +1 -1
- package/package.json +8 -8
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
|
-
|
|
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.
|
|
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.
|
|
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 !== (
|
|
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.
|
|
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 !== (
|
|
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
|
|
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.
|
|
58328
|
+
const version = "2.0.6";
|
|
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
|
-
|
|
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,
|
|
@@ -71628,7 +71646,7 @@ const waterfallFillTotal = (data, op) => {
|
|
|
71628
71646
|
if (!data) {
|
|
71629
71647
|
return data;
|
|
71630
71648
|
}
|
|
71631
|
-
const { indexField, valueField, total, seriesField } = op;
|
|
71649
|
+
const { indexField, valueField, total, seriesField, calculationMode } = op;
|
|
71632
71650
|
const totalData = {
|
|
71633
71651
|
[indexField]: (total === null || total === void 0 ? void 0 : total.text) || 'total',
|
|
71634
71652
|
[valueField]: data.reduce((pre, cur) => precisionAdd(pre, +cur[valueField]), 0)
|
|
@@ -71636,7 +71654,12 @@ const waterfallFillTotal = (data, op) => {
|
|
|
71636
71654
|
if (seriesField) {
|
|
71637
71655
|
totalData[seriesField] = 'total';
|
|
71638
71656
|
}
|
|
71639
|
-
|
|
71657
|
+
if (calculationMode === 'decrease') {
|
|
71658
|
+
data.unshift(totalData);
|
|
71659
|
+
}
|
|
71660
|
+
else {
|
|
71661
|
+
data.push(totalData);
|
|
71662
|
+
}
|
|
71640
71663
|
return data;
|
|
71641
71664
|
};
|
|
71642
71665
|
|
|
@@ -72247,7 +72270,7 @@ class WaterfallSeries extends BarSeries {
|
|
|
72247
72270
|
return super.getSeriesKeys();
|
|
72248
72271
|
}
|
|
72249
72272
|
initData() {
|
|
72250
|
-
var _a;
|
|
72273
|
+
var _a, _b, _c;
|
|
72251
72274
|
super.initData();
|
|
72252
72275
|
registerDataSetInstanceTransform(this._dataSet, 'waterfallFillTotal', waterfallFillTotal);
|
|
72253
72276
|
registerDataSetInstanceTransform(this._dataSet, 'waterfall', waterfall$1);
|
|
@@ -72260,6 +72283,7 @@ class WaterfallSeries extends BarSeries {
|
|
|
72260
72283
|
seriesField: this.getSeriesField(),
|
|
72261
72284
|
seriesFieldName: this._theme.seriesFieldName,
|
|
72262
72285
|
total: this._spec.total,
|
|
72286
|
+
calculationMode: (_b = this._spec.calculationMode) !== null && _b !== void 0 ? _b : 'increase',
|
|
72263
72287
|
stackInverse: this.getRegion().getStackInverse()
|
|
72264
72288
|
}
|
|
72265
72289
|
}, false);
|
|
@@ -72279,6 +72303,7 @@ class WaterfallSeries extends BarSeries {
|
|
|
72279
72303
|
startAs: STACK_FIELD_START,
|
|
72280
72304
|
endAs: STACK_FIELD_END,
|
|
72281
72305
|
total: this._spec.total,
|
|
72306
|
+
calculationMode: (_c = this._spec.calculationMode) !== null && _c !== void 0 ? _c : 'increase',
|
|
72282
72307
|
groupData: () => this.getGroups().groupData,
|
|
72283
72308
|
stackInverse: this.getRegion().getStackInverse()
|
|
72284
72309
|
}
|
|
@@ -72403,6 +72428,7 @@ class WaterfallSeries extends BarSeries {
|
|
|
72403
72428
|
}
|
|
72404
72429
|
initMarkStyle() {
|
|
72405
72430
|
super.initMarkStyle();
|
|
72431
|
+
const isDecrease = this._spec.calculationMode === 'decrease';
|
|
72406
72432
|
if (this._leaderLineMark) {
|
|
72407
72433
|
if (this._direction === "horizontal") {
|
|
72408
72434
|
this.setMarkStyle(this._leaderLineMark, {
|
|
@@ -72413,9 +72439,9 @@ class WaterfallSeries extends BarSeries {
|
|
|
72413
72439
|
if (!datum.lastIndex) {
|
|
72414
72440
|
return 0;
|
|
72415
72441
|
}
|
|
72416
|
-
return this.totalPositionY(datum, 'lastIndex', 1);
|
|
72442
|
+
return this.totalPositionY(datum, 'lastIndex', isDecrease ? 0 : 1);
|
|
72417
72443
|
},
|
|
72418
|
-
y1: (datum) => this.totalPositionY(datum, 'index', 0)
|
|
72444
|
+
y1: (datum) => this.totalPositionY(datum, 'index', isDecrease ? 1 : 0)
|
|
72419
72445
|
}, 'normal', AttributeLevel.Series);
|
|
72420
72446
|
}
|
|
72421
72447
|
else {
|
|
@@ -72425,9 +72451,9 @@ class WaterfallSeries extends BarSeries {
|
|
|
72425
72451
|
if (!datum.lastIndex) {
|
|
72426
72452
|
return 0;
|
|
72427
72453
|
}
|
|
72428
|
-
return this.totalPositionX(datum, 'lastIndex', 1);
|
|
72454
|
+
return this.totalPositionX(datum, 'lastIndex', isDecrease ? 0 : 1);
|
|
72429
72455
|
},
|
|
72430
|
-
x1: (datum) => this.totalPositionX(datum, 'index', 0),
|
|
72456
|
+
x1: (datum) => this.totalPositionX(datum, 'index', isDecrease ? 1 : 0),
|
|
72431
72457
|
y: (datum) => this.totalPositionY(datum, 'lastEnd', 0),
|
|
72432
72458
|
y1: (datum) => this.totalPositionY(datum, datum.isTotal ? 'end' : 'start', 0)
|
|
72433
72459
|
}, 'normal', AttributeLevel.Series);
|
|
@@ -89395,6 +89421,7 @@ class WaterfallChartSpecTransformer extends BarChartSpecTransformer {
|
|
|
89395
89421
|
series.stackLabel = spec.stackLabel;
|
|
89396
89422
|
series.leaderLine = spec.leaderLine;
|
|
89397
89423
|
series.total = spec.total;
|
|
89424
|
+
series.calculationMode = spec.calculationMode;
|
|
89398
89425
|
return series;
|
|
89399
89426
|
}
|
|
89400
89427
|
}
|
|
@@ -95728,7 +95755,7 @@ class CartesianMarkLine extends BaseMarkLine {
|
|
|
95728
95755
|
return { points };
|
|
95729
95756
|
}
|
|
95730
95757
|
_markerLayout() {
|
|
95731
|
-
var _a, _b, _c, _d;
|
|
95758
|
+
var _a, _b, _c, _d, _e;
|
|
95732
95759
|
const updateAttrs = this._getUpdateMarkerAttrs();
|
|
95733
95760
|
if (this._spec.type === 'type-step') {
|
|
95734
95761
|
const startRelativeSeries = this._startRelativeSeries;
|
|
@@ -95756,6 +95783,10 @@ class CartesianMarkLine extends BaseMarkLine {
|
|
|
95756
95783
|
expandDistanceValue = expandDistance;
|
|
95757
95784
|
}
|
|
95758
95785
|
const { points, limitRect } = updateAttrs;
|
|
95786
|
+
if (!points || points.length < 2) {
|
|
95787
|
+
(_a = this._markerComponent) === null || _a === void 0 ? void 0 : _a.setAttributes(updateAttrs);
|
|
95788
|
+
return;
|
|
95789
|
+
}
|
|
95759
95790
|
const joinPoints = getInsertPoints(points[0], points[1], connectDirection, expandDistanceValue);
|
|
95760
95791
|
let labelPositionAttrs;
|
|
95761
95792
|
if (multiSegment && isValid$1(mainSegmentIndex)) {
|
|
@@ -95767,11 +95798,11 @@ class CartesianMarkLine extends BaseMarkLine {
|
|
|
95767
95798
|
else {
|
|
95768
95799
|
labelPositionAttrs = Object.assign({ position: 'start', autoRotate: false }, getTextOffset(points[0], points[1], connectDirection, expandDistanceValue));
|
|
95769
95800
|
}
|
|
95770
|
-
const markerComponentAttr = (
|
|
95801
|
+
const markerComponentAttr = (_c = (_b = this._markerComponent) === null || _b === void 0 ? void 0 : _b.attribute) !== null && _c !== void 0 ? _c : {};
|
|
95771
95802
|
const prevLabelAttrs = array(markerComponentAttr.label);
|
|
95772
95803
|
const updateLabels = array(updateAttrs.label);
|
|
95773
95804
|
const labelsInSpec = array(this._spec.label);
|
|
95774
|
-
(
|
|
95805
|
+
(_d = this._markerComponent) === null || _d === void 0 ? void 0 : _d.setAttributes({
|
|
95775
95806
|
points: multiSegment
|
|
95776
95807
|
? [
|
|
95777
95808
|
[joinPoints[0], joinPoints[1]],
|
|
@@ -95811,7 +95842,7 @@ class CartesianMarkLine extends BaseMarkLine {
|
|
|
95811
95842
|
});
|
|
95812
95843
|
}
|
|
95813
95844
|
else {
|
|
95814
|
-
(
|
|
95845
|
+
(_e = this._markerComponent) === null || _e === void 0 ? void 0 : _e.setAttributes(updateAttrs);
|
|
95815
95846
|
}
|
|
95816
95847
|
}
|
|
95817
95848
|
_computeOptions() {
|
|
@@ -100264,8 +100295,41 @@ class FormatterPlugin extends BasePlugin {
|
|
|
100264
100295
|
else if (formatter.includes('%') && this._timeFormatter) {
|
|
100265
100296
|
return this._timeFormatter(formatter, text);
|
|
100266
100297
|
}
|
|
100298
|
+
else if (formatter.startsWith('calc(')) {
|
|
100299
|
+
return this._calcFormatter(formatter, text);
|
|
100300
|
+
}
|
|
100267
100301
|
return text;
|
|
100268
100302
|
}
|
|
100303
|
+
_calcFormatter(formatter, text) {
|
|
100304
|
+
try {
|
|
100305
|
+
const expression = formatter.slice(5, -1).replace(/v/g, String(text));
|
|
100306
|
+
return this._calculateMathExpression(expression, text);
|
|
100307
|
+
}
|
|
100308
|
+
catch (e) {
|
|
100309
|
+
return text;
|
|
100310
|
+
}
|
|
100311
|
+
}
|
|
100312
|
+
_calculateMathExpression(expression, text) {
|
|
100313
|
+
const cleanExpression = expression.replace(/\s+/g, '');
|
|
100314
|
+
if (!this._isValidMathExpression(cleanExpression)) {
|
|
100315
|
+
return text;
|
|
100316
|
+
}
|
|
100317
|
+
try {
|
|
100318
|
+
const safeFunction = new Function('return (' + cleanExpression + ')');
|
|
100319
|
+
const result = safeFunction();
|
|
100320
|
+
if (typeof result !== 'number' || isNaN(result) || !isFinite(result)) {
|
|
100321
|
+
throw new Error('Invalid calculation result');
|
|
100322
|
+
}
|
|
100323
|
+
return result;
|
|
100324
|
+
}
|
|
100325
|
+
catch (error) {
|
|
100326
|
+
return text;
|
|
100327
|
+
}
|
|
100328
|
+
}
|
|
100329
|
+
_isValidMathExpression(expression) {
|
|
100330
|
+
const validPattern = /^[0-9+\-*/().]+$/;
|
|
100331
|
+
return validPattern.test(expression);
|
|
100332
|
+
}
|
|
100269
100333
|
release() {
|
|
100270
100334
|
super.release();
|
|
100271
100335
|
this._format = null;
|