@visactor/vchart-extension 2.0.4-alpha.5 → 2.0.4-alpha.7

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
@@ -7015,7 +7015,8 @@
7015
7015
  y1: 0,
7016
7016
  strokeBoundsBuffer: 0,
7017
7017
  cornerRadius: 0,
7018
- cornerType: "round"
7018
+ cornerType: "round",
7019
+ drawStrokeWhenZeroWH: !1
7019
7020
  });
7020
7021
  Object.assign(Object.assign({}, DefaultAttribute), {
7021
7022
  width: 0,
@@ -7024,7 +7025,8 @@
7024
7025
  y1: 0,
7025
7026
  cornerRadius: 0,
7026
7027
  length: 0,
7027
- cornerType: "round"
7028
+ cornerType: "round",
7029
+ drawStrokeWhenZeroWH: !1
7028
7030
  });
7029
7031
  const DefaultSymbolAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
7030
7032
  symbolType: "circle",
@@ -7251,6 +7253,34 @@
7251
7253
  }
7252
7254
  return c;
7253
7255
  }
7256
+ static processColorStops(colorStops) {
7257
+ if (!colorStops || 0 === colorStops.length) return [];
7258
+ if (colorStops.some(item => item.length)) {
7259
+ const stops = colorStops.map(item => ({
7260
+ color: item.value,
7261
+ offset: item.length ? parseFloat(item.length.value) / 100 : -1
7262
+ }));
7263
+ stops[0].offset < 0 && (stops[0].offset = 0), stops[stops.length - 1].offset < 0 && (stops[stops.length - 1].offset = 1);
7264
+ for (let i = 1; i < stops.length - 1; i++) if (stops[i].offset < 0) {
7265
+ const prevWithOffsetIdx = i - 1;
7266
+ let nextWithOffsetIdx = i + 1;
7267
+ for (; nextWithOffsetIdx < stops.length && stops[nextWithOffsetIdx].offset < 0;) nextWithOffsetIdx++;
7268
+ const startOffset = stops[prevWithOffsetIdx].offset,
7269
+ endOffset = stops[nextWithOffsetIdx].offset,
7270
+ unspecCount = nextWithOffsetIdx - prevWithOffsetIdx;
7271
+ for (let j = 1; j < unspecCount; j++) stops[prevWithOffsetIdx + j].offset = startOffset + (endOffset - startOffset) * j / unspecCount;
7272
+ i = nextWithOffsetIdx - 1;
7273
+ }
7274
+ return stops;
7275
+ }
7276
+ return colorStops.map((item, index) => {
7277
+ const offset = colorStops.length > 1 ? index / (colorStops.length - 1) : 0;
7278
+ return {
7279
+ color: item.value,
7280
+ offset: offset
7281
+ };
7282
+ });
7283
+ }
7254
7284
  static ParseConic(datum) {
7255
7285
  const {
7256
7286
  orientation: orientation,
@@ -7264,10 +7294,7 @@
7264
7294
  y: .5,
7265
7295
  startAngle: sa,
7266
7296
  endAngle: sa + pi2,
7267
- stops: colorStops.map(item => ({
7268
- color: item.value,
7269
- offset: parseFloat(item.length.value) / 100
7270
- }))
7297
+ stops: GradientParser.processColorStops(colorStops)
7271
7298
  };
7272
7299
  }
7273
7300
  static ParseRadial(datum) {
@@ -7282,10 +7309,7 @@
7282
7309
  y1: .5,
7283
7310
  r0: 0,
7284
7311
  r1: 1,
7285
- stops: colorStops.map(item => ({
7286
- color: item.value,
7287
- offset: parseFloat(item.length.value) / 100
7288
- }))
7312
+ stops: GradientParser.processColorStops(colorStops)
7289
7313
  };
7290
7314
  }
7291
7315
  static ParseLinear(datum) {
@@ -7307,10 +7331,7 @@
7307
7331
  y0: y0,
7308
7332
  x1: x1,
7309
7333
  y1: y1,
7310
- stops: colorStops.map(item => ({
7311
- color: item.value,
7312
- offset: parseFloat(item.length.value) / 100
7313
- }))
7334
+ stops: GradientParser.processColorStops(colorStops)
7314
7335
  };
7315
7336
  }
7316
7337
  }
@@ -10219,7 +10240,7 @@
10219
10240
  });
10220
10241
  }
10221
10242
  setAttributes(params, forceUpdateTag = !1, context) {
10222
- (params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context);
10243
+ params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
10223
10244
  }
