@visactor/vchart 2.0.12-alpha.0 → 2.0.12-alpha.1

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.es.js CHANGED
@@ -35125,6 +35125,10 @@ class AnimationTransitionRegistry {
35125
35125
  }
35126
35126
  AnimationTransitionRegistry.getInstance();
35127
35127
 
35128
+ function getCustomType(custom) {
35129
+ return custom && isFunction$1(custom) ? /^class\s/.test(Function.prototype.toString.call(custom)) ? 1 : 2 : 0;
35130
+ }
35131
+
35128
35132
  class AnimateExecutor {
35129
35133
  static registerBuiltInAnimate(name, animate) {
35130
35134
  AnimateExecutor.builtInAnimateMap[name] = animate;
@@ -35189,7 +35193,7 @@ class AnimateExecutor {
35189
35193
  effects: effects.map(effect => {
35190
35194
  var _a, _b;
35191
35195
  const custom = null !== (_a = effect.custom) && void 0 !== _a ? _a : AnimateExecutor.builtInAnimateMap[null !== (_b = effect.type) && void 0 !== _b ? _b : "fromTo"],
35192
- customType = custom && isFunction$1(custom) ? /^class\s/.test(Function.prototype.toString.call(custom)) ? 1 : 2 : 0;
35196
+ customType = getCustomType(custom);
35193
35197
  return Object.assign(Object.assign({}, effect), {
35194
35198
  custom: custom,
35195
35199
  customType: customType
@@ -35203,7 +35207,7 @@ class AnimateExecutor {
35203
35207
  duration = this.resolveValue(params.duration, child, 300);
35204
35208
  let oneByOneDelay = 0;
35205
35209
  oneByOne && (oneByOneDelay = "number" == typeof oneByOne ? oneByOne : oneByOne ? delay + delayAfter + duration : 0), parsedParams.oneByOneDelay = oneByOneDelay, parsedParams.custom = null !== (_a = params.custom) && void 0 !== _a ? _a : AnimateExecutor.builtInAnimateMap[null !== (_b = params.type) && void 0 !== _b ? _b : "fromTo"];
35206
- const customType = parsedParams.custom && isFunction$1(parsedParams.custom) ? /^class\s/.test(Function.prototype.toString.call(parsedParams.custom)) ? 1 : 2 : 0;
35210
+ const customType = getCustomType(parsedParams.custom);
35207
35211
  if (parsedParams.customType = customType, totalTime) {
35208
35212
  const _totalTime = delay + delayAfter + duration + oneByOneDelay * (this._target.count - 2),
35209
35213
  scale = totalTime ? totalTime / _totalTime : 1;
@@ -35332,7 +35336,7 @@ class AnimateExecutor {
35332
35336
  from = effect.from;
35333
35337
  props || (parsedFromProps || (parsedFromProps = this.createPropsFromChannel(channel, graphic)), props = parsedFromProps.props), from || (parsedFromProps || (parsedFromProps = this.createPropsFromChannel(channel, graphic)), from = parsedFromProps.from);
35334
35338
  const custom = null !== (_a = effect.custom) && void 0 !== _a ? _a : AnimateExecutor.builtInAnimateMap[type],
35335
- customType = effect.customType;
35339
+ customType = effect.custom ? effect.customType : getCustomType(custom);
35336
35340
  this._handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, controlOptions, options, type, graphic);
35337
35341
  }), delayAfterValue > 0 && animate.wait(delayAfterValue);
35338
35342
  }
@@ -41311,7 +41315,31 @@ class CircleAxis extends AxisBase {
41311
41315
  separation: autoHideSeparation
41312
41316
  }));
41313
41317
  }
41314
- afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {}
41318
+ afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
41319
+ var _a;
41320
+ const {
41321
+ layoutRect: layoutRect,
41322
+ autoLabelMaxWidth: autoLabelMaxWidth
41323
+ } = this.attribute;
41324
+ if (!autoLabelMaxWidth || !layoutRect || !labelShapes || 0 === labelShapes.length) return;
41325
+ const rectRight = 0 + layoutRect.width;
41326
+ for (let i = 0; i < labelShapes.length; i++) {
41327
+ const label = labelShapes[i],
41328
+ x = label.attribute.x,
41329
+ align = null !== (_a = label.attribute.textAlign) && void 0 !== _a ? _a : "center";
41330
+ let maxWidth = 0;
41331
+ if ("left" === align) maxWidth = rectRight - x;else if ("right" === align) maxWidth = x - 0;else {
41332
+ const leftDist = x - 0,
41333
+ rightDist = rectRight - x;
41334
+ maxWidth = 2 * Math.max(0, Math.min(leftDist, rightDist));
41335
+ }
41336
+ maxWidth > 0 ? label.setAttributes({
41337
+ maxLineWidth: maxWidth
41338
+ }) : label.setAttributes({
41339
+ maxLineWidth: 0
41340
+ });
41341
+ }
41342
+ }
41315
41343
  getTextBaseline(vector) {
41316
41344
  return Math.abs(vector[1] / vector[0]) < .3 ? "middle" : vector[1] < 0 ? "bottom" : vector[1] > 0 ? "top" : "middle";
41317
41345
  }
package/build/index.js CHANGED
@@ -35131,6 +35131,10 @@
35131
35131
  }
35132
35132
  AnimationTransitionRegistry.getInstance();
35133
35133
 
35134
+ function getCustomType(custom) {
35135
+ return custom && isFunction$1(custom) ? /^class\s/.test(Function.prototype.toString.call(custom)) ? 1 : 2 : 0;
35136
+ }
35137
+
35134
35138
  class AnimateExecutor {
35135
35139
  static registerBuiltInAnimate(name, animate) {
35136
35140
  AnimateExecutor.builtInAnimateMap[name] = animate;
@@ -35195,7 +35199,7 @@
35195
35199
  effects: effects.map(effect => {
35196
35200
  var _a, _b;
35197
35201
  const custom = null !== (_a = effect.custom) && void 0 !== _a ? _a : AnimateExecutor.builtInAnimateMap[null !== (_b = effect.type) && void 0 !== _b ? _b : "fromTo"],
35198
- customType = custom && isFunction$1(custom) ? /^class\s/.test(Function.prototype.toString.call(custom)) ? 1 : 2 : 0;
35202
+ customType = getCustomType(custom);
35199
35203
  return Object.assign(Object.assign({}, effect), {
35200
35204
  custom: custom,
35201
35205
  customType: customType
@@ -35209,7 +35213,7 @@
35209
35213
  duration = this.resolveValue(params.duration, child, 300);
35210
35214
  let oneByOneDelay = 0;
35211
35215
  oneByOne && (oneByOneDelay = "number" == typeof oneByOne ? oneByOne : oneByOne ? delay + delayAfter + duration : 0), parsedParams.oneByOneDelay = oneByOneDelay, parsedParams.custom = null !== (_a = params.custom) && void 0 !== _a ? _a : AnimateExecutor.builtInAnimateMap[null !== (_b = params.type) && void 0 !== _b ? _b : "fromTo"];
35212
- const customType = parsedParams.custom && isFunction$1(parsedParams.custom) ? /^class\s/.test(Function.prototype.toString.call(parsedParams.custom)) ? 1 : 2 : 0;
35216
+ const customType = getCustomType(parsedParams.custom);
35213
35217
  if (parsedParams.customType = customType, totalTime) {
35214
35218
  const _totalTime = delay + delayAfter + duration + oneByOneDelay * (this._target.count - 2),
35215
35219
  scale = totalTime ? totalTime / _totalTime : 1;
@@ -35338,7 +35342,7 @@
35338
35342
  from = effect.from;
35339
35343
  props || (parsedFromProps || (parsedFromProps = this.createPropsFromChannel(channel, graphic)), props = parsedFromProps.props), from || (parsedFromProps || (parsedFromProps = this.createPropsFromChannel(channel, graphic)), from = parsedFromProps.from);
35340
35344
  const custom = null !== (_a = effect.custom) && void 0 !== _a ? _a : AnimateExecutor.builtInAnimateMap[type],
35341
- customType = effect.customType;
35345
+ customType = effect.custom ? effect.customType : getCustomType(custom);
35342
35346
  this._handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, controlOptions, options, type, graphic);
35343
35347
  }), delayAfterValue > 0 && animate.wait(delayAfterValue);
35344
35348
  }
@@ -41317,7 +41321,31 @@
41317
41321
  separation: autoHideSeparation
41318
41322
  }));
41319
41323
  }
