@visactor/vchart 2.0.0 → 2.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.es.js +178 -121
  3. package/build/index.js +178 -120
  4. package/build/index.min.js +2 -2
  5. package/build/tsconfig.tsbuildinfo +1 -1
  6. package/cjs/chart/base/base-chart.d.ts +1 -0
  7. package/cjs/chart/base/base-chart.js +3 -0
  8. package/cjs/chart/base/base-chart.js.map +1 -1
  9. package/cjs/chart/interface/chart.d.ts +1 -0
  10. package/cjs/chart/interface/chart.js.map +1 -1
  11. package/cjs/compile/compiler.js +6 -2
  12. package/cjs/compile/compiler.js.map +1 -1
  13. package/cjs/component/axis/base-axis.js.map +1 -1
  14. package/cjs/component/axis/interface/common.js.map +1 -1
  15. package/cjs/component/brush/brush.js +6 -6
  16. package/cjs/component/brush/brush.js.map +1 -1
  17. package/cjs/component/brush/interface.d.ts +1 -0
  18. package/cjs/component/brush/interface.js.map +1 -1
  19. package/cjs/component/crosshair/base.d.ts +1 -1
  20. package/cjs/component/crosshair/base.js +1 -1
  21. package/cjs/component/crosshair/base.js.map +1 -1
  22. package/cjs/component/crosshair/utils/cartesian.js +2 -2
  23. package/cjs/component/crosshair/utils/cartesian.js.map +1 -1
  24. package/cjs/core/index.d.ts +1 -1
  25. package/cjs/core/index.js +1 -1
  26. package/cjs/core/index.js.map +1 -1
  27. package/cjs/core/vchart.js +6 -7
  28. package/cjs/core/vchart.js.map +1 -1
  29. package/cjs/mark/base/base-mark.d.ts +3 -1
  30. package/cjs/mark/base/base-mark.js +33 -31
  31. package/cjs/mark/base/base-mark.js.map +1 -1
  32. package/cjs/mark/group.d.ts +1 -1
  33. package/cjs/mark/group.js +14 -10
  34. package/cjs/mark/group.js.map +1 -1
  35. package/cjs/mark/interface/common.d.ts +1 -1
  36. package/cjs/mark/interface/common.js.map +1 -1
  37. package/cjs/model/base-model.d.ts +1 -0
  38. package/cjs/model/base-model.js +1 -0
  39. package/cjs/model/base-model.js.map +1 -1
  40. package/cjs/model/interface.d.ts +1 -0
  41. package/cjs/model/interface.js.map +1 -1
  42. package/cjs/series/base/base-series.js +2 -3
  43. package/cjs/series/base/base-series.js.map +1 -1
  44. package/cjs/series/funnel/funnel.js +0 -2
  45. package/cjs/series/funnel/funnel.js.map +1 -1
  46. package/cjs/series/map/map.js +1 -2
  47. package/cjs/series/map/map.js.map +1 -1
  48. package/cjs/series/pie/pie.js +0 -1
  49. package/cjs/series/pie/pie.js.map +1 -1
  50. package/cjs/util/mark.d.ts +1 -0
  51. package/cjs/util/mark.js +10 -1
  52. package/cjs/util/mark.js.map +1 -1
  53. package/esm/chart/base/base-chart.d.ts +1 -0
  54. package/esm/chart/base/base-chart.js +3 -0
  55. package/esm/chart/base/base-chart.js.map +1 -1
  56. package/esm/chart/interface/chart.d.ts +1 -0
  57. package/esm/chart/interface/chart.js.map +1 -1
  58. package/esm/compile/compiler.js +7 -4
  59. package/esm/compile/compiler.js.map +1 -1
  60. package/esm/component/axis/base-axis.js.map +1 -1
  61. package/esm/component/axis/interface/common.js.map +1 -1
  62. package/esm/component/brush/brush.js +6 -6
  63. package/esm/component/brush/brush.js.map +1 -1
  64. package/esm/component/brush/interface.d.ts +1 -0
  65. package/esm/component/brush/interface.js.map +1 -1
  66. package/esm/component/crosshair/base.d.ts +1 -1
  67. package/esm/component/crosshair/base.js +1 -1
  68. package/esm/component/crosshair/base.js.map +1 -1
  69. package/esm/component/crosshair/utils/cartesian.js +2 -2
  70. package/esm/component/crosshair/utils/cartesian.js.map +1 -1
  71. package/esm/core/index.d.ts +1 -1
  72. package/esm/core/index.js +1 -1
  73. package/esm/core/index.js.map +1 -1
  74. package/esm/core/vchart.js +5 -6
  75. package/esm/core/vchart.js.map +1 -1
  76. package/esm/mark/base/base-mark.d.ts +3 -1
  77. package/esm/mark/base/base-mark.js +34 -30
  78. package/esm/mark/base/base-mark.js.map +1 -1
  79. package/esm/mark/group.d.ts +1 -1
  80. package/esm/mark/group.js +17 -9
  81. package/esm/mark/group.js.map +1 -1
  82. package/esm/mark/interface/common.d.ts +1 -1
  83. package/esm/mark/interface/common.js.map +1 -1
  84. package/esm/model/base-model.d.ts +1 -0
  85. package/esm/model/base-model.js +1 -0
  86. package/esm/model/base-model.js.map +1 -1
  87. package/esm/model/interface.d.ts +1 -0
  88. package/esm/model/interface.js.map +1 -1
  89. package/esm/series/base/base-series.js +2 -3
  90. package/esm/series/base/base-series.js.map +1 -1
  91. package/esm/series/funnel/funnel.js +0 -2
  92. package/esm/series/funnel/funnel.js.map +1 -1
  93. package/esm/series/map/map.js +1 -2
  94. package/esm/series/map/map.js.map +1 -1
  95. package/esm/series/pie/pie.js +0 -1
  96. package/esm/series/pie/pie.js.map +1 -1
  97. package/esm/util/mark.d.ts +1 -0
  98. package/esm/util/mark.js +7 -0
  99. package/esm/util/mark.js.map +1 -1
  100. package/package.json +6 -6