10224
10245
  _setAttributes(params, forceUpdateTag = !1, context) {
10225
10246
  const keys = Object.keys(params);
@@ -10854,8 +10875,8 @@
10854
10875
  function strokeVisible(opacity, strokeOpacity) {
10855
10876
  return opacity * strokeOpacity > 0;
10856
10877
  }
10857
- function rectStrokeVisible(opacity, strokeOpacity, width, height) {
10858
- return opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
10878
+ function rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH) {
10879
+ return drawStrokeWhenZeroWH ? opacity * strokeOpacity > 0 : opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
10859
10880
  }
10860
10881
  function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
10861
10882
  const x10 = x1 - x0,
@@ -12843,7 +12864,7 @@
12843
12864
  case "right":
12844
12865
  deltaX = -aabbBounds.width();
12845
12866
  }
12846
- return aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1, application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), 0 === aabbBounds.width() && 0 === aabbBounds.height() && aabbBounds.clear(), aabbBounds;
12867
+ return height || ("middle" === this.verticalDirection ? deltaY -= aabbBounds.height() / 2 : "bottom" === this.verticalDirection && (deltaY -= aabbBounds.height())), aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1, application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), 0 === aabbBounds.width() && 0 === aabbBounds.height() && aabbBounds.clear(), aabbBounds;
12847
12868
  }
12848
12869
  needUpdateTags(keys) {
12849
12870
  return super.needUpdateTags(keys, RICHTEXT_UPDATE_TAG_KEY);
@@ -14921,7 +14942,8 @@
14921
14942
  y1: y1,
14922
14943
  x: originX = rectAttribute.x,
14923
14944
  y: originY = rectAttribute.y,
14924
- fillStrokeOrder = rectAttribute.fillStrokeOrder
14945
+ fillStrokeOrder = rectAttribute.fillStrokeOrder,
14946
+ drawStrokeWhenZeroWH = rectAttribute.drawStrokeWhenZeroWH
14925
14947
  } = rect.attribute;
14926
14948
  let {
14927
14949
  width: width,
@@ -14929,7 +14951,7 @@
14929
14951
  } = rect.attribute;
14930
14952
  width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0;
14931
14953
  const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill),
14932
- sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height),
14954
+ sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH),
14933
14955
  doFill = runFill(fill, background),
14934
14956
  doStroke = runStroke(stroke, lineWidth);
14935
14957
  if (!rect.valid || !visible) return;
@@ -15833,7 +15855,7 @@
15833
15855
  super(...arguments), this.type = "rect3d", this.numberType = RECT3D_NUMBER_TYPE;
15834
15856
  }
15835
15857
  drawShape(rect, context, x, y, drawContext, params, fillCb, strokeCb) {
15836
- var _a;
15858
+ var _a, _b;
15837
15859
  const rectAttribute = getTheme(rect, null == params ? void 0 : params.theme).rect,
15838
15860
  {
15839
15861
  fill = rectAttribute.fill,
@@ -15846,16 +15868,17 @@
15846
15868
  fillOpacity = rectAttribute.fillOpacity,
15847
15869
  lineWidth = rectAttribute.lineWidth,
15848
15870
  strokeOpacity = rectAttribute.strokeOpacity,
15849
- visible = rectAttribute.visible
15871
+ visible = rectAttribute.visible,
15872
+ drawStrokeWhenZeroWH = null !== (_a = rectAttribute.drawStrokeWhenZeroWH) && void 0 !== _a && _a
15850
15873
  } = rect.attribute;
15851
15874
  let {
15852
15875
  width: width,
15853
15876
  height: height
15854
15877
  } = rect.attribute;
15855
15878
  width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0;
15856
- const z = null !== (_a = this.z) && void 0 !== _a ? _a : 0,
15879
+ const z = null !== (_b = this.z) && void 0 !== _b ? _b : 0,
15857
15880
  fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill),
15858
- sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height),
15881
+ sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH),
15859
15882
  doFill = runFill(fill),
15860
15883
  doStroke = runStroke(stroke, lineWidth);
15861
15884
  if (!rect.valid || !visible) return;
@@ -17848,6 +17871,7 @@
17848
17871
  return this.getEndProps();
17849
17872
  }
17850
17873
  stop() {}
17874
+ release() {}
17851
17875
  }
17852
17876
  class WaitStep extends Step {
17853
17877
  constructor(type, props, duration, easing) {
@@ -17855,8 +17879,6 @@
17855
17879
  }
17856
17880
  onStart() {
17857
17881
  super.onStart();
17858
- }
17859
- onFirstRun() {
17860
17882
  const fromProps = this.getFromProps();
17861
17883
  this.target.setAttributes(fromProps);
17862
17884
  }
@@ -18065,7 +18087,9 @@
18065
18087
  this.status !== AnimateStatus.END && this.onEnd(), this.status = AnimateStatus.END, this.target && ("start" === type ? this.target.setAttributes(this._startProps) : "end" === type ? this.target.setAttributes(this._endProps) : type && this.target.setAttributes(type));
18066
18088
  }
18067
18089
  release() {
18068
- this.status = AnimateStatus.END, this._onRemove && this._onRemove.forEach(cb => cb()), this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [];
18090
+ this.status = AnimateStatus.END, this._onRemove && this._onRemove.forEach(cb => cb()), this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [], this.forEachStep(step => {
18091
+ step.release();
18092
+ });
18069
18093
  }