41320
- afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {}
41324
+ afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
41325
+ var _a;
41326
+ const {
41327
+ layoutRect: layoutRect,
41328
+ autoLabelMaxWidth: autoLabelMaxWidth
41329
+ } = this.attribute;
41330
+ if (!autoLabelMaxWidth || !layoutRect || !labelShapes || 0 === labelShapes.length) return;
41331
+ const rectRight = 0 + layoutRect.width;
41332
+ for (let i = 0; i < labelShapes.length; i++) {
41333
+ const label = labelShapes[i],
41334
+ x = label.attribute.x,
41335
+ align = null !== (_a = label.attribute.textAlign) && void 0 !== _a ? _a : "center";
41336
+ let maxWidth = 0;
41337
+ if ("left" === align) maxWidth = rectRight - x;else if ("right" === align) maxWidth = x - 0;else {
41338
+ const leftDist = x - 0,
41339
+ rightDist = rectRight - x;
41340
+ maxWidth = 2 * Math.max(0, Math.min(leftDist, rightDist));
41341
+ }
41342
+ maxWidth > 0 ? label.setAttributes({
41343
+ maxLineWidth: maxWidth
41344
+ }) : label.setAttributes({
41345
+ maxLineWidth: 0
41346
+ });
41347
+ }
41348
+ }
41321
41349
  getTextBaseline(vector) {
41322
41350
  return Math.abs(vector[1] / vector[0]) < .3 ? "middle" : vector[1] < 0 ? "bottom" : vector[1] > 0 ? "top" : "middle";
41323
41351
  }