@@ -50,7 +50,9 @@ import { AnimationStateEnum } from "../../animation/interface";
50
50
 
51
51
  import { CompilableData } from "../../compile/data/compilable-data";
52
52
 
53
- import { log } from "../../util";
53
+ import { getDiffAttributesOfGraphic } from "../../util/mark";
54
+
55
+ import { log } from "../../util/debug";
54
56
 
55
57
  import { morph as runMorph } from "../../compile/morph";
56
58
 
@@ -509,6 +511,7 @@ export class BaseMark extends GrammarItem {
509
511
  this._dataByGroup = groupData(data, this._groupKeyGetter);
510
512
  }
511
513
  createAnimationStateList(type, animationConfig) {
514
+ var _a;
512
515
  let config = animationConfig[type];
513
516
  return config && Array.isArray(config) && (config = 1 === config.length ? config[0] : config),
514
517
  Array.isArray(config) && (config = config.map(((item, index) => {
@@ -516,7 +519,9 @@ export class BaseMark extends GrammarItem {
516
519
  return Object.assign(Object.assign({}, item), {
517
520
  priority: null !== (_a = item.priority) && void 0 !== _a ? _a : 1 / 0
518
521
  });
519
- }))), config;
522
+ }))), config ? Object.assign(Object.assign({}, config), {
523
+ priority: "normal" === type ? null !== (_a = config.priority) && void 0 !== _a ? _a : 1 / 0 : config.priority
524
+ }) : config;
520
525
  }
