@visactor/vchart 2.0.7-alpha.1 → 2.0.7-alpha.4

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/index.js CHANGED
@@ -1042,43 +1042,187 @@
1042
1042
  return [min, max];
1043
1043
  };
1044
1044
 
1045
+ function invNorm(p) {
1046
+ if (p <= 0 || p >= 1) return 0;
1047
+ const c1 = -.00778489400243029,
1048
+ c2 = -.322396458041136,
1049
+ c3 = -2.40075827716184,
1050
+ c4 = -2.54973253934373,
1051
+ c5 = 4.37466414146497,
1052
+ c6 = 2.93816398269878,
1053
+ d1 = .00778469570904146,
1054
+ d2 = .32246712907004,
1055
+ d3 = 2.445134137143,
1056
+ d4 = 3.75440866190742;
1057
+ let q, r;
1058
+ return p < .02425 ? (q = Math.sqrt(-2 * Math.log(p)), (((((c1 * q + c2) * q + c3) * q + c4) * q + c5) * q + c6) / ((((d1 * q + d2) * q + d3) * q + d4) * q + 1)) : p <= .97575 ? (q = p - .5, r = q * q, (((((-39.6968302866538 * r + 220.946098424521) * r - 275.928510446969) * r + 138.357751867269) * r - 30.6647980661472) * r + 2.50662827745924) * q / (((((-54.4760987982241 * r + 161.585836858041) * r - 155.698979859887) * r + 66.8013118877197) * r - 13.2806815528857) * r + 1)) : (q = Math.sqrt(-2 * Math.log(1 - p)), -(((((c1 * q + c2) * q + c3) * q + c4) * q + c5) * q + c6) / ((((d1 * q + d2) * q + d3) * q + d4) * q + 1));
1059
+ }
1060
+ function computeLinearCIComponents(data, x, y, predict) {
1061
+ let min = 1 / 0,
1062
+ max = -1 / 0,
1063
+ n = 0,
1064
+ sumX = 0;
1065
+ for (let i = 0; i < data.length; i++) {
1066
+ const d = data[i];
1067
+ let dx = x(d),
1068
+ dy = y(d);
1069
+ !isNil$1(dx) && (dx = +dx) >= dx && !isNil$1(dy) && (dy = +dy) >= dy && (dx < min && (min = dx), dx > max && (max = dx), n++, sumX += dx);
1070
+ }
1071
+ if (0 === n) return {
1072
+ min: min,
1073
+ max: max,
1074
+ n: n,
1075
+ X: 0,
1076
+ SSE: 0,
1077
+ Sxx: 0
1078
+ };
1079
+ const X = sumX / n;
1080
+ let SSE = 0,
1081
+ Sxx = 0;
1082
+ for (let i = 0; i < data.length; i++) {
1083
+ const d = data[i];
1084
+ let dx = x(d),
1085
+ dy = y(d);
1086
+ if (!isNil$1(dx) && (dx = +dx) >= dx && !isNil$1(dy) && (dy = +dy) >= dy) {
1087
+ const r = dy - predict(dx);
1088
+ SSE += r * r;
1089
+ const dxc = dx - X;
1090
+ Sxx += dxc * dxc;
1091
+ }
1092
+ }
1093
+ return {
1094
+ min: min,
1095
+ max: max,
1096
+ n: n,
1097
+ X: X,
1098
+ SSE: SSE,
1099
+ Sxx: Sxx
1100
+ };
1101
+ }
1102
+ function stdErrorsAt(px, comps) {
1103
+ const {
1104
+ n: n,
1105
+ X: X,
1106
+ Sxx: Sxx,
1107
+ SSE: SSE
1108
+ } = comps,
1109
+ s2 = n > 2 ? SSE / (n - 2) : 0;
1110
+ return {
1111
+ seMean: Sxx > 0 ? Math.sqrt(s2 * (1 / n + (px - X) * (px - X) / Sxx)) : Math.sqrt(s2 / n),
1112
+ sePred: Math.sqrt(s2 * (1 + 1 / n + (Sxx > 0 ? (px - X) * (px - X) / Sxx : 0)))
1113
+ };
1114
+ }
1115
+
1045
1116
  function ordinaryLeastSquares(uX, uY, uXY, uX2) {
1046
- const delta = uX2 - uX * uX,
1047
- slope = Math.abs(delta) < 1e-24 ? 0 : (uXY - uX * uY) / delta;
1048
- return [uY - slope * uX, slope];
1117
+ const denom = uX2 - uX * uX;
1118
+ if (Math.abs(denom) < Number.EPSILON) return {
1119
+ a: uY,
1120
+ b: 0
1121
+ };
1122
+ const b = (uXY - uX * uY) / denom;
1123
+ return {
1124
+ a: uY - b * uX,
1125
+ b: b
1126
+ };
1049
1127
  }
1050
1128
  function visitPoints(data, x, y, callback) {
1051
- let u,
1052
- v,
1053
- i = -1;
1054
- data.forEach(d => {
1055
- u = x(d), v = y(d), !isNil$1(u) && (u = +u) >= u && !isNil$1(v) && (v = +v) >= v && callback(u, v, ++i);
1056
- });
1129
+ for (let i = 0; i < data.length; i++) {
1130
+ const d = data[i];
1131
+ let xi = x(d),
1132
+ yi = y(d);
1133
+ !isNil$1(xi) && (xi = +xi) >= xi && !isNil$1(yi) && (yi = +yi) >= yi && callback(xi, yi, i);
1134
+ }
1057
1135
  }
1058
1136
  function rSquared(data, x, y, uY, predict) {
1059
- let SSE = 0,
1060
- SST = 0;
1061
- return visitPoints(data, x, y, (dx, dy) => {
1062
- const sse = dy - predict(dx),
1063
- sst = dy - uY;
1064
- SSE += sse * sse, SST += sst * sst;
1065
- }), 1 - SSE / SST;
1066
- }
1067
- function regressionLinear(data, x = datum => datum.x, y = datum => datum.y) {
1068
- let X = 0,
1069
- Y = 0,
1070
- XY = 0,
1071
- X2 = 0,
1072
- n = 0;
1073
- visitPoints(data, x, y, (dx, dy) => {
1074
- ++n, X += (dx - X) / n, Y += (dy - Y) / n, XY += (dx * dy - XY) / n, X2 += (dx * dx - X2) / n;
1137
+ let ssr = 0,
1138
+ sst = 0;
1139
+ for (let i = 0; i < data.length; i++) {
1140
+ const d = data[i];
1141
+ let yi = y(d);
1142
+ if (!isNil$1(yi) && (yi = +yi) >= yi) {
1143
+ const r = yi - predict(x(d));
1144
+ ssr += r * r;
1145
+ const t = yi - uY;
1146
+ sst += t * t;
1147
+ }
1148
+ }
1149
+ return 0 === sst ? 0 : 1 - ssr / sst;
1150
+ }
1151
+ function regressionLinear(data, x = d => d.x, y = d => d.y) {
1152
+ let n = 0,
1153
+ meanX = 0,
1154
+ meanY = 0,
1155
+ meanXY = 0,
1156
+ meanX2 = 0;
1157
+ visitPoints(data, x, y, (xi, yi) => {
1158
+ n++, meanX += (xi - meanX) / n, meanY += (yi - meanY) / n, meanXY += (xi * yi - meanXY) / n, meanX2 += (xi * xi - meanX2) / n;
1075
1159
  });
1076
- const coef = ordinaryLeastSquares(X, Y, XY, X2),
1077
- predict = x => coef[0] + coef[1] * x;
1160
+ const {
1161
+ a: a,
1162
+ b: b
1163
+ } = ordinaryLeastSquares(meanX, meanY, meanXY, meanX2),
1164
+ predict = xx => a + b * xx,
1165
+ comps = computeLinearCIComponents(data, x, y, predict);
1078
1166
  return {
1079
- coef: coef,
1167
+ coef: {
1168
+ a: a,
1169
+ b: b
1170
+ },
1080
1171
  predict: predict,
1081
- rSquared: rSquared(data, x, y, Y, predict)
1172
+ rSquared: rSquared(data, x, y, meanY, predict),
1173
+ evaluateGrid: function (N) {
1174
+ const out = [];
1175
+ if (0 === comps.n || N <= 0) return out;
1176
+ if (comps.min === comps.max) {
1177
+ for (let i = 0; i < N; i++) out.push({
1178
+ x: comps.min,
1179
+ y: predict(comps.min)
1180
+ });
1181
+ return out;
1182
+ }
1183
+ const step = (comps.max - comps.min) / (N - 1);
1184
+ for (let i = 0; i < N; i++) {
1185
+ const px = i === N - 1 ? comps.max : comps.min + step * i;
1186
+ out.push({
1187
+ x: px,
1188
+ y: predict(px)
1189
+ });
1190
+ }
1191
+ return out;
1192
+ },
1193
+ confidenceInterval: function (N = 50, alpha = .05) {
1194
+ const out = [];
1195
+ if (0 === comps.n || N <= 0) return out;
1196
+ const z = invNorm(1 - alpha / 2);
1197
+ if (comps.min === comps.max) {
1198
+ const m = predict(comps.min),
1199
+ errs = stdErrorsAt(comps.min, comps);
1200
+ for (let i = 0; i < N; i++) out.push({
1201
+ x: comps.min,
1202
+ mean: m,
1203
+ lower: m - z * errs.seMean,
1204
+ upper: m + z * errs.seMean,
1205
+ predLower: m - z * errs.sePred,
1206
+ predUpper: m + z * errs.sePred
1207
+ });
1208
+ return out;
1209
+ }
1210
+ const step = (comps.max - comps.min) / (N - 1);
1211
+ for (let i = 0; i < N; i++) {
1212
+ const px = i === N - 1 ? comps.max : comps.min + step * i,
1213
+ m = predict(px),
1214
+ errs = stdErrorsAt(px, comps);
1215
+ out.push({
1216
+ x: px,
1217
+ mean: m,
1218
+ lower: m - z * errs.seMean,
1219
+ upper: m + z * errs.seMean,
1220
+ predLower: m - z * errs.sePred,
1221
+ predUpper: m + z * errs.sePred
1222
+ });
1223
+ }
1224
+ return out;
1225
+ }
1082
1226
  };
1083
1227
  }
1084
1228
 
@@ -5974,6 +6118,59 @@
5974
6118
  return 0;
5975
6119
  }
5976
6120
 
6121
+ const bin = (data, options) => {
6122
+ var _a, _b, _c, _d, _e, _f, _g, _h;
6123
+ const field = null == options ? void 0 : options.field;
6124
+ if (!field) return [];
6125
+ const n = data.length;
6126
+ let thresholds,
6127
+ min = 1 / 0,
6128
+ max = -1 / 0;
6129
+ if (null == options ? void 0 : options.extent) min = options.extent[0], max = options.extent[1];else for (let i = 0; i < n; i++) {
6130
+ const v = data[i][field];
6131
+ if (isNil$1(v)) continue;
6132
+ const num = +v;
6133
+ Number.isFinite(num) && (num < min && (min = num), num > max && (max = num));
6134
+ }
6135
+ if (!Number.isFinite(min) || !Number.isFinite(max) || 0 === n) return [];
6136
+ if (options && options.thresholds && options.thresholds.length) thresholds = options.thresholds.slice(), thresholds.sort((a, b) => a - b);else if (options && "number" == typeof options.step && options.step > 0) {
6137
+ const stepSize = options.step;
6138
+ let startMin = min;
6139
+ for (options.extent || (startMin = Math.floor(min / stepSize) * stepSize), thresholds = [startMin]; startMin < max;) startMin += stepSize, thresholds.push(startMin);
6140
+ } else {
6141
+ const bins = (null == options ? void 0 : options.bins) && options.bins > 0 ? Math.floor(options.bins) : 10,
6142
+ stepSize = (max - min) / bins;
6143
+ thresholds = new Array(bins + 1);
6144
+ for (let i = 0; i <= bins; i++) thresholds[i] = i === bins ? max : min + stepSize * i;
6145
+ }
6146
+ const numBins = Math.max(0, thresholds.length - 1);
6147
+ if (0 === numBins) return [];
6148
+ const x0Name = null !== (_b = null === (_a = options.outputNames) || void 0 === _a ? void 0 : _a.x0) && void 0 !== _b ? _b : "x0",
6149
+ x1Name = null !== (_d = null === (_c = options.outputNames) || void 0 === _c ? void 0 : _c.x1) && void 0 !== _d ? _d : "x1",
6150
+ countName = null !== (_f = null === (_e = options.outputNames) || void 0 === _e ? void 0 : _e.count) && void 0 !== _f ? _f : "count",
6151
+ valuesName = null !== (_h = null === (_g = options.outputNames) || void 0 === _g ? void 0 : _g.values) && void 0 !== _h ? _h : "values",
6152
+ out = new Array(numBins);
6153
+ for (let i = 0; i < numBins; i++) out[i] = {
6154
+ [x0Name]: thresholds[i],
6155
+ [x1Name]: thresholds[i + 1],
6156
+ [countName]: 0
6157
+ }, (null == options ? void 0 : options.includeValues) && (out[i][valuesName] = []);
6158
+ for (let i = 0; i < n; i++) {
6159
+ const v = data[i][field];
6160
+ if (null == v) continue;
6161
+ const num = +v;
6162
+ if (Number.isFinite(num)) for (let j = 0; j < numBins; j++) {
6163
+ const left = out[j][x0Name],
6164
+ right = out[j][x1Name];
6165
+ if (num >= left && num < right || j === numBins - 1 && num <= right) {
6166
+ out[j][countName]++, options && options.includeValues && out[j][valuesName].push(data[i]);
6167
+ break;
6168
+ }
6169
+ }
6170
+ }
6171
+ return out;
6172
+ };
6173
+
5977
6174
  var EOL = {},
5978
6175
  EOF = {},
5979
6176
  QUOTE = 34,
@@ -38702,7 +38899,9 @@
38702
38899
  space = bandSpace(n, this._paddingInner, this._paddingOuter);
38703
38900
  return this._step = (stop - start) / Math.max(1, space || 1), this._round && (this._step = Math.floor(this._step)), start += (stop - start - this._step * (n - this._paddingInner)) * this._align, this.isBandwidthFixed() || (this._bandwidth = this._step * (1 - this._paddingInner)), this._round && (start = Math.round(start), this.isBandwidthFixed() || (this._bandwidth = Math.round(this._bandwidth))), this._bandRangeState = {
38704
38901
  reverse: reverse,
38705
- start: reverse ? start + this._step * (n - 1) : start,
38902
+ start: reverse ? clamp$1(start + this._step * (n - 1), wholeRange[1], wholeRange[0]) : clamp$1(start, wholeRange[0], wholeRange[1]),
38903
+ min: reverse ? wholeRange[1] : wholeRange[0],
38904
+ max: stop,
38706
38905
  count: n
38707
38906
  }, this.generateFishEyeTransform(), this;
38708
38907
  }
