@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
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "__esModule", {
14
14
  value: !0
15
15
  }), exports.BaseMark = void 0;
16
16
 
17
- const enum_1 = require("../interface/enum"), interface_1 = require("../../compile/mark/interface"), vutils_extension_1 = require("@visactor/vutils-extension"), color_1 = require("../../util/color"), scale_1 = require("../../util/scale"), gradient_1 = require("../../constant/gradient"), attribute_1 = require("../../constant/attribute"), vscale_1 = require("@visactor/vscale"), util_1 = require("../../theme/color-scheme/util"), mark_1 = require("../../compile/mark"), vutils_1 = require("@visactor/vutils"), common_1 = require("../utils/common"), interface_2 = require("../../compile/interface"), vrender_core_1 = require("@visactor/vrender-core"), util_2 = require("../../compile/mark/util"), factory_1 = require("../../core/factory"), data_1 = require("../../constant/data"), grammar_item_1 = require("../../compile/grammar-item"), layout_1 = require("../../constant/layout"), interface_3 = require("../../animation/interface"), compilable_data_1 = require("../../compile/data/compilable-data"), util_3 = require("../../util"), morph_1 = require("../../compile/morph");
17
+ const enum_1 = require("../interface/enum"), interface_1 = require("../../compile/mark/interface"), vutils_extension_1 = require("@visactor/vutils-extension"), color_1 = require("../../util/color"), scale_1 = require("../../util/scale"), gradient_1 = require("../../constant/gradient"), attribute_1 = require("../../constant/attribute"), vscale_1 = require("@visactor/vscale"), util_1 = require("../../theme/color-scheme/util"), mark_1 = require("../../compile/mark"), vutils_1 = require("@visactor/vutils"), common_1 = require("../utils/common"), interface_2 = require("../../compile/interface"), vrender_core_1 = require("@visactor/vrender-core"), util_2 = require("../../compile/mark/util"), factory_1 = require("../../core/factory"), data_1 = require("../../constant/data"), grammar_item_1 = require("../../compile/grammar-item"), layout_1 = require("../../constant/layout"), interface_3 = require("../../animation/interface"), compilable_data_1 = require("../../compile/data/compilable-data"), mark_2 = require("../../util/mark"), debug_1 = require("../../util/debug"), morph_1 = require("../../compile/morph");
18
18
 
19
19
  class BaseMark extends grammar_item_1.GrammarItem {
20
20
  commit(render, recursion) {
@@ -476,6 +476,7 @@ class BaseMark extends grammar_item_1.GrammarItem {
476
476
  this._dataByGroup = (0, common_1.groupData)(data, this._groupKeyGetter);
477
477
  }
478
478
  createAnimationStateList(type, animationConfig) {
479
+ var _a;
479
480
  let config = animationConfig[type];
480
481
  return config && Array.isArray(config) && (config = 1 === config.length ? config[0] : config),
481
482
  Array.isArray(config) && (config = config.map(((item, index) => {
@@ -483,7 +484,9 @@ class BaseMark extends grammar_item_1.GrammarItem {
483
484
  return Object.assign(Object.assign({}, item), {
484
485
  priority: null !== (_a = item.priority) && void 0 !== _a ? _a : 1 / 0
485
486
  });
486
- }))), config;
487
+ }))), config ? Object.assign(Object.assign({}, config), {
488
+ priority: "normal" === type ? null !== (_a = config.priority) && void 0 !== _a ? _a : 1 / 0 : config.priority
489
+ }) : config;
487
490
  }