521
526
  tryRunMorphing(graphics) {
522
527
  if (this._lastMark) {
@@ -575,29 +580,32 @@ export class BaseMark extends GrammarItem {
575
580
  this._product.applyAnimationState([ "normal" ], [ normalConfig ]);
576
581
  }
577
582
  }
583
+ _setAnimationState(g) {
584
+ const customizedState = this._aniamtionStateCallback ? this._aniamtionStateCallback(g) : void 0;
585
+ g.context.animationState = null != customizedState ? customizedState : g.context.diffState,
586
+ g.context.animationState === DiffState.exit && (g.context.reusing = !0, g.animates && g.animates.forEach((a => a.stop())));
587
+ }
578
588
  _runJoin(data) {
579
- const newGroupedData = this._getDataByKey(data), prevGroupedData = this._prevDataByKey, newGraphics = [], enterGraphics = new Set(this._graphics.filter((g => g.context.diffState === DiffState.enter))), callback = (key, newData, prevData) => {
580
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
589
+ const newGroupedData = this._getDataByKey(data), prevGroupedData = this._prevDataByKey, allGraphics = [], enterGraphics = new Set(this._graphics.filter((g => g.context.diffState === DiffState.enter))), callback = (key, newData, prevData) => {
590
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
581
591
  let g, diffState;
582
592
  return isNil(newData) ? (g = this._graphicMap.get(key), g && (diffState = DiffState.exit)) : isNil(prevData) ? (g = this._graphicMap.has(key) ? this._graphicMap.get(key) : {},
583
- diffState = DiffState.enter, g.isExiting = !1, (null === (_a = g.context) || void 0 === _a ? void 0 : _a.diffState) === DiffState.exit && (g.context.reusing = !0,
584
- g.animates && g.animates.forEach((a => a.stop()))), this._graphicMap.set(key, g),
585
- newGraphics.push(g)) : (g = this._graphicMap.get(key), g && (diffState = DiffState.update,
586
- newGraphics.push(g))), g && (g.context = Object.assign(Object.assign({}, this._getCommonContext()), {
593
+ diffState = DiffState.enter, g.isExiting = !1, this._graphicMap.set(key, g), allGraphics.push(g)) : (g = this._graphicMap.get(key),
594
+ g && (diffState = DiffState.update, allGraphics.push(g))), g && (enterGraphics.delete(g),
595
+ g.context = Object.assign(Object.assign({}, this._getCommonContext()), {
587
596
  diffState: diffState,
588
- reusing: null === (_b = g.context) || void 0 === _b ? void 0 : _b.reusing,
589
- originalFieldX: null === (_c = g.context) || void 0 === _c ? void 0 : _c.originalFieldX,
590
- originalFieldY: null === (_d = g.context) || void 0 === _d ? void 0 : _d.originalFieldY,
591
- fieldX: null === (_e = g.context) || void 0 === _e ? void 0 : _e.fieldX,
592
- fieldY: null === (_f = g.context) || void 0 === _f ? void 0 : _f.fieldY,
593
- animationState: diffState,
594
- data: null != newData ? newData : null === (_g = g.context) || void 0 === _g ? void 0 : _g.data,
597
+ reusing: null === (_a = g.context) || void 0 === _a ? void 0 : _a.reusing,
598
+ originalFieldX: null === (_b = g.context) || void 0 === _b ? void 0 : _b.originalFieldX,
599
+ originalFieldY: null === (_c = g.context) || void 0 === _c ? void 0 : _c.originalFieldY,
600
+ fieldX: null === (_d = g.context) || void 0 === _d ? void 0 : _d.fieldX,
601
+ fieldY: null === (_e = g.context) || void 0 === _e ? void 0 : _e.fieldY,
602
+ data: null != newData ? newData : null === (_f = g.context) || void 0 === _f ? void 0 : _f.data,
595
603
  uniqueKey: key,
596
- key: newData ? this._keyGetter(newData[0]) : null === (_h = g.context) || void 0 === _h ? void 0 : _h.key,
597
- groupKey: newData ? this._groupKeyGetter(newData[0]) : null === (_j = g.context) || void 0 === _j ? void 0 : _j.groupKey,
604
+ key: newData ? this._keyGetter(newData[0]) : null === (_g = g.context) || void 0 === _g ? void 0 : _g.key,
605
+ groupKey: newData ? this._groupKeyGetter(newData[0]) : null === (_h = g.context) || void 0 === _h ? void 0 : _h.groupKey,
598
606
  indexKey: "__VCHART_DEFAULT_DATA_INDEX",
599
- stateAnimateConfig: null === (_k = this.getAnimationConfig()) || void 0 === _k ? void 0 : _k.state
600
- }), enterGraphics.delete(g)), g;
607
+ stateAnimateConfig: null === (_j = this.getAnimationConfig()) || void 0 === _j ? void 0 : _j.state
608
+ }), this._setAnimationState(g)), g;
601
609
  };
602
610
  if (prevGroupedData && newGroupedData) {
603
611
  const prevMap = new Map(prevGroupedData.data);
@@ -616,10 +624,10 @@ export class BaseMark extends GrammarItem {
616
624
  this._graphicMap.delete(g.context.uniqueKey), g.parent && g.parent.removeChild(g),
617
625
  g.release();
618
626
  }));
619
- const graphicCount = newGraphics.length;
620
- newGraphics.forEach(((g, index) => {
627
+ const graphicCount = allGraphics.length;
628
+ allGraphics.forEach(((g, index) => {
621
629
  g.context.graphicCount = graphicCount, g.context.graphicIndex = index;
622
- })), this._dataByKey = newGroupedData, this._graphics = newGraphics, this.needClear = !0;
630
+ })), this._dataByKey = newGroupedData, this._graphics = allGraphics, this.needClear = !0;
623
631
  }