@@ -38719,10 +38918,12 @@
38719
38918
  const {
38720
38919
  count: count,
38721
38920
  start: start,
38722
- reverse: reverse
38921
+ reverse: reverse,
38922
+ min: min,
38923
+ max: max
38723
38924
  } = this._bandRangeState,
38724
38925
  output = start + (reverse ? -1 : 1) * ((i - 1) % count) * this._step;
38725
- return this._fishEyeTransform ? this._fishEyeTransform(output) : output;
38926
+ return clamp$1(this._fishEyeTransform ? this._fishEyeTransform(output) : output, min, max);
38726
38927
  }
38727
38928
  _calculateWholeRange(range, changeProperty) {
38728
38929
  if (this._wholeRange) return this._wholeRange;
@@ -42230,6 +42431,19 @@
42230
42431
  }
42231
42432
  mixin(CircleAxisGrid, CircleAxisMixin);
42232
42433
 
42434
+ var DataZoomActiveTag;
42435
+ !function (DataZoomActiveTag) {
42436
+ DataZoomActiveTag.startHandler = "startHandler", DataZoomActiveTag.endHandler = "endHandler", DataZoomActiveTag.middleHandler = "middleHandler", DataZoomActiveTag.background = "background";
42437
+ }(DataZoomActiveTag || (DataZoomActiveTag = {}));
42438
+ var IDataZoomInteractiveEvent;
42439
+ !function (IDataZoomInteractiveEvent) {
42440
+ IDataZoomInteractiveEvent.stateUpdate = "stateUpdate", IDataZoomInteractiveEvent.maskUpdate = "maskUpdate", IDataZoomInteractiveEvent.dataZoomUpdate = "dataZoomUpdate";
42441
+ }(IDataZoomInteractiveEvent || (IDataZoomInteractiveEvent = {}));
42442
+ var IDataZoomEvent;
42443
+ !function (IDataZoomEvent) {
42444
+ IDataZoomEvent.dataZoomChange = "dataZoomChange";
42445
+ }(IDataZoomEvent || (IDataZoomEvent = {}));
42446
+
42233
42447
  const DEFAULT_HANDLER_PATH = "M -0.0544 0.25 C -0.0742 0.25 -0.0901 0.234 -0.0901 0.2143 L -0.0901 -0.1786 C -0.0901 -0.1983 -0.0742 -0.2143 -0.0544 -0.2143 L -0.0187 -0.2143 L -0.0187 -0.5 L 0.017 -0.5 L 0.017 -0.2143 L 0.0527 -0.2143 C 0.0724 -0.2143 0.0884 -0.1983 0.0884 -0.1786 L 0.0884 0.2143 C 0.0884 0.234 0.0724 0.25 0.0527 0.25 L 0.017 0.25 L 0.017 0.5 L -0.0187 0.5 L -0.0187 0.25 L -0.0544 0.25 Z M -0.0187 -0.1429 L -0.0544 -0.1429 L -0.0544 0.1786 L -0.0187 0.1786 L -0.0187 -0.1429 Z M 0.0527 -0.1429 L 0.017 -0.1429 L 0.017 0.1786 L 0.0527 0.1786 L 0.0527 -0.1429 Z";
42234
42448
  const DEFAULT_DATA_ZOOM_ATTRIBUTES = {
42235
42449
  orient: "bottom",
@@ -42347,14 +42561,17 @@
42347
42561
  }
42348
42562
  };
42349
42563
 
42350
- var DataZoomActiveTag;
42351
- !function (DataZoomActiveTag) {
42352
- DataZoomActiveTag.startHandler = "startHandler", DataZoomActiveTag.endHandler = "endHandler", DataZoomActiveTag.middleHandler = "middleHandler", DataZoomActiveTag.background = "background";
42353
- }(DataZoomActiveTag || (DataZoomActiveTag = {}));
42354
-
42355
- function loadDataZoomComponent() {
42356
- loadTagComponent(), registerRect(), registerSymbol(), registerArea(), registerLine();
42357
- }
42564
+ const isTextOverflow = (componentBoundsLike, textBounds, layout, isHorizontal) => {
42565
+ if (!textBounds) return !1;
42566
+ if (isHorizontal) {
42567
+ if ("start" === layout) {
42568
+ if (textBounds.x1 < componentBoundsLike.x1) return !0;
42569
+ } else if (textBounds.x2 > componentBoundsLike.x2) return !0;
42570
+ } else if ("start" === layout) {
42571
+ if (textBounds.y1 < componentBoundsLike.y1) return !0;
42572
+ } else if (textBounds.y2 > componentBoundsLike.y2) return !0;
42573
+ return !1;
42574
+ };
42358
42575
 
42359
42576
  var __rest$1 = undefined && undefined.__rest || function (s, e) {
42360
42577
  var t = {};
@@ -42365,176 +42582,96 @@
42365
42582
  }
42366
42583
  return t;
42367
42584
  };
42368
- const delayMap$2 = {
42369
- debounce: debounce,
42370
- throttle: throttle
42371
- };
42372
- loadDataZoomComponent();
42373
- let DataZoom$1 = class DataZoom extends AbstractComponent {
42374
- setPropsFromAttrs() {
42585
+ class DataZoomRenderer {
42586
+ get startHandlerMask() {
42587
+ return this._startHandlerMask;
42588
+ }
42589
+ get middleHandlerSymbol() {
42590
+ return this._middleHandlerSymbol;
42591
+ }
42592
+ get middleHandlerRect() {
42593
+ return this._middleHandlerRect;
42594
+ }
42595
+ get endHandlerMask() {
42596
+ return this._endHandlerMask;
42597
+ }
42598
+ get selectedBackground() {
42599
+ return this._selectedBackground;
42600
+ }
42601
+ get dragMask() {
42602
+ return this._dragMask;
42603
+ }
42604
+ get startText() {
42605
+ return this._startText;
42606
+ }
42607
+ get endText() {
42608
+ return this._endText;
42609
+ }
42610
+ get startValue() {
42611
+ return this._startValue;
42612
+ }
42613
+ get endValue() {
42614
+ return this._endValue;
42615
+ }
42616
+ set showText(showText) {
42617
+ this._showText = showText;
42618
+ }
42619
+ get background() {
42620
+ return this._background;
42621
+ }
42622
+ set previewData(previewData) {
42623
+ this._previewData = previewData;
42624
+ }
42625
+ get previewGroup() {
42626
+ return this._previewGroup;
42627
+ }
42628
+ get selectedPreviewGroup() {
42629
+ return this._selectedPreviewGroup;
42630
+ }
42631
+ set previewPointsX(previewPointsX) {
42632
+ this._previewPointsX = previewPointsX;
42633
+ }
42634
+ set previewPointsY(previewPointsY) {
42635
+ this._previewPointsY = previewPointsY;
42636
+ }
42637
+ set previewPointsX1(previewPointsX1) {
42638
+ this._previewPointsX1 = previewPointsX1;
42639
+ }
42640
+ set previewPointsY1(previewPointsY1) {
42641
+ this._previewPointsY1 = previewPointsY1;
42642
+ }
42643
+ set statePointToData(statePointToData) {
42644
+ this._statePointToData = statePointToData;
42645
+ }
42646
+ _initAttrs(props) {
42647
+ this.attribute = props.attribute, this._isHorizontal = "top" === this.attribute.orient || "bottom" === this.attribute.orient;
42375
42648
  const {
42376
- start: start,
42377
- end: end,
42378
- orient: orient,
42379
42649
  previewData: previewData,
42380
42650
  previewPointsX: previewPointsX,
42381
42651
  previewPointsY: previewPointsY,
42382
42652
  previewPointsX1: previewPointsX1,
42383
42653
  previewPointsY1: previewPointsY1
42384
42654
  } = this.attribute;
42385
- start && (this.state.start = start), end && (this.state.end = end);
42386
- const {
42387
- width: width,
42388
- height: height
42389
- } = this.getLayoutAttrFromConfig();
42390
- this._spanCache = this.state.end - this.state.start, this._isHorizontal = "top" === orient || "bottom" === orient, this._layoutCache.max = this._isHorizontal ? width : height, this._layoutCache.attPos = this._isHorizontal ? "x" : "y", this._layoutCache.attSize = this._isHorizontal ? "width" : "height", previewData && (this._previewData = previewData), isFunction$1(previewPointsX) && (this._previewPointsX = previewPointsX), isFunction$1(previewPointsY) && (this._previewPointsY = previewPointsY), isFunction$1(previewPointsX1) && (this._previewPointsX1 = previewPointsX1), isFunction$1(previewPointsY1) && (this._previewPointsY1 = previewPointsY1);
42655
+ previewData && (this._previewData = previewData), isFunction$1(previewPointsX) && (this._previewPointsX = previewPointsX), isFunction$1(previewPointsY) && (this._previewPointsY = previewPointsY), isFunction$1(previewPointsX1) && (this._previewPointsX1 = previewPointsX1), isFunction$1(previewPointsY1) && (this._previewPointsY1 = previewPointsY1), this._getState = props.getState, this._getLayoutAttrFromConfig = props.getLayoutAttrFromConfig, this._getContainer = props.getContainer;
42391
42656
  }
42392
- constructor(attributes, options) {
42393
- super((null == options ? void 0 : options.skipDefault) ? attributes : merge$1({}, DataZoom.defaultAttributes, attributes)), this.name = "dataZoom", this._previewData = [], this._activeState = !1, this._activeCache = {
42394
- startPos: {
42395
- x: 0,
42396
- y: 0
42397
- },
42398
- lastPos: {
42399
- x: 0,
42400
- y: 0
42401
- }
42402
- }, this._layoutCache = {
42403
- attPos: "x",
42404
- attSize: "width",
42405
- max: 0
42406
- }, this.state = {
42407
- start: 0,
42408
- end: 1
42409
- }, this._statePointToData = state => state, this._handleTouchMove = e => {
42410
- this._activeState && e.preventDefault();
42411
- }, this._onHandlerPointerDown = (e, tag) => {
42412
- this._clearDragEvents(), "start" === tag ? (this._activeTag = DataZoomActiveTag.startHandler, this._activeItem = this._startHandlerMask) : "end" === tag ? (this._activeTag = DataZoomActiveTag.endHandler, this._activeItem = this._endHandlerMask) : "middleRect" === tag ? (this._activeTag = DataZoomActiveTag.middleHandler, this._activeItem = this._middleHandlerRect) : "middleSymbol" === tag ? (this._activeTag = DataZoomActiveTag.middleHandler, this._activeItem = this._middleHandlerSymbol) : "background" === tag && (this._activeTag = DataZoomActiveTag.background, this._activeItem = this._background), this._activeState = !0, this._activeCache.startPos = this.eventPosToStagePos(e), this._activeCache.lastPos = this.eventPosToStagePos(e);
42413
- const evtTarget = "browser" === vglobal.env ? vglobal : this.stage,
42414
- triggers = getEndTriggersOfDrag();
42415
- evtTarget.addEventListener("pointermove", this._onHandlerPointerMove, {
42416
- capture: !0
42417
- }), this.addEventListener("pointermove", this._onHandlerPointerMove, {
42418
- capture: !0
42419
- }), triggers.forEach(trigger => {
42420
- evtTarget.addEventListener(trigger, this._onHandlerPointerUp);
42421
- });
42422
- }, this._pointerMove = e => {
42423
- const {
42424
- start: startAttr,
42425
- end: endAttr,
42426
- brushSelect: brushSelect,
42427
- realTime = !0
42428
- } = this.attribute,
42429
- pos = this.eventPosToStagePos(e),
42430
- {
42431
- attPos: attPos,
42432
- max: max
42433
- } = this._layoutCache,
42434
- dis = (pos[attPos] - this._activeCache.lastPos[attPos]) / max;
42435
- let {
42436
- start: start,
42437
- end: end
42438
- } = this.state;
42439
- this._activeState && (this._activeTag === DataZoomActiveTag.middleHandler ? this.moveZoomWithMiddle((this.state.start + this.state.end) / 2 + dis) : this._activeTag === DataZoomActiveTag.startHandler ? start + dis > end ? (start = end, end = start + dis, this._activeTag = DataZoomActiveTag.endHandler) : start += dis : this._activeTag === DataZoomActiveTag.endHandler && (end + dis < start ? (end = start, start = end + dis, this._activeTag = DataZoomActiveTag.startHandler) : end += dis), this._activeCache.lastPos = pos, brushSelect && this.renderDragMask()), start = Math.min(Math.max(start, 0), 1), end = Math.min(Math.max(end, 0), 1), startAttr === start && endAttr === end || (this.setStateAttr(start, end, !0), realTime && this._dispatchEvent("change", {
42440
- start: start,
42441
- end: end,
42442
- tag: this._activeTag
42443
- }));
42444
- }, this._onHandlerPointerMove = 0 === this.attribute.delayTime ? this._pointerMove : delayMap$2[this.attribute.delayType](this._pointerMove, this.attribute.delayTime), this._onHandlerPointerUp = e => {
42445
- const {
42446
- start: start,
42447
- end: end,
42448
- brushSelect: brushSelect,
42449
- realTime = !0
42450
- } = this.attribute;
42451
- if (this._activeState && this._activeTag === DataZoomActiveTag.background) {
42452
- const pos = this.eventPosToStagePos(e);
42453
- this.backgroundDragZoom(this._activeCache.startPos, pos);
42454
- }
42455
- this._activeState = !1, brushSelect && this.renderDragMask(), this._dispatchEvent("change", {
42456
- start: this.state.start,
42457
- end: this.state.end,
42458
- tag: this._activeTag
42459
- }), this._clearDragEvents();
42460
- };
42657
+ constructor(props) {
42658
+ this._previewData = [], this._statePointToData = state => state;
42461
42659
  const {
42462
- position: position,
42463
42660
  showDetail: showDetail
42464
- } = attributes;
42465
- this._activeCache.startPos = position, this._activeCache.lastPos = position, this._showText = "auto" !== showDetail && showDetail, this.setPropsFromAttrs();
42661
+ } = props.attribute;
42662
+ this._showText = "auto" !== showDetail && showDetail, this._initAttrs(props);
42466
42663
  }
42467
- setAttributes(params, forceUpdateTag) {
42468
- super.setAttributes(params, forceUpdateTag), this.setPropsFromAttrs();
42664
+ setAttributes(props) {
42665
+ this._initAttrs(props);
42469
42666
  }
42470
- bindEvents() {
42471
- if (this.attribute.disableTriggerEvent) return void this.setAttribute("childrenPickable", !1);
42667
+ renderDataZoom(onlyStateChange = !1) {
42668
+ var _a, _b, _c, _d, _e, _f;
42472
42669
  const {
42473
- showDetail: showDetail,
42670
+ backgroundChartStyle = {},
42671
+ selectedBackgroundChartStyle = {},
42474
42672
  brushSelect: brushSelect
42475
42673
  } = this.attribute;
42476
- this._startHandlerMask && this._startHandlerMask.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, "start")), this._endHandlerMask && this._endHandlerMask.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, "end")), this._middleHandlerSymbol && this._middleHandlerSymbol.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, "middleSymbol")), this._middleHandlerRect && this._middleHandlerRect.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, "middleRect"));
42477
- const selectedTag = brushSelect ? "background" : "middleRect";
42478
- this._selectedBackground && this._selectedBackground.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, selectedTag)), brushSelect && this._background && this._background.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, "background")), brushSelect && this._previewGroup && this._previewGroup.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, "background")), this._selectedPreviewGroup && this._selectedPreviewGroup.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, selectedTag)), "auto" === showDetail && (this.addEventListener("pointerenter", this._onHandlerPointerEnter), this.addEventListener("pointerleave", this._onHandlerPointerLeave)), ("browser" === vglobal.env ? vglobal : this.stage).addEventListener("touchmove", this._handleTouchMove, {
42479
- passive: !1
42480
- });
42481
- }
42482
- dragMaskSize() {
42483
- const {
42484
- position: position
42485
- } = this.attribute,
42486
- {
42487
- attPos: attPos,
42488
- max: max
42489
- } = this._layoutCache;
42490
- return this._activeCache.lastPos[attPos] - position[attPos] > max ? max + position[attPos] - this._activeCache.startPos[attPos] : this._activeCache.lastPos[attPos] - position[attPos] < 0 ? position[attPos] - this._activeCache.startPos[attPos] : this._activeCache.lastPos[attPos] - this._activeCache.startPos[attPos];
42491
- }
42492
- setStateAttr(start, end, shouldRender) {
42493
- const {
42494
- zoomLock = !1,
42495
- minSpan = 0,
42496
- maxSpan = 1
42497
- } = this.attribute,
42498
- span = end - start;
42499
- span !== this._spanCache && (zoomLock || span < minSpan || span > maxSpan) || (this._spanCache = span, this.state.start = start, this.state.end = end, shouldRender && this.setAttributes({
42500
- start: start,
42501
- end: end
42502
- }));
42503
- }
42504
- _clearDragEvents() {
42505
- const evtTarget = "browser" === vglobal.env ? vglobal : this.stage,
42506
- triggers = getEndTriggersOfDrag();
42507
- evtTarget.removeEventListener("pointermove", this._onHandlerPointerMove, {
42508
- capture: !0
42509
- }), triggers.forEach(trigger => {
42510
- evtTarget.removeEventListener(trigger, this._onHandlerPointerUp);
42511
- }), this.removeEventListener("pointermove", this._onHandlerPointerMove, {
42512
- capture: !0
42513
- });
42514
- }
42515
- _onHandlerPointerEnter(e) {
42516
- this._showText = !0, this.renderText();
42517
- }
42518
- _onHandlerPointerLeave(e) {
42519
- this._showText = !1, this.renderText();
42520
- }
42521
- backgroundDragZoom(startPos, endPos) {
42522
- const {
42523
- attPos: attPos,
42524
- max: max
42525
- } = this._layoutCache,
42526
- {
42527
- position: position
42528
- } = this.attribute,
42529
- startPosInComponent = startPos[attPos] - position[attPos],
42530
- endPosInComponent = endPos[attPos] - position[attPos],
42531
- start = Math.min(Math.max(Math.min(startPosInComponent, endPosInComponent) / max, 0), 1),
42532
- end = Math.min(Math.max(Math.max(startPosInComponent, endPosInComponent) / max, 0), 1);
42533
- Math.abs(start - end) < .01 ? this.moveZoomWithMiddle(start) : this.setStateAttr(start, end, !1);
42534
- }
42535
- moveZoomWithMiddle(middle) {
42536
- let offset = middle - (this.state.start + this.state.end) / 2;
42537
- 0 !== offset && (offset > 0 ? this.state.end + offset > 1 && (offset = 1 - this.state.end) : offset < 0 && this.state.start + offset < 0 && (offset = -this.state.start), this.setStateAttr(this.state.start + offset, this.state.end + offset, !1));
42674
+ this._renderBackground(), (null === (_a = backgroundChartStyle.line) || void 0 === _a ? void 0 : _a.visible) && !onlyStateChange && this._setPreviewAttributes("line", this._getContainer()), (null === (_b = backgroundChartStyle.area) || void 0 === _b ? void 0 : _b.visible) && !onlyStateChange && this._setPreviewAttributes("area", this._getContainer()), brushSelect && this.renderDragMask(), this._renderSelectedBackground(), (null === (_c = selectedBackgroundChartStyle.line) || void 0 === _c ? void 0 : _c.visible) && this._setSelectedPreviewClipAttributes("line", this._getContainer()), (null === (_d = selectedBackgroundChartStyle.line) || void 0 === _d ? void 0 : _d.visible) && !onlyStateChange && this._setSelectedPreviewAttributes("line"), (null === (_e = selectedBackgroundChartStyle.line) || void 0 === _e ? void 0 : _e.visible) && this._setSelectedPreviewClipAttributes("area", this._getContainer()), (null === (_f = selectedBackgroundChartStyle.area) || void 0 === _f ? void 0 : _f.visible) && !onlyStateChange && this._setSelectedPreviewAttributes("area"), this._renderHandler(), this._showText && this.renderText();
42538
42675
  }