488
491
  tryRunMorphing(graphics) {
489
492
  if (this._lastMark) {
@@ -542,30 +545,33 @@ class BaseMark extends grammar_item_1.GrammarItem {
542
545
  this._product.applyAnimationState([ "normal" ], [ normalConfig ]);
543
546
  }
544
547
  }
548
+ _setAnimationState(g) {
549
+ const customizedState = this._aniamtionStateCallback ? this._aniamtionStateCallback(g) : void 0;
550
+ g.context.animationState = null != customizedState ? customizedState : g.context.diffState,
551
+ g.context.animationState === enum_1.DiffState.exit && (g.context.reusing = !0, g.animates && g.animates.forEach((a => a.stop())));
552
+ }
545
553
  _runJoin(data) {
546
- const newGroupedData = this._getDataByKey(data), prevGroupedData = this._prevDataByKey, newGraphics = [], enterGraphics = new Set(this._graphics.filter((g => g.context.diffState === enum_1.DiffState.enter))), callback = (key, newData, prevData) => {
547
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
554
+ const newGroupedData = this._getDataByKey(data), prevGroupedData = this._prevDataByKey, allGraphics = [], enterGraphics = new Set(this._graphics.filter((g => g.context.diffState === enum_1.DiffState.enter))), callback = (key, newData, prevData) => {
555
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
548
556
  let g, diffState;
549
557
  return (0, vutils_1.isNil)(newData) ? (g = this._graphicMap.get(key), g && (diffState = enum_1.DiffState.exit)) : (0,
550
558
  vutils_1.isNil)(prevData) ? (g = this._graphicMap.has(key) ? this._graphicMap.get(key) : {},
551
- diffState = enum_1.DiffState.enter, g.isExiting = !1, (null === (_a = g.context) || void 0 === _a ? void 0 : _a.diffState) === enum_1.DiffState.exit && (g.context.reusing = !0,
552
- g.animates && g.animates.forEach((a => a.stop()))), this._graphicMap.set(key, g),
553
- newGraphics.push(g)) : (g = this._graphicMap.get(key), g && (diffState = enum_1.DiffState.update,
554
- newGraphics.push(g))), g && (g.context = Object.assign(Object.assign({}, this._getCommonContext()), {
559
+ diffState = enum_1.DiffState.enter, g.isExiting = !1, this._graphicMap.set(key, g),
560
+ allGraphics.push(g)) : (g = this._graphicMap.get(key), g && (diffState = enum_1.DiffState.update,
561
+ allGraphics.push(g))), g && (enterGraphics.delete(g), g.context = Object.assign(Object.assign({}, this._getCommonContext()), {
555
562
  diffState: diffState,
556
- reusing: null === (_b = g.context) || void 0 === _b ? void 0 : _b.reusing,
557
- originalFieldX: null === (_c = g.context) || void 0 === _c ? void 0 : _c.originalFieldX,
558
- originalFieldY: null === (_d = g.context) || void 0 === _d ? void 0 : _d.originalFieldY,
559
- fieldX: null === (_e = g.context) || void 0 === _e ? void 0 : _e.fieldX,
560
- fieldY: null === (_f = g.context) || void 0 === _f ? void 0 : _f.fieldY,
561
- animationState: diffState,
562
- data: null != newData ? newData : null === (_g = g.context) || void 0 === _g ? void 0 : _g.data,
563
+ reusing: null === (_a = g.context) || void 0 === _a ? void 0 : _a.reusing,
564
+ originalFieldX: null === (_b = g.context) || void 0 === _b ? void 0 : _b.originalFieldX,
565
+ originalFieldY: null === (_c = g.context) || void 0 === _c ? void 0 : _c.originalFieldY,
566
+ fieldX: null === (_d = g.context) || void 0 === _d ? void 0 : _d.fieldX,
567
+ fieldY: null === (_e = g.context) || void 0 === _e ? void 0 : _e.fieldY,
568
+ data: null != newData ? newData : null === (_f = g.context) || void 0 === _f ? void 0 : _f.data,
563
569
  uniqueKey: key,
564
- key: newData ? this._keyGetter(newData[0]) : null === (_h = g.context) || void 0 === _h ? void 0 : _h.key,
565
- groupKey: newData ? this._groupKeyGetter(newData[0]) : null === (_j = g.context) || void 0 === _j ? void 0 : _j.groupKey,
570
+ key: newData ? this._keyGetter(newData[0]) : null === (_g = g.context) || void 0 === _g ? void 0 : _g.key,
571
+ groupKey: newData ? this._groupKeyGetter(newData[0]) : null === (_h = g.context) || void 0 === _h ? void 0 : _h.groupKey,
566
572
  indexKey: "__VCHART_DEFAULT_DATA_INDEX",
567
- stateAnimateConfig: null === (_k = this.getAnimationConfig()) || void 0 === _k ? void 0 : _k.state
568
- }), enterGraphics.delete(g)), g;
573
+ stateAnimateConfig: null === (_j = this.getAnimationConfig()) || void 0 === _j ? void 0 : _j.state
574
+ }), this._setAnimationState(g)), g;
569
575
  };
570
576
  if (prevGroupedData && newGroupedData) {
571
577
  const prevMap = new Map(prevGroupedData.data);
@@ -584,10 +590,10 @@ class BaseMark extends grammar_item_1.GrammarItem {
584
590
  this._graphicMap.delete(g.context.uniqueKey), g.parent && g.parent.removeChild(g),
585
591
  g.release();
586
592
  }));
587
- const graphicCount = newGraphics.length;
588
- newGraphics.forEach(((g, index) => {
593
+ const graphicCount = allGraphics.length;
594
+ allGraphics.forEach(((g, index) => {
589
595
  g.context.graphicCount = graphicCount, g.context.graphicIndex = index;
590
- })), this._dataByKey = newGroupedData, this._graphics = newGraphics, this.needClear = !0;
596
+ })), this._dataByKey = newGroupedData, this._graphics = allGraphics, this.needClear = !0;
591
597
  }