18070
18094
  getDuration() {
18071
18095
  return this._duration;
@@ -18139,6 +18163,10 @@
18139
18163
  getLoop() {
18140
18164
  return this._loopCount;
18141
18165
  }
18166
+ forEachStep(cb) {
18167
+ let step = this._firstStep;
18168
+ for (; step;) cb(step), step = step.next;
18169
+ }
18142
18170
  }
18143
18171
 
18144
18172
  const performanceRAF = new PerformanceRAF();
@@ -18371,6 +18399,9 @@
18371
18399
  constructor(target) {
18372
18400
  this._animates = [], this._startCallbacks = [], this._endCallbacks = [], this._started = !1, this._activeCount = 0, this._target = target;
18373
18401
  }
18402
+ get started() {
18403
+ return this._started;
18404
+ }
18374
18405
  onStart(cb) {
18375
18406
  cb ? (this._startCallbacks.push(cb), this._started && this._activeCount > 0 && cb()) : this._startCallbacks.forEach(cb => {
18376
18407
  cb();
@@ -18511,14 +18542,14 @@
18511
18542
  return delayAfterValue > 0 && (totalDelay += delayAfterValue), totalDelay > 0 && animate.wait(totalDelay), loop && loop > 0 && animate.loop(loop), bounce && animate.bounce(!0), animate;
18512
18543
  }
18513
18544
  _handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, controlOptions, options, type, graphic) {
18514
- var _a, _b, _c, _d;
18545
+ var _a, _b, _c, _d, _e, _f;
18515
18546
  if (custom && customType) {
18516
18547
  const customParams = Object.assign({
18517
- width: graphic.stage.width,
18518
- height: graphic.stage.height,
18548
+ width: (null === (_a = graphic.stage) || void 0 === _a ? void 0 : _a.width) || 0,
18549
+ height: (null === (_b = graphic.stage) || void 0 === _b ? void 0 : _b.height) || 0,
18519
18550
  group: this._target.parent
18520
18551
  }, this.resolveValue(customParameters, graphic)),
18521
- objOptions = isFunction$1(options) ? options.call(null, null !== (_b = customParams && (null === (_a = customParams.data) || void 0 === _a ? void 0 : _a[0])) && void 0 !== _b ? _b : null === (_d = null === (_c = graphic.context) || void 0 === _c ? void 0 : _c.data) || void 0 === _d ? void 0 : _d[0], graphic, customParams) : options;
18552
+ objOptions = isFunction$1(options) ? options.call(null, null !== (_d = customParams && (null === (_c = customParams.data) || void 0 === _c ? void 0 : _c[0])) && void 0 !== _d ? _d : null === (_f = null === (_e = graphic.context) || void 0 === _e ? void 0 : _e.data) || void 0 === _f ? void 0 : _f[0], graphic, customParams) : options;
18522
18553
  customParams.options = objOptions, customParams.controlOptions = controlOptions, 1 === customType ? this.createCustomAnimation(animate, custom, from, props, duration, easing, customParams) : 2 === customType && this.createCustomInterpolatorAnimation(animate, custom, props, duration, easing, customParams);
18523
18554
  } else "to" === type ? animate.to(props, duration, easing) : "from" === type && animate.from(props, duration, easing);
18524
18555
  }
@@ -18738,7 +18769,7 @@
18738
18769
  reApplyState(state) {
18739
18770
  var _a;
18740
18771
  const stateInfo = null === (_a = this.stateList) || void 0 === _a ? void 0 : _a.find(stateInfo => stateInfo.state === state);
18741
- if (stateInfo) {
18772
+ if (stateInfo && stateInfo.executor.started) {
18742
18773
  const stateList = this.stateList.slice();
18743
18774
  stateInfo.executor.stop(), this.stateList = stateList, stateInfo.executor.execute(stateInfo.animationConfig);
18744
18775
  }
@@ -21877,7 +21908,14 @@
21877
21908
  if (maskImage && ((_a = this._spec.layoutConfig) === null || _a === void 0 ? void 0 : _a.placement) === 'masked') {
21878
21909
  this._rootMark.getProduct().setAttribute('background', maskImage);
21879
21910
  }
21880
- }).bind(this)
21911
+ }).bind(this),
21912
+ onLayoutFinished: () => {
21913
+ var _a, _b;
21914
+ return (_b = (_a = this._option.globalInstance
21915
+ .getChart()
21916
+ .getOption()
21917
+ .performanceHook) === null || _a === void 0 ? void 0 : _a.afterWordcloudShapeDraw) === null || _b === void 0 ? void 0 : _b.call(_a, this._option.globalInstance);
21918
+ }
21881
21919
  };
21882
21920
  }
21883
21921
  _buildMarkAttributeContext() {