42539
42676
  renderDragMask() {
42540
42677
  const {
@@ -42544,254 +42681,104 @@
42544
42681
  position: position,
42545
42682
  width: width,
42546
42683
  height: height
42547
- } = this.getLayoutAttrFromConfig();
42548
- this._isHorizontal ? this._dragMask = this._container.createOrUpdateChild("dragMask", Object.assign({
42549
- x: clamp$1(this.dragMaskSize() < 0 ? this._activeCache.lastPos.x : this._activeCache.startPos.x, position.x, position.x + width),
42684
+ } = this._getLayoutAttrFromConfig(),
42685
+ {
42686
+ start: start,
42687
+ end: end
42688
+ } = this._getState();
42689
+ return this._isHorizontal ? this._dragMask = this._getContainer().createOrUpdateChild("dragMask", Object.assign({
42690
+ x: position.x + start * width,
42550
42691
  y: position.y,
42551
- width: this._activeState && this._activeTag === DataZoomActiveTag.background && Math.abs(this.dragMaskSize()) || 0,
42692
+ width: (end - start) * width,
42552
42693
  height: height
42553
- }, dragMaskStyle), "rect") : this._dragMask = this._container.createOrUpdateChild("dragMask", Object.assign({
42694
+ }, dragMaskStyle), "rect") : this._dragMask = this._getContainer().createOrUpdateChild("dragMask", Object.assign({
42554
42695
  x: position.x,
42555
- y: clamp$1(this.dragMaskSize() < 0 ? this._activeCache.lastPos.y : this._activeCache.startPos.y, position.y, position.y + height),
42696
+ y: position.y + start * height,
42556
42697
  width: width,
42557
- height: this._activeState && this._activeTag === DataZoomActiveTag.background && Math.abs(this.dragMaskSize()) || 0
42558
- }, dragMaskStyle), "rect");
42559
- }
42560
- isTextOverflow(componentBoundsLike, textBounds, layout) {
42561
- if (!textBounds) return !1;
42562
- if (this._isHorizontal) {
42563
- if ("start" === layout) {
42564
- if (textBounds.x1 < componentBoundsLike.x1) return !0;
42565
- } else if (textBounds.x2 > componentBoundsLike.x2) return !0;
42566
- } else if ("start" === layout) {
42567
- if (textBounds.y1 < componentBoundsLike.y1) return !0;
42568
- } else if (textBounds.y2 > componentBoundsLike.y2) return !0;
42569
- return !1;
42698
+ height: (end - start) * height
42699
+ }, dragMaskStyle), "rect"), {
42700
+ start: start,
42701
+ end: end
42702
+ };
42570
42703
  }
42571
- setTextAttr(startTextBounds, endTextBounds) {
42572
- var _a, _b, _c, _d, _e, _f, _g, _h;
42704
+ _renderBackground() {
42705
+ var _a;
42573
42706
  const {
42574
- startTextStyle: startTextStyle,
42575
- endTextStyle: endTextStyle
42707
+ backgroundStyle: backgroundStyle,
42708
+ brushSelect: brushSelect,
42709
+ zoomLock: zoomLock
42576
42710
  } = this.attribute,
42577
42711
  {
42578
- formatMethod: startTextFormat
42579
- } = startTextStyle,
42580
- restStartTextStyle = __rest$1(startTextStyle, ["formatMethod"]),
42581
- {
42582
- formatMethod: endTextFormat
42583
- } = endTextStyle,
42584
- restEndTextStyle = __rest$1(endTextStyle, ["formatMethod"]),
42585
- {
42586
- start: start,
42587
- end: end
42588
- } = this.state;
42589
- this._startValue = this._statePointToData(start), this._endValue = this._statePointToData(end);
42590
- const {
42591
42712
  position: position,
42592
42713
  width: width,
42593
42714
  height: height
42594
- } = this.getLayoutAttrFromConfig(),
42595
- startTextValue = startTextFormat ? startTextFormat(this._startValue) : this._startValue,
42596
- endTextValue = endTextFormat ? endTextFormat(this._endValue) : this._endValue,
42597
- componentBoundsLike = {
42598
- x1: position.x,
42599
- y1: position.y,
42600
- x2: position.x + width,
42601
- y2: position.y + height
42602
- };
42603
- let startTextPosition, endTextPosition, startTextAlignStyle, endTextAlignStyle;
42604
- this._isHorizontal ? (startTextPosition = {
42605
- x: position.x + start * width,
42606
- y: position.y + height / 2
42607
- }, endTextPosition = {
42608
- x: position.x + end * width,
42609
- y: position.y + height / 2
42610
- }, startTextAlignStyle = {
42611
- textAlign: this.isTextOverflow(componentBoundsLike, startTextBounds, "start") ? "left" : "right",
42612
- textBaseline: null !== (_b = null === (_a = null == restStartTextStyle ? void 0 : restStartTextStyle.textStyle) || void 0 === _a ? void 0 : _a.textBaseline) && void 0 !== _b ? _b : "middle"
42613
- }, endTextAlignStyle = {
42614
- textAlign: this.isTextOverflow(componentBoundsLike, endTextBounds, "end") ? "right" : "left",
42615
- textBaseline: null !== (_d = null === (_c = null == restEndTextStyle ? void 0 : restEndTextStyle.textStyle) || void 0 === _c ? void 0 : _c.textBaseline) && void 0 !== _d ? _d : "middle"
42616
- }) : (startTextPosition = {
42617
- x: position.x + width / 2,
42618
- y: position.y + start * height
42619
- }, endTextPosition = {
42620
- x: position.x + width / 2,
42621
- y: position.y + end * height
42622
- }, startTextAlignStyle = {
42623
- textAlign: null !== (_f = null === (_e = null == restStartTextStyle ? void 0 : restStartTextStyle.textStyle) || void 0 === _e ? void 0 : _e.textAlign) && void 0 !== _f ? _f : "center",
42624
- textBaseline: this.isTextOverflow(componentBoundsLike, startTextBounds, "start") ? "top" : "bottom"
42625
- }, endTextAlignStyle = {
42626
- textAlign: null !== (_h = null === (_g = null == restEndTextStyle ? void 0 : restEndTextStyle.textStyle) || void 0 === _g ? void 0 : _g.textAlign) && void 0 !== _h ? _h : "center",
42627
- textBaseline: this.isTextOverflow(componentBoundsLike, endTextBounds, "end") ? "bottom" : "top"
42628
- }), this._startText = this.maybeAddLabel(this._container, merge$1({}, restStartTextStyle, {
42629
- text: startTextValue,
42630
- x: startTextPosition.x,
42631
- y: startTextPosition.y,
42632
- visible: this._showText,
42633
- pickable: !1,
42634
- childrenPickable: !1,
42635
- textStyle: startTextAlignStyle
42636
- }), `data-zoom-start-text-${position}`), this._endText = this.maybeAddLabel(this._container, merge$1({}, restEndTextStyle, {
42637
- text: endTextValue,
42638
- x: endTextPosition.x,
42639
- y: endTextPosition.y,
42640
- visible: this._showText,
42641
- pickable: !1,
42642
- childrenPickable: !1,
42643
- textStyle: endTextAlignStyle
42644
- }), `data-zoom-end-text-${position}`);
42645
- }
42646
- renderText() {
42647
- let startTextBounds = null,
42648
- endTextBounds = null;
42649
- this.setTextAttr(startTextBounds, endTextBounds), startTextBounds = this._startText.AABBBounds, endTextBounds = this._endText.AABBBounds, this.setTextAttr(startTextBounds, endTextBounds), startTextBounds = this._startText.AABBBounds, endTextBounds = this._endText.AABBBounds;
42650
- const {
42651
- x1: x1,
42652
- x2: x2,
42653
- y1: y1,
42654
- y2: y2
42655
- } = startTextBounds,
42656
- {
42657
- dx: startTextDx = 0,
42658
- dy: startTextDy = 0
42659
- } = this.attribute.startTextStyle;
42660
- if (new Bounds().set(x1, y1, x2, y2).intersects(endTextBounds)) {
42661
- const direction = "bottom" === this.attribute.orient || "right" === this.attribute.orient ? -1 : 1;
42662
- if (this._isHorizontal) {
42663
- const boundsYDiff = Math.abs(endTextBounds.y1 - endTextBounds.y2);
42664
- this._startText.setAttribute("dy", startTextDy + direction * (Number.isFinite(boundsYDiff) ? boundsYDiff : 0));
42665
- } else {
42666
- const boundsXDiff = Math.abs(endTextBounds.x1 - endTextBounds.x2);
42667
- this._startText.setAttribute("dx", startTextDx + direction * (Number.isFinite(boundsXDiff) ? boundsXDiff : 0));
42668
- }
42669
- } else this._isHorizontal ? this._startText.setAttribute("dy", startTextDy) : this._startText.setAttribute("dx", startTextDx);
42670
- }
42671
- getLayoutAttrFromConfig() {
42672
- var _a, _b, _c, _d, _e, _f;
42673
- if (this._layoutAttrFromConfig) return this._layoutAttrFromConfig;
42674
- const {
42675
- position: positionConfig,
42676
- size: size,
42677
- orient: orient,
42678
- middleHandlerStyle = {},
42679
- startHandlerStyle = {},
42680
- endHandlerStyle = {},
42681
- backgroundStyle = {}
42682
- } = this.attribute,
42683
- {
42684
- width: widthConfig,
42685
- height: heightConfig
42686
- } = size,
42687
- middleHandlerSize = null !== (_b = null === (_a = middleHandlerStyle.background) || void 0 === _a ? void 0 : _a.size) && void 0 !== _b ? _b : 10;
42688
- let width, height, position;
42689
- middleHandlerStyle.visible ? this._isHorizontal ? (width = widthConfig, height = heightConfig - middleHandlerSize, position = {
42690
- x: positionConfig.x,
42691
- y: positionConfig.y + middleHandlerSize
42692
- }) : (width = widthConfig - middleHandlerSize, height = heightConfig, position = {
42693
- x: positionConfig.x + ("left" === orient ? middleHandlerSize : 0),
42694
- y: positionConfig.y
42695
- }) : (width = widthConfig, height = heightConfig, position = positionConfig);
42696
- const startHandlerSize = null !== (_c = startHandlerStyle.size) && void 0 !== _c ? _c : this._isHorizontal ? height : width,
42697
- endHandlerSize = null !== (_d = endHandlerStyle.size) && void 0 !== _d ? _d : this._isHorizontal ? height : width;
42698
- return startHandlerStyle.visible && (this._isHorizontal ? (width -= (startHandlerSize + endHandlerSize) / 2, position = {
42699
- x: position.x + startHandlerSize / 2,
42700
- y: position.y
42701
- }) : (height -= (startHandlerSize + endHandlerSize) / 2, position = {
42715
+ } = this._getLayoutAttrFromConfig(),
42716
+ group = this._getContainer();
42717
+ this._background = group.createOrUpdateChild("background", Object.assign(Object.assign({
42702
42718
  x: position.x,
42703
- y: position.y + startHandlerSize / 2
42704
- })), height += null !== (_e = backgroundStyle.lineWidth / 2) && void 0 !== _e ? _e : 1, width += null !== (_f = backgroundStyle.lineWidth / 2) && void 0 !== _f ? _f : 1, this._layoutAttrFromConfig = {
42705
- position: position,
42719
+ y: position.y,
42706
42720
  width: width,
42707
- height: height
42708
- }, this._layoutAttrFromConfig;
42721
+ height: height,
42722
+ cursor: brushSelect ? "crosshair" : "auto"
42723
+ }, backgroundStyle), {
42724
+ pickable: !zoomLock && (null === (_a = backgroundStyle.pickable) || void 0 === _a || _a)
42725
+ }), "rect");
42709
42726
  }