592
598
  _runEncoderOfGraphic(styles, g, attrs = {}) {
593
599
  return (0, common_1.runEncoder)(styles, g.context.data[0], attrs);
@@ -631,10 +637,8 @@ class BaseMark extends grammar_item_1.GrammarItem {
631
637
  var _a;
632
638
  const finalAttrs = g.context.finalAttrs, hasStateAnimation = this.hasAnimationByState(g.context.animationState);
633
639
  if (g.setAttributes) {
634
- const prevAttrs = g.getAttributes(!0), diffAttrs = {};
635
- Object.keys(finalAttrs).forEach((key => {
636
- prevAttrs[key] !== finalAttrs[key] && (diffAttrs[key] = finalAttrs[key]);
637
- })), g.context.diffAttrs = diffAttrs, g.context.reusing ? (g.context.lastAttrs = g.attribute,
640
+ const diffAttrs = (0, mark_2.getDiffAttributesOfGraphic)(g, finalAttrs);
641
+ g.context.diffAttrs = diffAttrs, g.context.reusing ? (g.context.lastAttrs = g.attribute,
638
642
  g.initAttributes({}), g.context.reusing = !1) : hasStateAnimation || (hasAnimation ? g.setAttributesAndPreventAnimate(diffAttrs) : g.setAttributes(diffAttrs)),
639
643
  hasAnimation && g.setFinalAttributes(finalAttrs);
640
644
  } else {
@@ -724,7 +728,7 @@ class BaseMark extends grammar_item_1.GrammarItem {
724
728
  }
725
729
  render() {
726
730
  this.isCommited() && (!this.getVisible() || this._skipBeforeLayouted && this.getCompiler().getLayoutState() === interface_2.LayoutState.before || ((0,
727
- util_3.log)(`render mark: ${this.getProductId()}, type is ${this.type}`), this.renderInner()),
731
+ debug_1.log)(`render mark: ${this.getProductId()}, type is ${this.type}`), this.renderInner()),
728
732
  this.uncommit());
729
733
  }
730
734
  updateMarkState(key) {
@@ -740,7 +744,7 @@ class BaseMark extends grammar_item_1.GrammarItem {
740
744
  this._graphicMap.delete(key), g.parent && g.parent.removeChild(g), g.release && g.release();
741
745
  };
742
746
  this._graphicMap.forEach(((g, key) => {
743
- if (g.context.diffState === enum_1.DiffState.exit && !g.isExiting) if (this.hasAnimationByState("exit")) {
747
+ if (g.context.diffState === enum_1.DiffState.exit && !g.isExiting) if (g.context.animationState === enum_1.DiffState.exit && this.hasAnimationByState("exit")) {
744
748
  g.isExiting = !0;
745
749
  const animationConfig = this.getAnimationConfig();
746
750
  if (animationConfig.exit && animationConfig.exit.length) {
@@ -850,9 +854,7 @@ class BaseMark extends grammar_item_1.GrammarItem {
850
854
  (null === (_a = this.renderContext) || void 0 === _a ? void 0 : _a.beforeTransformProgressive) ? this._runBeforeProgressive() : this.renderContext.progressive && this._runProgressiveStep();
851
855
  }
852
856
  updateAnimationState(callback) {
853
- this._graphics && this._graphics.length && this._graphics.forEach((g => {
854
- g.context.animationState = callback(g);
855
- }));
857
+ this._aniamtionStateCallback = callback;
856
858
  }
857
859
  hasAnimationByState(state) {
858
860
  if (!state || !this._animationConfig || !this._animationConfig[state]) return !1;