624
632
  _runEncoderOfGraphic(styles, g, attrs = {}) {
625
633
  return runEncoder(styles, g.context.data[0], attrs);
@@ -663,10 +671,8 @@ export class BaseMark extends GrammarItem {
663
671
  var _a;
664
672
  const finalAttrs = g.context.finalAttrs, hasStateAnimation = this.hasAnimationByState(g.context.animationState);
665
673
  if (g.setAttributes) {
666
- const prevAttrs = g.getAttributes(!0), diffAttrs = {};
667
- Object.keys(finalAttrs).forEach((key => {
668
- prevAttrs[key] !== finalAttrs[key] && (diffAttrs[key] = finalAttrs[key]);
669
- })), g.context.diffAttrs = diffAttrs, g.context.reusing ? (g.context.lastAttrs = g.attribute,
674
+ const diffAttrs = getDiffAttributesOfGraphic(g, finalAttrs);
675
+ g.context.diffAttrs = diffAttrs, g.context.reusing ? (g.context.lastAttrs = g.attribute,
670
676
  g.initAttributes({}), g.context.reusing = !1) : hasStateAnimation || (hasAnimation ? g.setAttributesAndPreventAnimate(diffAttrs) : g.setAttributes(diffAttrs)),
671
677
  hasAnimation && g.setFinalAttributes(finalAttrs);
672
678
  } else {
@@ -770,7 +776,7 @@ export class BaseMark extends GrammarItem {
770
776
  this._graphicMap.delete(key), g.parent && g.parent.removeChild(g), g.release && g.release();
771
777
  };
772
778
  this._graphicMap.forEach(((g, key) => {
773
- if (g.context.diffState === DiffState.exit && !g.isExiting) if (this.hasAnimationByState("exit")) {
779
+ if (g.context.diffState === DiffState.exit && !g.isExiting) if (g.context.animationState === DiffState.exit && this.hasAnimationByState("exit")) {
774
780
  g.isExiting = !0;
775
781
  const animationConfig = this.getAnimationConfig();
776
782
  if (animationConfig.exit && animationConfig.exit.length) {
@@ -880,9 +886,7 @@ export class BaseMark extends GrammarItem {
880
886
  (null === (_a = this.renderContext) || void 0 === _a ? void 0 : _a.beforeTransformProgressive) ? this._runBeforeProgressive() : this.renderContext.progressive && this._runProgressiveStep();
881
887
  }
882
888
  updateAnimationState(callback) {
883
- this._graphics && this._graphics.length && this._graphics.forEach((g => {
884
- g.context.animationState = callback(g);
885
- }));
889
+ this._aniamtionStateCallback = callback;
886
890
  }
887
891
  hasAnimationByState(state) {
888
892
  if (!state || !this._animationConfig || !this._animationConfig[state]) return !1;