42710
- render() {
42711
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
42712
- this._layoutAttrFromConfig = null;
42727
+ _renderHandler() {
42728
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
42713
42729
  const {
42714
42730
  orient: orient,
42715
- backgroundStyle: backgroundStyle,
42716
- backgroundChartStyle = {},
42717
- selectedBackgroundStyle = {},
42718
- selectedBackgroundChartStyle = {},
42719
42731
  middleHandlerStyle = {},
42720
42732
  startHandlerStyle = {},
42721
42733
  endHandlerStyle = {},
42722
- brushSelect: brushSelect,
42723
42734
  zoomLock: zoomLock
42724
42735
  } = this.attribute,
42725
42736
  {
42726
42737
  start: start,
42727
42738
  end: end
42728
- } = this.state,
42739
+ } = this._getState(),
42729
42740
  {
42730
42741
  position: position,
42731
42742
  width: width,
42732
42743
  height: height
42733
- } = this.getLayoutAttrFromConfig(),
42744
+ } = this._getLayoutAttrFromConfig(),
42734
42745
  startHandlerMinSize = null !== (_a = startHandlerStyle.triggerMinSize) && void 0 !== _a ? _a : 40,
42735
42746
  endHandlerMinSize = null !== (_b = endHandlerStyle.triggerMinSize) && void 0 !== _b ? _b : 40,
42736
- group = this.createOrUpdateChild("dataZoom-container", {}, "group");
42737
- if (this._container = group, this._background = group.createOrUpdateChild("background", Object.assign(Object.assign({
42738
- x: position.x,
42739
- y: position.y,
42740
- width: width,
42741
- height: height,
42742
- cursor: brushSelect ? "crosshair" : "auto"
42743
- }, backgroundStyle), {
42744
- pickable: !zoomLock && (null === (_c = backgroundStyle.pickable) || void 0 === _c || _c)
42745
- }), "rect"), (null === (_d = backgroundChartStyle.line) || void 0 === _d ? void 0 : _d.visible) && this.setPreviewAttributes("line", group), (null === (_e = backgroundChartStyle.area) || void 0 === _e ? void 0 : _e.visible) && this.setPreviewAttributes("area", group), brushSelect && this.renderDragMask(), this._isHorizontal ? this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign(Object.assign({
42746
- x: position.x + start * width,
42747
- y: position.y,
42748
- width: (end - start) * width,
42749
- height: height,
42750
- cursor: brushSelect ? "crosshair" : "move"
42751
- }, selectedBackgroundStyle), {
42752
- pickable: !zoomLock && (null === (_f = selectedBackgroundChartStyle.pickable) || void 0 === _f || _f)
42753
- }), "rect") : this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign(Object.assign({
42754
- x: position.x,
42755
- y: position.y + start * height,
42756
- width: width,
42757
- height: (end - start) * height,
42758
- cursor: brushSelect ? "crosshair" : "move"
42759
- }, selectedBackgroundStyle), {
42760
- pickable: !zoomLock && (null === (_g = selectedBackgroundStyle.pickable) || void 0 === _g || _g)
42761
- }), "rect"), (null === (_h = selectedBackgroundChartStyle.line) || void 0 === _h ? void 0 : _h.visible) && this.setSelectedPreviewAttributes("line", group), (null === (_j = selectedBackgroundChartStyle.area) || void 0 === _j ? void 0 : _j.visible) && this.setSelectedPreviewAttributes("area", group), this._isHorizontal) {
42747
+ group = this._getContainer();
42748
+ if (this._isHorizontal) {
42762
42749
  if (middleHandlerStyle.visible) {
42763
- const middleHandlerBackgroundSize = (null === (_k = middleHandlerStyle.background) || void 0 === _k ? void 0 : _k.size) || 10;
42750
+ const middleHandlerBackgroundSize = (null === (_c = middleHandlerStyle.background) || void 0 === _c ? void 0 : _c.size) || 10;
42764
42751
  this._middleHandlerRect = group.createOrUpdateChild("middleHandlerRect", Object.assign(Object.assign({
42765
42752
  x: position.x + start * width,
42766
42753
  y: position.y - middleHandlerBackgroundSize,
42767
42754
  width: (end - start) * width,
42768
42755
  height: middleHandlerBackgroundSize
42769
- }, null === (_l = middleHandlerStyle.background) || void 0 === _l ? void 0 : _l.style), {
42770
- pickable: !zoomLock && (null === (_p = null === (_o = null === (_m = middleHandlerStyle.background) || void 0 === _m ? void 0 : _m.style) || void 0 === _o ? void 0 : _o.pickable) || void 0 === _p || _p)
42756
+ }, null === (_d = middleHandlerStyle.background) || void 0 === _d ? void 0 : _d.style), {
42757
+ pickable: !zoomLock && (null === (_g = null === (_f = null === (_e = middleHandlerStyle.background) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.pickable) || void 0 === _g || _g)
42771
42758
  }), "rect"), this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign(Object.assign({
42772
42759
  x: position.x + (start + end) / 2 * width,
42773
42760
  y: position.y - middleHandlerBackgroundSize / 2,
42774
42761
  strokeBoundsBuffer: 0,
42775
42762
  angle: 0,
42776
- symbolType: null !== (_r = null === (_q = middleHandlerStyle.icon) || void 0 === _q ? void 0 : _q.symbolType) && void 0 !== _r ? _r : "square"
42763
+ symbolType: null !== (_j = null === (_h = middleHandlerStyle.icon) || void 0 === _h ? void 0 : _h.symbolType) && void 0 !== _j ? _j : "square"
42777
42764
  }, middleHandlerStyle.icon), {
42778
- pickable: !zoomLock && (null === (_s = middleHandlerStyle.icon.pickable) || void 0 === _s || _s)
42765
+ pickable: !zoomLock && (null === (_k = middleHandlerStyle.icon.pickable) || void 0 === _k || _k)
42779
42766
  }), "symbol");
42780
42767
  }
42781
42768
  this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign({
42782
42769
  x: position.x + start * width,
42783
42770
  y: position.y + height / 2,
42784
42771
  size: height,
42785
- symbolType: null !== (_t = startHandlerStyle.symbolType) && void 0 !== _t ? _t : "square"
42772
+ symbolType: null !== (_l = startHandlerStyle.symbolType) && void 0 !== _l ? _l : "square"
42786
42773
  }, DEFAULT_HANDLER_ATTR_MAP.horizontal), startHandlerStyle), {
42787
- pickable: !zoomLock && (null === (_u = startHandlerStyle.pickable) || void 0 === _u || _u)
42774
+ pickable: !zoomLock && (null === (_m = startHandlerStyle.pickable) || void 0 === _m || _m)
42788
42775
  }), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign({
42789
42776
  x: position.x + end * width,
42790
42777
  y: position.y + height / 2,
42791
42778
  size: height,
42792
- symbolType: null !== (_v = endHandlerStyle.symbolType) && void 0 !== _v ? _v : "square"
42779
+ symbolType: null !== (_o = endHandlerStyle.symbolType) && void 0 !== _o ? _o : "square"
42793
42780
  }, DEFAULT_HANDLER_ATTR_MAP.horizontal), endHandlerStyle), {
42794
- pickable: !zoomLock && (null === (_w = endHandlerStyle.pickable) || void 0 === _w || _w)
42781
+ pickable: !zoomLock && (null === (_p = endHandlerStyle.pickable) || void 0 === _p || _p)
42795
42782
  }), "symbol");
42796
42783
  const startHandlerWidth = Math.max(this._startHandler.AABBBounds.width(), startHandlerMinSize),
42797
42784
  startHandlerHeight = Math.max(this._startHandler.AABBBounds.height(), startHandlerMinSize),
@@ -42820,38 +42807,38 @@
42820
42807
  }), "rect");
42821
42808
  } else {
42822
42809
  if (middleHandlerStyle.visible) {
42823
- const middleHandlerBackgroundSize = (null === (_x = middleHandlerStyle.background) || void 0 === _x ? void 0 : _x.size) || 10;
42810
+ const middleHandlerBackgroundSize = (null === (_q = middleHandlerStyle.background) || void 0 === _q ? void 0 : _q.size) || 10;
42824
42811
  this._middleHandlerRect = group.createOrUpdateChild("middleHandlerRect", Object.assign(Object.assign({
42825
42812
  x: "left" === orient ? position.x - middleHandlerBackgroundSize : position.x + width,
42826
42813
  y: position.y + start * height,
42827
42814
  width: middleHandlerBackgroundSize,
42828
42815
  height: (end - start) * height
42829
- }, null === (_y = middleHandlerStyle.background) || void 0 === _y ? void 0 : _y.style), {
42830
- pickable: !zoomLock && (null === (_1 = null === (_0 = null === (_z = middleHandlerStyle.background) || void 0 === _z ? void 0 : _z.style) || void 0 === _0 ? void 0 : _0.pickable) || void 0 === _1 || _1)
42816
+ }, null === (_r = middleHandlerStyle.background) || void 0 === _r ? void 0 : _r.style), {
42817
+ pickable: !zoomLock && (null === (_u = null === (_t = null === (_s = middleHandlerStyle.background) || void 0 === _s ? void 0 : _s.style) || void 0 === _t ? void 0 : _t.pickable) || void 0 === _u || _u)
42831
42818
  }), "rect"), this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign(Object.assign({
42832
42819
  x: "left" === orient ? position.x - middleHandlerBackgroundSize / 2 : position.x + width + middleHandlerBackgroundSize / 2,
42833
42820
  y: position.y + (start + end) / 2 * height,
42834
42821
  angle: Math.PI / 180 * 90,
42835
- symbolType: null !== (_3 = null === (_2 = middleHandlerStyle.icon) || void 0 === _2 ? void 0 : _2.symbolType) && void 0 !== _3 ? _3 : "square",
42822
+ symbolType: null !== (_w = null === (_v = middleHandlerStyle.icon) || void 0 === _v ? void 0 : _v.symbolType) && void 0 !== _w ? _w : "square",
42836
42823
  strokeBoundsBuffer: 0
42837
42824
  }, middleHandlerStyle.icon), {
42838
- pickable: !zoomLock && (null === (_5 = null === (_4 = middleHandlerStyle.icon) || void 0 === _4 ? void 0 : _4.pickable) || void 0 === _5 || _5)
42825
+ pickable: !zoomLock && (null === (_y = null === (_x = middleHandlerStyle.icon) || void 0 === _x ? void 0 : _x.pickable) || void 0 === _y || _y)
42839
42826
  }), "symbol");
42840
42827
  }
42841
42828
  this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign({
42842
42829
  x: position.x + width / 2,
42843
42830
  y: position.y + start * height,
42844
42831
  size: width,
42845
- symbolType: null !== (_6 = startHandlerStyle.symbolType) && void 0 !== _6 ? _6 : "square"
42832
+ symbolType: null !== (_z = startHandlerStyle.symbolType) && void 0 !== _z ? _z : "square"
42846
42833
  }, DEFAULT_HANDLER_ATTR_MAP.vertical), startHandlerStyle), {
42847
- pickable: !zoomLock && (null === (_7 = startHandlerStyle.pickable) || void 0 === _7 || _7)
42834
+ pickable: !zoomLock && (null === (_0 = startHandlerStyle.pickable) || void 0 === _0 || _0)
42848
42835
  }), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign({
42849
42836
  x: position.x + width / 2,
42850
42837
  y: position.y + end * height,
42851
42838
  size: width,
42852
- symbolType: null !== (_8 = endHandlerStyle.symbolType) && void 0 !== _8 ? _8 : "square"
42839
+ symbolType: null !== (_1 = endHandlerStyle.symbolType) && void 0 !== _1 ? _1 : "square"
42853
42840
  }, DEFAULT_HANDLER_ATTR_MAP.vertical), endHandlerStyle), {
42854
- pickable: !zoomLock && (null === (_9 = endHandlerStyle.pickable) || void 0 === _9 || _9)
42841
+ pickable: !zoomLock && (null === (_2 = endHandlerStyle.pickable) || void 0 === _2 || _2)
42855
42842
  }), "symbol");
42856
42843
  const startHandlerWidth = Math.max(this._startHandler.AABBBounds.width(), startHandlerMinSize),
42857
42844
  startHandlerHeight = Math.max(this._startHandler.AABBBounds.height(), startHandlerMinSize),
@@ -42879,9 +42866,107 @@
42879
42866
  pickable: !zoomLock
42880
42867
  }), "rect");
42881
42868
  }
42882
- this._showText && this.renderText();
42883
42869
  }
42884
- computeBasePoints() {
42870
+ _renderSelectedBackground() {
42871
+ var _a, _b;
42872
+ const {
42873
+ selectedBackgroundStyle = {},
42874
+ selectedBackgroundChartStyle = {},
42875
+ brushSelect: brushSelect,
42876
+ zoomLock: zoomLock
42877
+ } = this.attribute,
42878
+ {
42879
+ start: start,
42880
+ end: end
42881
+ } = this._getState(),
42882
+ {
42883
+ position: position,
42884
+ width: width,
42885
+ height: height
42886
+ } = this._getLayoutAttrFromConfig(),
42887
+ group = this._getContainer();
42888
+ this._isHorizontal ? this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign(Object.assign({
42889
+ x: position.x + start * width,
42890
+ y: position.y,
42891
+ width: (end - start) * width,
42892
+ height: height,
42893
+ cursor: brushSelect ? "crosshair" : "move"
42894
+ }, selectedBackgroundStyle), {
42895
+ pickable: !zoomLock && (null === (_a = selectedBackgroundChartStyle.pickable) || void 0 === _a || _a)
42896
+ }), "rect") : this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign(Object.assign({
42897
+ x: position.x,
42898
+ y: position.y + start * height,
42899
+ width: width,
42900
+ height: (end - start) * height,
42901
+ cursor: brushSelect ? "crosshair" : "move"
42902
+ }, selectedBackgroundStyle), {
42903
+ pickable: !zoomLock && (null === (_b = selectedBackgroundStyle.pickable) || void 0 === _b || _b)
42904
+ }), "rect");
42905
+ }
42906
+ _setPreviewAttributes(type, group) {
42907
+ this._previewGroup || (this._previewGroup = group.createOrUpdateChild("previewGroup", {
42908
+ pickable: !1
42909
+ }, "group")), "line" === type ? this._previewLine = this._previewGroup.createOrUpdateChild("previewLine", {}, "line") : this._previewArea = this._previewGroup.createOrUpdateChild("previewArea", {
42910
+ curveType: "basis"
42911
+ }, "area");
42912
+ const {
42913
+ backgroundChartStyle = {}
42914
+ } = this.attribute;
42915
+ "line" === type && this._previewLine.setAttributes(Object.assign({
42916
+ points: this._getPreviewLinePoints(),
42917
+ curveType: "basis",
42918
+ pickable: !1
42919
+ }, backgroundChartStyle.line)), "area" === type && this._previewArea.setAttributes(Object.assign({
42920
+ points: this._getPreviewAreaPoints(),
42921
+ curveType: "basis",
42922
+ pickable: !1
42923
+ }, backgroundChartStyle.area));
42924
+ }
42925
+ _setSelectedPreviewClipAttributes(type, group) {
42926
+ this._selectedPreviewGroupClip || (this._selectedPreviewGroupClip = group.createOrUpdateChild("selectedPreviewGroupClip", {
42927
+ pickable: !1
42928
+ }, "group"), this._selectedPreviewGroup = this._selectedPreviewGroupClip.createOrUpdateChild("selectedPreviewGroup", {}, "group"));
42929
+ const {
42930
+ start: start,
42931
+ end: end
42932
+ } = this._getState(),
42933
+ {
42934
+ position: position,
42935
+ width: width,
42936
+ height: height
42937
+ } = this._getLayoutAttrFromConfig();
42938
+ this._selectedPreviewGroupClip.setAttributes({
42939
+ x: this._isHorizontal ? position.x + start * width : position.x,
42940
+ y: this._isHorizontal ? position.y : position.y + start * height,
42941
+ width: this._isHorizontal ? (end - start) * width : width,
42942
+ height: this._isHorizontal ? height : (end - start) * height,
42943
+ clip: !0,
42944
+ pickable: !1
42945
+ }), this._selectedPreviewGroup.setAttributes({
42946
+ x: -(this._isHorizontal ? position.x + start * width : position.x),
42947
+ y: -(this._isHorizontal ? position.y : position.y + start * height),
42948
+ width: this._isHorizontal ? (end - start) * width : width,
42949
+ height: this._isHorizontal ? height : (end - start) * height,
42950
+ pickable: !1
42951
+ });
42952
+ }
42953
+ _setSelectedPreviewAttributes(type) {
42954
+ const {
42955
+ selectedBackgroundChartStyle = {}
42956
+ } = this.attribute;
42957
+ "line" === type ? this._selectedPreviewLine = this._selectedPreviewGroup.createOrUpdateChild("selectedPreviewLine", {}, "line") : this._selectedPreviewArea = this._selectedPreviewGroup.createOrUpdateChild("selectedPreviewArea", {
42958
+ curveType: "basis"
42959
+ }, "area"), "line" === type && this._selectedPreviewLine.setAttributes(Object.assign({
42960
+ points: this._getPreviewLinePoints(),
42961
+ curveType: "basis",
42962
+ pickable: !1
42963
+ }, selectedBackgroundChartStyle.line)), "area" === type && this._selectedPreviewArea.setAttributes(Object.assign({
42964
+ points: this._getPreviewAreaPoints(),
42965
+ curveType: "basis",
42966
+ pickable: !1
42967
+ }, selectedBackgroundChartStyle.area));
42968
+ }
42969
+ _computeBasePoints() {
42885
42970
  const {
42886
42971
  orient: orient
42887
42972
  } = this.attribute,
@@ -42889,7 +42974,7 @@
42889
42974
  position: position,
42890
42975
  width: width,
42891
42976
  height: height
42892
- } = this.getLayoutAttrFromConfig();
42977
+ } = this._getLayoutAttrFromConfig();
42893
42978
  let basePointStart, basePointEnd;
42894
42979
  return this._isHorizontal ? (basePointStart = [{
42895
42980
  x: position.x,
@@ -42914,7 +42999,7 @@
42914
42999
  basePointEnd: basePointEnd
42915
43000
  };
42916
43001
  }
42917
- simplifyPoints(points) {
43002
+ _simplifyPoints(points) {
42918
43003
  var _a;
42919
43004
  if (points.length > 1e4) {
42920
43005
  const tolerance = null !== (_a = this.attribute.tolerance) && void 0 !== _a ? _a : this._previewData.length / 1e4;
@@ -42922,20 +43007,20 @@
42922
43007
  }
42923
43008
  return points;
42924
43009
  }
42925
- getPreviewLinePoints() {
43010
+ _getPreviewLinePoints() {
42926
43011
  let previewPoints = this._previewData.map(d => ({
42927
43012
  x: this._previewPointsX && this._previewPointsX(d),
42928
43013
  y: this._previewPointsY && this._previewPointsY(d)
42929
43014
  }));
42930
43015
  if (0 === previewPoints.length) return previewPoints;
42931
- previewPoints = this.simplifyPoints(previewPoints);
43016
+ previewPoints = this._simplifyPoints(previewPoints);
42932
43017
  const {
42933
43018
  basePointStart: basePointStart,
42934
43019
  basePointEnd: basePointEnd
42935
- } = this.computeBasePoints();
43020
+ } = this._computeBasePoints();
42936
43021
  return basePointStart.concat(previewPoints).concat(basePointEnd);
42937
43022
  }
42938
- getPreviewAreaPoints() {
43023
+ _getPreviewAreaPoints() {
42939
43024
  let previewPoints = this._previewData.map(d => ({
42940
43025
  x: this._previewPointsX && this._previewPointsX(d),
42941
43026
  y: this._previewPointsY && this._previewPointsY(d),
@@ -42943,99 +43028,459 @@
42943
43028
  y1: this._previewPointsY1 && this._previewPointsY1(d)
42944
43029
  }));
42945
43030
  if (0 === previewPoints.length) return previewPoints;
42946
- previewPoints = this.simplifyPoints(previewPoints);
43031
+ previewPoints = this._simplifyPoints(previewPoints);
42947
43032
  const {
42948
43033
  basePointStart: basePointStart,
42949
43034
  basePointEnd: basePointEnd
42950
- } = this.computeBasePoints();
43035
+ } = this._computeBasePoints();
42951
43036
  return basePointStart.concat(previewPoints).concat(basePointEnd);
42952
43037
  }
42953
- setPreviewAttributes(type, group) {
42954
- this._previewGroup || (this._previewGroup = group.createOrUpdateChild("previewGroup", {
42955
- pickable: !1
42956
- }, "group")), "line" === type ? this._previewLine = this._previewGroup.createOrUpdateChild("previewLine", {}, "line") : this._previewArea = this._previewGroup.createOrUpdateChild("previewArea", {
42957
- curveType: "basis"
42958
- }, "area");
42959
- const {
42960
- backgroundChartStyle = {}
42961
- } = this.attribute;
42962
- "line" === type && this._previewLine.setAttributes(Object.assign({
42963
- points: this.getPreviewLinePoints(),
42964
- curveType: "basis",
42965
- pickable: !1
42966
- }, backgroundChartStyle.line)), "area" === type && this._previewArea.setAttributes(Object.assign({
42967
- points: this.getPreviewAreaPoints(),
42968
- curveType: "basis",
42969
- pickable: !1
42970
- }, backgroundChartStyle.area));
43038
+ renderText() {
43039
+ let startTextBounds = null,
43040
+ endTextBounds = null;
43041
+ if (this._setTextAttr(startTextBounds, endTextBounds), this._showText) {
43042
+ startTextBounds = this._startText.AABBBounds, endTextBounds = this._endText.AABBBounds, this._setTextAttr(startTextBounds, endTextBounds), startTextBounds = this._startText.AABBBounds, endTextBounds = this._endText.AABBBounds;
43043
+ const {
43044
+ x1: x1,
43045
+ x2: x2,
43046
+ y1: y1,
43047
+ y2: y2
43048
+ } = startTextBounds,
43049
+ {
43050
+ dx: startTextDx = 0,
43051
+ dy: startTextDy = 0
43052
+ } = this.attribute.startTextStyle;
43053
+ if (new Bounds().set(x1, y1, x2, y2).intersects(endTextBounds)) {
43054
+ const direction = "bottom" === this.attribute.orient || "right" === this.attribute.orient ? -1 : 1;
43055
+ this._isHorizontal ? this._startText.setAttribute("dy", startTextDy + direction * Math.abs(endTextBounds.y1 - endTextBounds.y2)) : this._startText.setAttribute("dx", startTextDx + direction * Math.abs(endTextBounds.x1 - endTextBounds.x2));
43056
+ } else this._isHorizontal ? this._startText.setAttribute("dy", startTextDy) : this._startText.setAttribute("dx", startTextDx);
43057
+ }
42971
43058
  }
42972
- setSelectedPreviewAttributes(type, group) {
42973
- this._selectedPreviewGroupClip || (this._selectedPreviewGroupClip = group.createOrUpdateChild("selectedPreviewGroupClip", {
42974
- pickable: !1
42975
- }, "group"), this._selectedPreviewGroup = this._selectedPreviewGroupClip.createOrUpdateChild("selectedPreviewGroup", {}, "group")), "line" === type ? this._selectedPreviewLine = this._selectedPreviewGroup.createOrUpdateChild("selectedPreviewLine", {}, "line") : this._selectedPreviewArea = this._selectedPreviewGroup.createOrUpdateChild("selectedPreviewArea", {
42976
- curveType: "basis"
42977
- }, "area");
43059
+ _setTextAttr(startTextBounds, endTextBounds) {
43060
+ var _a, _b, _c, _d, _e, _f, _g, _h;
42978
43061
  const {
42979
- selectedBackgroundChartStyle = {}
43062
+ startTextStyle: startTextStyle,
43063
+ endTextStyle: endTextStyle
42980
43064
  } = this.attribute,
43065
+ {
43066
+ formatMethod: startTextFormat
43067
+ } = startTextStyle,
43068
+ restStartTextStyle = __rest$1(startTextStyle, ["formatMethod"]),
43069
+ {
43070
+ formatMethod: endTextFormat
43071
+ } = endTextStyle,
43072
+ restEndTextStyle = __rest$1(endTextStyle, ["formatMethod"]),
42981
43073
  {
42982
43074
  start: start,
42983
43075
  end: end
42984
- } = this.state,
42985
- {
43076
+ } = this._getState();
43077
+ this._startValue = this._statePointToData(start), this._endValue = this._statePointToData(end);
43078
+ const {
42986
43079
  position: position,
42987
43080
  width: width,
42988
43081
  height: height
42989
- } = this.getLayoutAttrFromConfig();
42990
- this._selectedPreviewGroupClip.setAttributes({
42991
- x: this._isHorizontal ? position.x + start * width : position.x,
42992
- y: this._isHorizontal ? position.y : position.y + start * height,
42993
- width: this._isHorizontal ? (end - start) * width : width,
42994
- height: this._isHorizontal ? height : (end - start) * height,
42995
- clip: !0,
42996
- pickable: !1
42997
- }), this._selectedPreviewGroup.setAttributes({
42998
- x: -(this._isHorizontal ? position.x + start * width : position.x),
42999
- y: -(this._isHorizontal ? position.y : position.y + start * height),
43000
- width: this._isHorizontal ? (end - start) * width : width,
43001
- height: this._isHorizontal ? height : (end - start) * height,
43002
- pickable: !1
43003
- }), "line" === type && this._selectedPreviewLine.setAttributes(Object.assign({
43004
- points: this.getPreviewLinePoints(),
43005
- curveType: "basis",
43006
- pickable: !1
43007
- }, selectedBackgroundChartStyle.line)), "area" === type && this._selectedPreviewArea.setAttributes(Object.assign({
43008
- points: this.getPreviewAreaPoints(),
43009
- curveType: "basis",
43010
- pickable: !1
43011
- }, selectedBackgroundChartStyle.area));
43082
+ } = this._getLayoutAttrFromConfig(),
43083
+ startTextValue = startTextFormat ? startTextFormat(this._startValue) : this._startValue,
43084
+ endTextValue = endTextFormat ? endTextFormat(this._endValue) : this._endValue,
43085
+ componentBoundsLike = {
43086
+ x1: position.x,
43087
+ y1: position.y,
43088
+ x2: position.x + width,
43089
+ y2: position.y + height
43090
+ };
43091
+ let startTextPosition, endTextPosition, startTextAlignStyle, endTextAlignStyle;
43092
+ this._isHorizontal ? (startTextPosition = {
43093
+ x: position.x + start * width,
43094
+ y: position.y + height / 2
43095
+ }, endTextPosition = {
43096
+ x: position.x + end * width,
43097
+ y: position.y + height / 2
43098
+ }, startTextAlignStyle = {
43099
+ textAlign: isTextOverflow(componentBoundsLike, startTextBounds, "start", this._isHorizontal) ? "left" : "right",
43100
+ textBaseline: null !== (_b = null === (_a = null == restStartTextStyle ? void 0 : restStartTextStyle.textStyle) || void 0 === _a ? void 0 : _a.textBaseline) && void 0 !== _b ? _b : "middle"
43101
+ }, endTextAlignStyle = {
43102
+ textAlign: isTextOverflow(componentBoundsLike, endTextBounds, "end", this._isHorizontal) ? "right" : "left",
43103
+ textBaseline: null !== (_d = null === (_c = null == restEndTextStyle ? void 0 : restEndTextStyle.textStyle) || void 0 === _c ? void 0 : _c.textBaseline) && void 0 !== _d ? _d : "middle"
43104
+ }) : (startTextPosition = {
43105
+ x: position.x + width / 2,
43106
+ y: position.y + start * height
43107
+ }, endTextPosition = {
43108
+ x: position.x + width / 2,
43109
+ y: position.y + end * height
43110
+ }, startTextAlignStyle = {
43111
+ textAlign: null !== (_f = null === (_e = null == restStartTextStyle ? void 0 : restStartTextStyle.textStyle) || void 0 === _e ? void 0 : _e.textAlign) && void 0 !== _f ? _f : "center",
43112
+ textBaseline: isTextOverflow(componentBoundsLike, startTextBounds, "start", this._isHorizontal) ? "top" : "bottom"
43113
+ }, endTextAlignStyle = {
43114
+ textAlign: null !== (_h = null === (_g = null == restEndTextStyle ? void 0 : restEndTextStyle.textStyle) || void 0 === _g ? void 0 : _g.textAlign) && void 0 !== _h ? _h : "center",
43115
+ textBaseline: isTextOverflow(componentBoundsLike, endTextBounds, "end", this._isHorizontal) ? "bottom" : "top"
43116
+ }), this._startText = this._maybeAddLabel(this._getContainer(), merge$1({}, restStartTextStyle, {
43117
+ text: startTextValue,
43118
+ x: startTextPosition.x,
43119
+ y: startTextPosition.y,
43120
+ visible: this._showText,
43121
+ pickable: !1,
43122
+ childrenPickable: !1,
43123
+ textStyle: startTextAlignStyle
43124
+ }), "data-zoom-start-text"), this._endText = this._maybeAddLabel(this._getContainer(), merge$1({}, restEndTextStyle, {
43125
+ text: endTextValue,
43126
+ x: endTextPosition.x,
43127
+ y: endTextPosition.y,
43128
+ visible: this._showText,
43129
+ pickable: !1,
43130
+ childrenPickable: !1,
43131
+ textStyle: endTextAlignStyle
43132
+ }), "data-zoom-end-text");
43012
43133
  }
43013
- maybeAddLabel(container, attributes, name) {
43014
- let labelShape = this.find(node => node.name === name, !0);
43015
- return labelShape ? labelShape.setAttributes(attributes) : (labelShape = new Tag(attributes), labelShape.name = name), container.add(labelShape), labelShape;
43134
+ _maybeAddLabel(container, attributes, name) {
43135
+ let labelShape = container.find(node => node.name === name, !0);
43136
+ return labelShape ? labelShape.setAttributes(attributes) : (labelShape = new Tag(attributes), labelShape.name = name, container.add(labelShape)), labelShape;
43016
43137
  }
43017
- setStartAndEnd(start, end) {
43138
+ }
43139
+
43140
+ const delayMap$2 = {
43141
+ debounce: debounce,
43142
+ throttle: throttle
43143
+ };
43144
+ class DataZoomInteraction extends EventEmitter {
43145
+ constructor(props) {
43146
+ super(), this._activeState = !1, this._activeCache = {
43147
+ startPos: {
43148
+ x: 0,
43149
+ y: 0
43150
+ },
43151
+ lastPos: {
43152
+ x: 0,
43153
+ y: 0
43154
+ }
43155
+ }, this._layoutCache = {
43156
+ attPos: "x",
43157
+ attSize: "width",
43158
+ size: 0
43159
+ }, this._handleTouchMove = e => {
43160
+ this._activeState && e.preventDefault();
43161
+ }, this._onHandlerPointerDown = (e, tag) => {
43162
+ this.clearDragEvents(), "start" === tag ? (this._activeTag = DataZoomActiveTag.startHandler, this._activeItem = this._startHandlerMask) : "end" === tag ? (this._activeTag = DataZoomActiveTag.endHandler, this._activeItem = this._endHandlerMask) : "middleRect" === tag ? (this._activeTag = DataZoomActiveTag.middleHandler, this._activeItem = this._middleHandlerRect) : "middleSymbol" === tag ? (this._activeTag = DataZoomActiveTag.middleHandler, this._activeItem = this._middleHandlerSymbol) : "background" === tag && (this._activeTag = DataZoomActiveTag.background, this._activeItem = this._background), this._activeState = !0, this._activeCache.startPos = this._eventPosToStagePos(e), this._activeCache.lastPos = this._eventPosToStagePos(e);
43163
+ const evtTarget = "browser" === vglobal.env ? vglobal : this.stage,
43164
+ triggers = getEndTriggersOfDrag();
43165
+ evtTarget.addEventListener("pointermove", this._onHandlerPointerMove, {
43166
+ capture: !0
43167
+ }), this.on("pointermove", this._onHandlerPointerMove, {
43168
+ capture: !0
43169
+ }), triggers.forEach(trigger => {
43170
+ evtTarget.addEventListener(trigger, this._onHandlerPointerUp);
43171
+ });
43172
+ }, this._pointerMove = e => {
43173
+ const {
43174
+ brushSelect: brushSelect
43175
+ } = this.attribute,
43176
+ {
43177
+ position: position
43178
+ } = this._getLayoutAttrFromConfig(),
43179
+ pos = this._eventPosToStagePos(e),
43180
+ {
43181
+ attPos: attPos,
43182
+ size: size,
43183
+ attSize: attSize
43184
+ } = this._layoutCache,
43185
+ dis = (pos[attPos] - this._activeCache.lastPos[attPos]) / size,
43186
+ statePos = (pos[attPos] - position[attPos]) / this._getLayoutAttrFromConfig()[attSize];
43187
+ let {
43188
+ start: start,
43189
+ end: end
43190
+ } = this._getState(),
43191
+ shouldRender = !0;
43192
+ this._activeState && (this._activeTag === DataZoomActiveTag.middleHandler ? ({
43193
+ start: start,
43194
+ end: end
43195
+ } = this._moveZoomWithMiddle(dis)) : this._activeTag === DataZoomActiveTag.startHandler ? ({
43196
+ start: start,
43197
+ end: end
43198
+ } = this._moveZoomWithHandler(statePos, "start")) : this._activeTag === DataZoomActiveTag.endHandler ? ({
43199
+ start: start,
43200
+ end: end
43201
+ } = this._moveZoomWithHandler(statePos, "end")) : this._activeTag === DataZoomActiveTag.background && brushSelect && (({
43202
+ start: start,
43203
+ end: end
43204
+ } = this._moveZoomWithBackground(statePos)), shouldRender = !1, this._dispatchEvent(IDataZoomInteractiveEvent.maskUpdate)), this._activeCache.lastPos = pos), this._getState().start === start && this._getState().end === end || (this._setStateAttr(start, end), this._dispatchEvent(IDataZoomInteractiveEvent.stateUpdate, {
43205
+ start: this._getState().start,
43206
+ end: this._getState().end,
43207
+ shouldRender: shouldRender,
43208
+ tag: this._activeTag
43209
+ }), this.attribute.realTime && this._dispatchEvent(IDataZoomInteractiveEvent.dataZoomUpdate, {
43210
+ start: this._getState().start,
43211
+ end: this._getState().end,
43212
+ shouldRender: !0,
43213
+ tag: this._activeTag
43214
+ }));
43215
+ }, this._onHandlerPointerUp = e => {
43216
+ this._activeState && this._activeTag === DataZoomActiveTag.background && (this._setStateAttr(this._getState().start, this._getState().end), this._dispatchEvent(IDataZoomInteractiveEvent.stateUpdate, {
43217
+ start: this._getState().start,
43218
+ end: this._getState().end,
43219
+ shouldRender: !0,
43220
+ tag: this._activeTag
43221
+ })), this._activeState = !1, this._dispatchEvent(IDataZoomInteractiveEvent.dataZoomUpdate, {
43222
+ start: this._getState().start,
43223
+ end: this._getState().end,
43224
+ shouldRender: !0,
43225
+ tag: this._activeTag
43226
+ }), this.clearDragEvents();
43227
+ }, this._initAttrs(props);
43228
+ }
43229
+ setAttributes(props) {
43230
+ var _a, _b, _c, _d, _e, _f;
43231
+ this._initAttrs(props), this._onHandlerPointerMove = 0 === (null !== (_b = null === (_a = this.attribute) || void 0 === _a ? void 0 : _a.delayTime) && void 0 !== _b ? _b : 0) ? this._pointerMove : delayMap$2[null !== (_d = null === (_c = this.attribute) || void 0 === _c ? void 0 : _c.delayType) && void 0 !== _d ? _d : "debounce"](this._pointerMove, null !== (_f = null === (_e = this.attribute) || void 0 === _e ? void 0 : _e.delayTime) && void 0 !== _f ? _f : 0);
43232
+ }
43233
+ _initAttrs(props) {
43234
+ this.stage = props.stage, this.attribute = props.attribute, this._startHandlerMask = props.startHandlerMask, this._endHandlerMask = props.endHandlerMask, this._middleHandlerSymbol = props.middleHandlerSymbol, this._middleHandlerRect = props.middleHandlerRect, this._selectedBackground = props.selectedBackground, this._background = props.background, this._previewGroup = props.previewGroup, this._selectedPreviewGroup = props.selectedPreviewGroup, this._getLayoutAttrFromConfig = props.getLayoutAttrFromConfig, this._getState = props.getState, this._setState = props.setState;
43018
43235
  const {
43019
- start: startAttr,
43020
- end: endAttr
43236
+ width: width,
43237
+ height: height
43238
+ } = this._getLayoutAttrFromConfig();
43239
+ this._spanCache = this._getState().end - this._getState().start;
43240
+ const isHorizontal = "top" === this.attribute.orient || "bottom" === this.attribute.orient;
43241
+ this._layoutCache.size = isHorizontal ? width : height, this._layoutCache.attPos = isHorizontal ? "x" : "y", this._layoutCache.attSize = isHorizontal ? "width" : "height", this._getGlobalTransMatrix = props.getGlobalTransMatrix;
43242
+ }
43243
+ clearDragEvents() {
43244
+ const evtTarget = "browser" === vglobal.env ? vglobal : this.stage,
43245
+ triggers = getEndTriggersOfDrag();
43246
+ evtTarget.removeEventListener("pointermove", this._onHandlerPointerMove, {
43247
+ capture: !0
43248
+ }), triggers.forEach(trigger => {
43249
+ evtTarget.removeEventListener(trigger, this._onHandlerPointerUp);
43250
+ }), this.off("pointermove", this._onHandlerPointerMove, {
43251
+ capture: !0
43252
+ });
43253
+ }
43254
+ clearVGlobalEvents() {
43255
+ ("browser" === vglobal.env ? vglobal : this.stage).addEventListener("touchmove", this._handleTouchMove, {
43256
+ passive: !1
43257
+ });
43258
+ }
43259
+ bindEvents() {
43260
+ var _a, _b, _c, _d, _e, _f, _g, _h;
43261
+ const {
43262
+ brushSelect: brushSelect
43021
43263
  } = this.attribute;
43022
- isValid$1(start) && isValid$1(end) && (start !== this.state.start || end !== this.state.end) && (this.state.start = start, this.state.end = end, startAttr === this.state.start && endAttr === this.state.end || (this.setStateAttr(start, end, !0), this._dispatchEvent("change", {
43264
+ null === (_a = this._startHandlerMask) || void 0 === _a || _a.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, "start")), null === (_b = this._endHandlerMask) || void 0 === _b || _b.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, "end")), null === (_c = this._middleHandlerSymbol) || void 0 === _c || _c.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, "middleSymbol")), null === (_d = this._middleHandlerRect) || void 0 === _d || _d.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, "middleRect"));
43265
+ const selectedTag = brushSelect ? "background" : "middleRect";
43266
+ null === (_e = this._selectedBackground) || void 0 === _e || _e.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, selectedTag)), brushSelect && (null === (_f = this._background) || void 0 === _f || _f.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, "background"))), brushSelect && (null === (_g = this._previewGroup) || void 0 === _g || _g.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, "background"))), null === (_h = this._selectedPreviewGroup) || void 0 === _h || _h.addEventListener("pointerdown", e => this._onHandlerPointerDown(e, selectedTag)), ("browser" === vglobal.env ? vglobal : this.stage).addEventListener("touchmove", this._handleTouchMove, {
43267
+ passive: !1
43268
+ });
43269
+ }
43270
+ _setStateAttr(start, end) {
43271
+ const {
43272
+ zoomLock = !1,
43273
+ minSpan = 0,
43274
+ maxSpan = 1
43275
+ } = this.attribute,
43276
+ span = end - start;
43277
+ span !== this._spanCache && (zoomLock || span < minSpan || span > maxSpan) || (this._spanCache = span, this._setState({
43278
+ start: start,
43279
+ end: end
43280
+ }));
43281
+ }
43282
+ _moveZoomWithMiddle(dis) {
43283
+ const {
43284
+ start: staetState,
43285
+ end: endState
43286
+ } = this._getState();
43287
+ return dis > 0 && endState + dis > 1 ? dis = 1 - endState : dis < 0 && staetState + dis < 0 && (dis = -staetState), {
43288
+ start: clamp$1(staetState + dis, 0, 1),
43289
+ end: clamp$1(endState + dis, 0, 1)
43290
+ };
43291
+ }
43292
+ _moveZoomWithHandler(statePos, handler) {
43293
+ const {
43294
+ start: start,
43295
+ end: end
43296
+ } = this._getState();
43297
+ let newStart = start,
43298
+ newEnd = end;
43299
+ return "start" === handler ? statePos > end ? (newStart = end, newEnd = statePos, this._activeTag = DataZoomActiveTag.endHandler) : newStart = statePos : "end" === handler && (statePos < start ? (newEnd = start, newStart = statePos, this._activeTag = DataZoomActiveTag.startHandler) : newEnd = statePos), {
43300
+ start: clamp$1(newStart, 0, 1),
43301
+ end: clamp$1(newEnd, 0, 1)
43302
+ };
43303
+ }
43304
+ _moveZoomWithBackground(statePos) {
43305
+ const {
43306
+ position: position
43307
+ } = this._getLayoutAttrFromConfig(),
43308
+ {
43309
+ attSize: attSize
43310
+ } = this._layoutCache,
43311
+ startPos = (this._activeCache.startPos[this._layoutCache.attPos] - position[this._layoutCache.attPos]) / this._getLayoutAttrFromConfig()[attSize],
43312
+ endPos = statePos;
43313
+ let start = clamp$1(startPos, 0, 1),
43314
+ end = clamp$1(endPos, 0, 1);
43315
+ return start > end && ([start, end] = [end, start]), {
43316
+ start: start,
43317
+ end: end
43318
+ };
43319
+ }
43320
+ _eventPosToStagePos(e) {
43321
+ var _a, _b;
43322
+ const result = {
43323
+ x: 0,
43324
+ y: 0
43325
+ },
43326
+ stagePoints = null !== (_b = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.eventPointTransform(e)) && void 0 !== _b ? _b : {
43327
+ x: 0,
43328
+ y: 0
43329
+ };
43330
+ return this._getGlobalTransMatrix().transformPoint(stagePoints, result), result;
43331
+ }
43332
+ _dispatchEvent(eventName, details) {
43333
+ this.emit(eventName, details);
43334
+ }
43335
+ }
43336
+
43337
+ function loadDataZoomComponent() {
43338
+ loadTagComponent(), registerRect(), registerSymbol(), registerArea(), registerLine();
43339
+ }
43340
+
43341
+ loadDataZoomComponent();
43342
+ let DataZoom$1 = class DataZoom extends AbstractComponent {
43343
+ constructor(attributes, options) {
43344
+ super((null == options ? void 0 : options.skipDefault) ? attributes : merge$1({}, DataZoom.defaultAttributes, attributes)), this.name = "dataZoom", this._state = {
43345
+ start: 0,
43346
+ end: 1
43347
+ }, this.getLayoutAttrFromConfig = () => {
43348
+ var _a, _b, _c, _d, _e, _f;
43349
+ if (this._layoutCacheFromConfig) return this._layoutCacheFromConfig;
43350
+ const {
43351
+ position: positionConfig,
43352
+ size: size,
43353
+ orient: orient,
43354
+ middleHandlerStyle = {},
43355
+ startHandlerStyle = {},
43356
+ endHandlerStyle = {},
43357
+ backgroundStyle = {}
43358
+ } = this.attribute,
43359
+ {
43360
+ width: widthConfig,
43361
+ height: heightConfig
43362
+ } = size,
43363
+ middleHandlerSize = null !== (_b = null === (_a = middleHandlerStyle.background) || void 0 === _a ? void 0 : _a.size) && void 0 !== _b ? _b : 10;
43364
+ let width, height, position;
43365
+ middleHandlerStyle.visible ? this._isHorizontal ? (width = widthConfig, height = heightConfig - middleHandlerSize, position = {
43366
+ x: positionConfig.x,
43367
+ y: positionConfig.y + middleHandlerSize
43368
+ }) : (width = widthConfig - middleHandlerSize, height = heightConfig, position = {
43369
+ x: positionConfig.x + ("left" === orient ? middleHandlerSize : 0),
43370
+ y: positionConfig.y
43371
+ }) : (width = widthConfig, height = heightConfig, position = positionConfig);
43372
+ const startHandlerSize = null !== (_c = startHandlerStyle.size) && void 0 !== _c ? _c : this._isHorizontal ? height : width,
43373
+ endHandlerSize = null !== (_d = endHandlerStyle.size) && void 0 !== _d ? _d : this._isHorizontal ? height : width;
43374
+ return startHandlerStyle.visible && (this._isHorizontal ? (width -= (startHandlerSize + endHandlerSize) / 2, position = {
43375
+ x: position.x + startHandlerSize / 2,
43376
+ y: position.y
43377
+ }) : (height -= (startHandlerSize + endHandlerSize) / 2, position = {
43378
+ x: position.x,
43379
+ y: position.y + startHandlerSize / 2
43380
+ })), height += (null !== (_e = backgroundStyle.lineWidth) && void 0 !== _e ? _e : 2) / 2, width += (null !== (_f = backgroundStyle.lineWidth) && void 0 !== _f ? _f : 2) / 2, this._layoutCacheFromConfig = {
43381
+ position: position,
43382
+ width: width,
43383
+ height: height
43384
+ }, this._layoutCacheFromConfig;
43385
+ };
43386
+ const {
43387
+ start: start,
43388
+ end: end,
43389
+ orient: orient
43390
+ } = this.attribute;
43391
+ this._isHorizontal = "top" === orient || "bottom" === orient, start && (this._state.start = start), end && (this._state.end = end), this._renderer = new DataZoomRenderer(this._getRendererAttrs()), this._interaction = new DataZoomInteraction(this._getInteractionAttrs());
43392
+ }
43393
+ _getRendererAttrs() {
43394
+ return {
43395
+ attribute: this.attribute,
43396
+ getLayoutAttrFromConfig: this.getLayoutAttrFromConfig,
43397
+ setState: state => {
43398
+ this._state = state;
43399
+ },
43400
+ getState: () => this._state,
43401
+ getContainer: () => this._container
43402
+ };
43403
+ }
43404
+ _getInteractionAttrs() {
43405
+ return {
43406
+ stage: this.stage,
43407
+ attribute: this.attribute,
43408
+ startHandlerMask: this._renderer.startHandlerMask,
43409
+ endHandlerMask: this._renderer.endHandlerMask,
43410
+ middleHandlerSymbol: this._renderer.middleHandlerSymbol,
43411
+ middleHandlerRect: this._renderer.middleHandlerRect,
43412
+ selectedBackground: this._renderer.selectedBackground,
43413
+ background: this._renderer.background,
43414
+ previewGroup: this._renderer.previewGroup,
43415
+ selectedPreviewGroup: this._renderer.selectedPreviewGroup,
43416
+ getLayoutAttrFromConfig: this.getLayoutAttrFromConfig,
43417
+ setState: state => {
43418
+ this._state = state;
43419
+ },
43420
+ getState: () => this._state,
43421
+ getGlobalTransMatrix: () => this.globalTransMatrix
43422
+ };
43423
+ }
43424
+ bindEvents() {
43425
+ this.attribute.disableTriggerEvent ? this.setAttribute("childrenPickable", !1) : (this._interaction.bindEvents(), this._interaction.on(IDataZoomInteractiveEvent.stateUpdate, ({
43426
+ shouldRender: shouldRender
43427
+ }) => {
43428
+ shouldRender && this._renderer.renderDataZoom(!0);
43429
+ }), this._interaction.on(IDataZoomInteractiveEvent.dataZoomUpdate, ({
43023
43430
  start: start,
43024
43431
  end: end,
43025
- tag: this._activeTag
43432
+ tag: tag
43433
+ }) => {
43434
+ this._dispatchEvent(IDataZoomEvent.dataZoomChange, {
43435
+ start: start,
43436
+ end: end,
43437
+ tag: tag
43438
+ });
43439
+ }), this._interaction.on(IDataZoomInteractiveEvent.maskUpdate, () => {
43440
+ this._renderer.renderDragMask();
43441
+ }), "auto" === this.attribute.showDetail && (this._container.addEventListener("pointerenter", () => {
43442
+ this._renderer.showText = !0, this._renderer.renderText();
43443
+ }), this._container.addEventListener("pointerleave", () => {
43444
+ this._renderer.showText = !1, this._renderer.renderText();
43026
43445
  })));
43027
43446
  }
43447
+ setAttributes(params, forceUpdateTag) {
43448
+ const {
43449
+ start: start,
43450
+ end: end
43451
+ } = this.attribute;
43452
+ start && (this._state.start = start), end && (this._state.end = end), this._renderer.setAttributes(this._getRendererAttrs()), this._interaction.setAttributes(this._getInteractionAttrs()), super.setAttributes(params, forceUpdateTag);
43453
+ }
43454
+ render() {
43455
+ this._layoutCacheFromConfig = null, this._container = this.createOrUpdateChild("datazoom-container", {}, "group"), this._renderer.renderDataZoom(), this._interaction.setAttributes(this._getInteractionAttrs());
43456
+ }
43457
+ release(all) {
43458
+ super.release(all), this._interaction.clearDragEvents();
43459
+ }
43460
+ setStartAndEnd(start, end) {
43461
+ const {
43462
+ start: startState,
43463
+ end: endState
43464
+ } = this._state;
43465
+ isValid$1(start) && isValid$1(end) && (start !== startState || end !== endState) && (this._state = {
43466
+ start: start,
43467
+ end: end
43468
+ }, this._renderer.renderDataZoom(!0), this._dispatchEvent(IDataZoomEvent.dataZoomChange, {
43469
+ start: start,
43470
+ end: end
43471
+ }));
43472
+ }
43028
43473
  setPreviewData(data) {
43029
- this._previewData = data;
43474
+ this._renderer.previewData = data;
43030
43475
  }
43031
43476
  setText(text, tag) {
43032
- "start" === tag ? this._startText.setAttribute("text", text) : this._endText.setAttribute("text", text);
43477
+ "start" === tag ? this._renderer.startText.setAttribute("text", text) : this._renderer.endText.setAttribute("text", text);
43033
43478
  }
43034
43479
  getStartValue() {
43035
- return this._startValue;
43480
+ return this._renderer.startValue;
43036
43481
  }
43037
43482
  getEndTextValue() {
43038
- return this._endValue;
43483
+ return this._renderer.endValue;
43039
43484
  }
43040
43485
  getMiddleHandlerSize() {
43041
43486
  var _a, _b, _c, _d;
@@ -43047,24 +43492,19 @@
43047
43492
  return Math.max(middleHandlerRectSize, ...array(middleHandlerSymbolSize));
43048
43493
  }
43049
43494
  setPreviewPointsX(callback) {
43050
- isFunction$1(callback) && (this._previewPointsX = callback);
43495
+ isFunction$1(callback) && (this._renderer.previewPointsX = callback);
43051
43496
  }
43052
43497
  setPreviewPointsY(callback) {
43053
- isFunction$1(callback) && (this._previewPointsY = callback);
43498
+ isFunction$1(callback) && (this._renderer.previewPointsY = callback);
43054
43499
  }
43055
43500
  setPreviewPointsX1(callback) {
43056
- isFunction$1(callback) && (this._previewPointsX1 = callback);
43501
+ isFunction$1(callback) && (this._renderer.previewPointsX1 = callback);
43057
43502
  }
43058
43503
  setPreviewPointsY1(callback) {
43059
- isFunction$1(callback) && (this._previewPointsY1 = callback);
43504
+ isFunction$1(callback) && (this._renderer.previewPointsY1 = callback);
43060
43505
  }
43061
43506
  setStatePointToData(callback) {
43062
- isFunction$1(callback) && (this._statePointToData = callback);
43063
- }
43064
- release(all) {
43065
- super.release(all), ("browser" === vglobal.env ? vglobal : this.stage).addEventListener("touchmove", this._handleTouchMove, {
43066
- passive: !1
43067
- }), this._clearDragEvents();
43507
+ isFunction$1(callback) && (this._renderer.statePointToData = callback);
43068
43508
  }
43069
43509
  };
43070
43510
  DataZoom$1.defaultAttributes = DEFAULT_DATA_ZOOM_ATTRIBUTES;
@@ -58331,7 +58771,7 @@
58331
58771
  });
58332
58772
  };
58333
58773
 
58334
- const version = "2.0.7-alpha.1";
58774
+ const version = "2.0.7-alpha.4";
58335
58775
 
58336
58776
  const addVChartProperty = (data, op) => {
58337
58777
  const context = op.beforeCall();
@@ -72259,7 +72699,9 @@
72259
72699
  this._reStackTotal = () => {
72260
72700
  const stackData = this.getStackData();
72261
72701
  const stackValueField = this.getStackValueField();
72262
- stackTotal(stackData, stackValueField);
72702
+ if (stackData) {
72703
+ stackTotal(stackData, stackValueField);
72704
+ }
72263
72705
  };
72264
72706
  }
72265
72707
  getTotalData() {
@@ -78405,6 +78847,72 @@
78405
78847
  isNil$1(node.value) && ((null === (_a = node.children) || void 0 === _a ? void 0 : _a.length) ? node.value = calculateNodeValue(node.children) : node.value = 0), sum += Math.abs(node.value);
78406
78848
  }), sum;
78407
78849
  };
78850
+ function makeHierarchicNodes(originalNodes, nodeKeyFunc, nodes = [], nodeMap = {}, originalLinks) {
78851
+ calculateNodeValue(originalNodes);
78852
+ const doSubTree = (subTree, depth, parents) => {
78853
+ subTree.forEach((node, index) => {
78854
+ const nodeKey = nodeKeyFunc ? nodeKeyFunc(node) : parents ? `${parents[parents.length - 1].key}-${index}` : `${depth}-${index}`,
78855
+ nodeValue = isNil$1(node.value) ? 0 : toValidNumber$1(node.value);
78856
+ if (nodeMap[nodeKey]) nodeMap[nodeKey].value = void 0;else {
78857
+ const nodeElement = {
78858
+ depth: depth,
78859
+ datum: node,
78860
+ index: index,
78861
+ key: nodeKey,
78862
+ value: nodeValue,
78863
+ sourceLinks: [],
78864
+ targetLinks: []
78865
+ };
78866
+ nodeMap[nodeKey] = nodeElement, nodes.push(nodeElement);
78867
+ }
78868
+ parents && originalLinks && originalLinks.push({
78869
+ source: parents[parents.length - 1].key,
78870
+ target: nodeKey,
78871
+ value: nodeValue,
78872
+ parents: parents
78873
+ }), node.children && node.children.length && doSubTree(node.children, depth + 1, parents ? parents.concat([nodeMap[nodeKey]]) : [nodeMap[nodeKey]]);
78874
+ });
78875
+ };
78876
+ return doSubTree(originalNodes, 0, null), nodes;
78877
+ }
78878
+ function computeHierarchicNodeLinks(originalNodes, nodeKeyFunc) {
78879
+ const nodes = [],
78880
+ links = [],
78881
+ nodeMap = {},
78882
+ linkMap = {},
78883
+ originalLinks = [];
78884
+ return makeHierarchicNodes(originalNodes, nodeKeyFunc, nodes, nodeMap, originalLinks), originalLinks.forEach((link, index) => {
78885
+ const key = `${link.source}-${link.target}`,
78886
+ linkDatum = pickWithout(link, ["parents"]);
78887
+ if (linkDatum.parents = link.parents.map(node => pickWithout(node, ["sourceLinks", "targetLinks"])), linkMap[key]) return linkMap[key].value += toValidNumber$1(link.value), void linkMap[key].datum.push(linkDatum);
78888
+ const linkElement = {
78889
+ index: index,
78890
+ key: `${link.source}-${link.target}`,
78891
+ source: link.source,
78892
+ target: link.target,
78893
+ datum: [linkDatum],
78894
+ value: link.value,
78895
+ parents: link.parents.map(parent => parent.key)
78896
+ };
78897
+ links.push(linkElement), nodeMap[link.source].sourceLinks.push(linkElement), nodeMap[link.target].targetLinks.push(linkElement), linkMap[key] = linkElement;
78898
+ }), {
78899
+ nodes: nodes,
78900
+ links: links,
78901
+ nodeMap: nodeMap
78902
+ };
78903
+ }
78904
+ function computeNodeValues(nodes) {
78905
+ for (let i = 0, len = nodes.length; i < len; i++) {
78906
+ const node = nodes[i];
78907
+ node.value = Math.max(isNil$1(node.value) ? 0 : toValidNumber$1(node.value), node.sourceLinks.reduce((sum, link) => {
78908
+ var _a;
78909
+ return sum + (null !== (_a = toValidNumber$1(link.value)) && void 0 !== _a ? _a : 0);
78910
+ }, 0), node.targetLinks.reduce((sum, link) => {
78911
+ var _a;
78912
+ return sum + (null !== (_a = toValidNumber$1(link.value)) && void 0 !== _a ? _a : 0);
78913
+ }, 0));
78914
+ }
78915
+ }
78408
78916
 
78409
78917
  function left(node) {
78410
78918
  return node.depth;
@@ -78538,55 +79046,7 @@
78538
79046
  };
78539
79047
  }
78540
79048
  computeHierarchicNodeLinks(originalNodes) {
78541
- const nodes = [],
78542
- links = [],
78543
- nodeMap = {},
78544
- linkMap = {},
78545
- originalLinks = [];
78546
- calculateNodeValue(originalNodes);
78547
- const doSubTree = (subTree, depth, parents) => {
78548
- subTree.forEach((node, index) => {
78549
- const nodeKey = this._getNodeKey ? this._getNodeKey(node) : parents ? `${parents[parents.length - 1].key}-${index}` : `${depth}-${index}`,
78550
- nodeValue = isNil$1(node.value) ? 0 : toValidNumber$1(node.value);
78551
- if (nodeMap[nodeKey]) nodeMap[nodeKey].value = void 0;else {
78552
- const nodeElement = {
78553
- depth: depth,
78554
- datum: node,
78555
- index: index,
78556
- key: nodeKey,
78557
- value: nodeValue,
78558
- sourceLinks: [],
78559
- targetLinks: []
78560
- };
78561
- nodeMap[nodeKey] = nodeElement, nodes.push(nodeElement);
78562
- }
78563
- parents && originalLinks.push({
78564
- source: parents[parents.length - 1].key,
78565
- target: nodeKey,
78566
- value: nodeValue,
78567
- parents: parents
78568
- }), node.children && node.children.length && doSubTree(node.children, depth + 1, parents ? parents.concat([nodeMap[nodeKey]]) : [nodeMap[nodeKey]]);
78569
- });
78570
- };
78571
- return doSubTree(originalNodes, 0, null), originalLinks.forEach((link, index) => {
78572
- const key = `${link.source}-${link.target}`,
78573
- linkDatum = pickWithout(link, ["parents"]);
78574
- if (linkDatum.parents = link.parents.map(node => pickWithout(node, ["sourceLinks", "targetLinks"])), linkMap[key]) return linkMap[key].value += toValidNumber$1(link.value), void linkMap[key].datum.push(linkDatum);
78575
- const linkElement = {
78576
- index: index,
78577
- key: `${link.source}-${link.target}`,
78578
- source: link.source,
78579
- target: link.target,
78580
- datum: [linkDatum],
78581
- value: link.value,
78582
- parents: link.parents.map(parent => parent.key)
78583
- };
78584
- links.push(linkElement), nodeMap[link.source].sourceLinks.push(linkElement), nodeMap[link.target].targetLinks.push(linkElement), linkMap[key] = linkElement;
78585
- }), {
78586
- nodes: nodes,
78587
- links: links,
78588
- nodeMap: nodeMap
78589
- };
79049
+ return computeHierarchicNodeLinks(originalNodes, this._getNodeKey);
78590
79050
  }
78591
79051
  computeSourceTargetNodeLinks(data) {
78592
79052
  const nodes = [],
@@ -78656,16 +79116,7 @@
78656
79116
  };
78657
79117
  }
78658
79118
  computeNodeValues(nodes) {
78659
- for (let i = 0, len = nodes.length; i < len; i++) {
78660
- const node = nodes[i];
78661
- node.value = Math.max(isNil$1(node.value) ? 0 : toValidNumber$1(node.value), node.sourceLinks.reduce((sum, link) => {
78662
- var _a;
78663
- return sum + (null !== (_a = toValidNumber$1(link.value)) && void 0 !== _a ? _a : 0);
78664
- }, 0), node.targetLinks.reduce((sum, link) => {
78665
- var _a;
78666
- return sum + (null !== (_a = toValidNumber$1(link.value)) && void 0 !== _a ? _a : 0);
78667
- }, 0));
78668
- }
79119
+ return computeNodeValues(nodes);
78669
79120
  }
78670
79121
  computeNodeDepths(nodes) {
78671
79122
  var _a;
@@ -79730,7 +80181,7 @@
79730
80181
  return ret;
79731
80182
  }
79732
80183
 
79733
- function scaleSolution(solution, width, height, x0, y0) {
80184
+ function scaleSolution(solution, width, height, x0, y0, hasEmptySet = !1) {
79734
80185
  width = Math.max(width, 1), height = Math.max(height, 1);
79735
80186
  const circles = [],
79736
80187
  setIds = [];
@@ -79740,9 +80191,20 @@
79740
80191
  yRange = bounds.yRange;
79741
80192
  if (xRange.max === xRange.min || yRange.max === yRange.min) return console.log("not scaling solution: zero size detected"), solution;
79742
80193
  const xScaling = width / (xRange.max - xRange.min),
79743
- yScaling = height / (yRange.max - yRange.min),
79744
- scaling = Math.min(yScaling, xScaling),
79745
- xOffset = (width - (xRange.max - xRange.min) * scaling) / 2,
80194
+ yScaling = height / (yRange.max - yRange.min);
80195
+ let scaling;
80196
+ if (hasEmptySet) {
80197
+ const containerRadius = Math.min(width, height) / 2,
80198
+ centerX = (xRange.min + xRange.max) / 2,
80199
+ centerY = (yRange.min + yRange.max) / 2;
80200
+ let diagramRadius = 0;
80201
+ for (const circle of circles) {
80202
+ const maxDistanceForThisCircle = Math.sqrt(Math.pow(circle.x - centerX, 2) + Math.pow(circle.y - centerY, 2)) + circle.radius;
80203
+ diagramRadius = Math.max(diagramRadius, maxDistanceForThisCircle);
80204
+ }
80205
+ scaling = containerRadius / diagramRadius;
80206
+ } else scaling = Math.min(yScaling, xScaling);
80207
+ const xOffset = (width - (xRange.max - xRange.min) * scaling) / 2,
79746
80208
  yOffset = (height - (yRange.max - yRange.min) * scaling) / 2,
79747
80209
  scaled = {};
79748
80210
  for (let i = 0; i < circles.length; ++i) {
@@ -79957,21 +80419,39 @@
79957
80419
  setField = "sets",
79958
80420
  valueField = "size",
79959
80421
  orientation = Math.PI / 2,
79960
- orientationOrder = null
80422
+ orientationOrder = null,
80423
+ emptySetKey: emptySetKey
79961
80424
  } = options;
79962
80425
  let circles = {},
79963
80426
  textCenters = {};
79964
- if (upstreamData.length > 0) {
79965
- const vennData = upstreamData.map(area => ({
80427
+ const hasEmptySet = upstreamData.some(area => {
80428
+ const sets = array(area[setField]);
80429
+ return !sets || 0 === sets.length;
80430
+ }),
80431
+ nonEmptyData = hasEmptySet ? upstreamData.filter(area => !isEmpty(array(area[setField]))) : upstreamData;
80432
+ if (nonEmptyData.length > 0) {
80433
+ const vennData = nonEmptyData.map(area => ({
79966
80434
  sets: array(area[setField]),
79967
80435
  size: area[valueField]
79968
80436
  }));
79969
80437
  let solution = venn$1(vennData, options);
79970
- solution = normalizeSolution(solution, orientation, orientationOrder), circles = scaleSolution(solution, x1 - x0, y1 - y0, x0, y0), textCenters = computeTextCenters(circles, vennData);
80438
+ solution = normalizeSolution(solution, orientation, orientationOrder), circles = scaleSolution(solution, x1 - x0, y1 - y0, x0, y0, hasEmptySet), textCenters = computeTextCenters(circles, vennData);
79971
80439
  }
79972
80440
  return upstreamData.map(area => {
79973
- const sets = array(area[setField]),
79974
- key = sets.toString(),
80441
+ const sets = array(area[setField]);
80442
+ if (!sets || 0 === sets.length) return Object.assign(Object.assign({}, area), {
80443
+ datum: area,
80444
+ sets: sets,
80445
+ key: emptySetKey || "others",
80446
+ size: area[valueField],
80447
+ labelX: void 0,
80448
+ labelY: void 0,
80449
+ type: "circle",
80450
+ x: x0 + (x1 - x0) / 2,
80451
+ y: y0 + (y1 - y0) / 2,
80452
+ radius: Math.min(x1 - x0, y1 - y0) / 2
80453
+ });
80454
+ const key = sets.toString(),
79975
80455
  textCenter = textCenters[key],
79976
80456
  basicDatum = Object.assign(Object.assign({}, area), {
79977
80457
  datum: area,
@@ -80251,11 +80731,11 @@
80251
80731
  if (1 === this._placeStatus) {
80252
80732
  const maxSize0 = d.fontSize * this._originSize[0] / this.options.minFontSize,
80253
80733
  distSize0 = Math.max(d.width, d.height);
80254
- if (distSize0 <= maxSize0) this.expandBoard(this._board, this._bounds, distSize0 / this._size[0]);else {
80734
+ if (distSize0 <= maxSize0) this._board = this.expandBoard(this._board, this._bounds, distSize0 / this._size[0]);else {
80255
80735
  if (!this.options.clip) return !0;
80256
- this.expandBoard(this._board, this._bounds, maxSize0 / this._size[0]);
80736
+ this._board = this.expandBoard(this._board, this._bounds, maxSize0 / this._size[0]);
80257
80737
  }
80258
- } else this._placeStatus, this.expandBoard(this._board, this._bounds);
80738
+ } else this._placeStatus, this._board = this.expandBoard(this._board, this._bounds);
80259
80739
  return this.updateBoardExpandStatus(d.fontSize), !1;
80260
80740
  }
80261
80741
  return this._tTemp = null, this._dtTemp = null, !0;
@@ -80266,7 +80746,7 @@
80266
80746
  width: 1,
80267
80747
  height: 1
80268
80748
  }));
80269
- this.contextAndRatio = contextAndRatio, this._board = new Array((this._size[0] >> 5) * this._size[1]).fill(0), this._bounds = null;
80749
+ this.contextAndRatio = contextAndRatio, this._board = new Uint32Array((this._size[0] >> 5) * this._size[1]).fill(0), this._bounds = null;
80270
80750
  words.length;
80271
80751
  this.result = [];
80272
80752
  const data = words.map((d, i) => ({
@@ -80333,18 +80813,33 @@
80333
80813
  this._size = this._size.map(v => v * (1 - minRatio));
80334
80814
  }
80335
80815
  expandBoard(board, bounds, factor) {
80336
- const expandedLeftWidth = this._size[0] * (factor || 1.1) - this._size[0] >> 5;
80816
+ const oldW = this._size[0],
80817
+ oldH = this._size[1],
80818
+ oldRowStride = oldW >> 5,
80819
+ expandedLeftWidth = oldW * (factor || 1.1) - oldW >> 5;
80337
80820
  let diffWidth = 2 * expandedLeftWidth > 2 ? expandedLeftWidth : 2;
80338
80821
  diffWidth % 2 != 0 && diffWidth++;
80339
- let diffHeight = Math.ceil(this._size[1] * (diffWidth << 5) / this._size[0]);
80822
+ let diffHeight = Math.ceil(oldH * (diffWidth << 5) / oldW);
80340
80823
  diffHeight % 2 != 0 && diffHeight++;
80341
- const w = this._size[0],
80342
- h = this._size[1],
80343
- widthArr = new Array(diffWidth).fill(0),
80344
- heightArr = new Array(diffHeight / 2 * (diffWidth + (w >> 5))).fill(0);
80345
- this.insertZerosToArray(board, h * (w >> 5), heightArr.length + diffWidth / 2);
80346
- for (let i = h - 1; i > 0; i--) this.insertZerosToArray(board, i * (w >> 5), widthArr.length);
80347
- this.insertZerosToArray(board, 0, heightArr.length + diffWidth / 2), this._size = [w + (diffWidth << 5), h + diffHeight], bounds && (bounds[0].x += (diffWidth << 5) / 2, bounds[0].y += diffHeight / 2, bounds[1].x += (diffWidth << 5) / 2, bounds[1].y += diffHeight / 2);
80824
+ const newW = oldW + (diffWidth << 5),
80825
+ newH = oldH + diffHeight,
80826
+ newRowStride = newW >> 5,
80827
+ paddingLeft = diffWidth / 2,
80828
+ paddingTop = diffHeight / 2,
80829
+ newBoard = new Uint32Array(newH * newRowStride).fill(0);
80830
+ for (let y = 0; y < oldH; y++) {
80831
+ const sourceStartIndex = y * oldRowStride,
80832
+ sourceEndIndex = sourceStartIndex + oldRowStride,
80833
+ destStartIndex = (y + paddingTop) * newRowStride + paddingLeft,
80834
+ rowData = board.slice(sourceStartIndex, sourceEndIndex);
80835
+ newBoard.set(rowData, destStartIndex);
80836
+ }
80837
+ if (this._size = [newW, newH], bounds) {
80838
+ const offsetX = (diffWidth << 5) / 2,
80839
+ offsetY = diffHeight / 2;
80840
+ bounds[0].x += offsetX, bounds[0].y += offsetY, bounds[1].x += offsetX, bounds[1].y += offsetY;
80841
+ }
80842
+ return newBoard;
80348
80843
  }
80349
80844
  insertZerosToArray(array, index, length) {
80350
80845
  if (this.options.customInsertZerosToArray) return this.options.customInsertZerosToArray(array, index, length);
@@ -88833,6 +89328,7 @@
88833
89328
  registerDimensionEvents();
88834
89329
  registerDimensionHover();
88835
89330
  registerBarSeries();
89331
+ Factory.registerTransform('bin', bin);
88836
89332
  Factory.registerChart(HistogramChart.type, HistogramChart);
88837
89333
  };
88838
89334
 
@@ -102085,6 +102581,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
102085
102581
  exports.registerAreaChart = registerAreaChart;
102086
102582
  exports.registerAreaMark = registerAreaMark;
102087
102583
  exports.registerAreaSeries = registerAreaSeries;
102584
+ exports.registerBarAnimation = registerBarAnimation;
102088
102585
  exports.registerBarChart = registerBarChart;
102089
102586
  exports.registerBarSeries = registerBarSeries;
102090
102587
  exports.registerBoxplotChart = registerBoxplotChart;