@visactor/vchart 2.0.5-alpha.6 → 2.0.5-alpha.8

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 (42) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.es.js +49 -9
  3. package/build/index.js +49 -9
  4. package/build/index.min.js +2 -2
  5. package/build/tsconfig.tsbuildinfo +1 -1
  6. package/cjs/component/axis/cartesian/axis.d.ts +6 -0
  7. package/cjs/component/axis/cartesian/axis.js +3 -0
  8. package/cjs/component/axis/cartesian/axis.js.map +1 -1
  9. package/cjs/component/crosshair/base.d.ts +2 -1
  10. package/cjs/component/crosshair/base.js +26 -9
  11. package/cjs/component/crosshair/base.js.map +1 -1
  12. package/cjs/component/crosshair/cartesian.js +15 -3
  13. package/cjs/component/crosshair/cartesian.js.map +1 -1
  14. package/cjs/core/expression-function.js +1 -1
  15. package/cjs/core/factory.js +1 -1
  16. package/cjs/core/index.d.ts +1 -1
  17. package/cjs/core/index.js +2 -2
  18. package/cjs/core/index.js.map +1 -1
  19. package/cjs/core/instance-manager.js +1 -1
  20. package/cjs/env/env.js +1 -1
  21. package/cjs/env/index.js +1 -1
  22. package/cjs/event/bubble.js +1 -1
  23. package/cjs/event/event-dispatcher.js +1 -1
  24. package/esm/component/axis/cartesian/axis.d.ts +6 -0
  25. package/esm/component/axis/cartesian/axis.js +3 -0
  26. package/esm/component/axis/cartesian/axis.js.map +1 -1
  27. package/esm/component/crosshair/base.d.ts +2 -1
  28. package/esm/component/crosshair/base.js +26 -9
  29. package/esm/component/crosshair/base.js.map +1 -1
  30. package/esm/component/crosshair/cartesian.js +15 -3
  31. package/esm/component/crosshair/cartesian.js.map +1 -1
  32. package/esm/core/expression-function.js +1 -1
  33. package/esm/core/factory.js +1 -1
  34. package/esm/core/index.d.ts +1 -1
  35. package/esm/core/index.js +2 -2
  36. package/esm/core/index.js.map +1 -1
  37. package/esm/core/instance-manager.js +1 -1
  38. package/esm/env/env.js +1 -1
  39. package/esm/env/index.js +1 -1
  40. package/esm/event/bubble.js +1 -1
  41. package/esm/event/event-dispatcher.js +1 -1
  42. package/package.json +4 -4
package/build/index.es.js CHANGED
@@ -58309,7 +58309,7 @@ const lookup = (data, opt) => {
58309
58309
  });
58310
58310
  };
58311
58311
 
58312
- const version = "2.0.5-alpha.3";
58312
+ const version = "2.0.5-alpha.6";
58313
58313
 
58314
58314
  const addVChartProperty = (data, op) => {
58315
58315
  const context = op.beforeCall();
@@ -63124,6 +63124,9 @@ class CartesianAxis extends AxisComponent {
63124
63124
  getScales() {
63125
63125
  return this._scales;
63126
63126
  }
63127
+ getInnerOffset() {
63128
+ return this._innerOffset;
63129
+ }
63127
63130
  constructor(spec, options) {
63128
63131
  super(spec, options);
63129
63132
  this.type = ComponentTypeEnum.cartesianAxis;
@@ -91705,7 +91708,7 @@ class BaseCrossHair extends BaseComponent {
91705
91708
  return;
91706
91709
  }
91707
91710
  this.clearOutEvent();
91708
- this.hide();
91711
+ this.hideCrosshair();
91709
91712
  };
91710
91713
  this._handleTooltipShow = (params) => {
91711
91714
  const tooltipData = params.tooltipData;
@@ -91724,10 +91727,12 @@ class BaseCrossHair extends BaseComponent {
91724
91727
  this._layoutCrosshair(x, y, tooltipData, params.activeType);
91725
91728
  const components = this._getNeedClearVRenderComponents();
91726
91729
  this._hasActive = components.some(comp => comp && comp.attribute.visible !== false);
91730
+ this._renderNextFrame();
91727
91731
  };
91728
91732
  this._handleTooltipHideOrRelease = () => {
91729
91733
  this.clearOutEvent();
91730
- this.hide();
91734
+ this.hideCrosshair();
91735
+ this._renderNextFrame();
91731
91736
  };
91732
91737
  this.enable = true;
91733
91738
  this.showDefault = true;
@@ -91795,17 +91800,20 @@ class BaseCrossHair extends BaseComponent {
91795
91800
  return this._limitBounds;
91796
91801
  }
91797
91802
  _showDefaultCrosshairBySpec() {
91803
+ let hasDefaultCrosshair = false;
91798
91804
  Object.keys(this._stateByField).forEach(field => {
91799
91805
  const fieldSpec = this._spec[field];
91800
91806
  if (fieldSpec && fieldSpec.visible && fieldSpec.defaultSelect) {
91801
91807
  const { axisIndex = 0, datum } = fieldSpec.defaultSelect;
91802
91808
  const axis = this._option.getComponentsByKey('axes').find(c => c.getSpecIndex() === axisIndex);
91803
91809
  if (axis) {
91810
+ hasDefaultCrosshair = true;
91804
91811
  this._stateByField[field].currentValue.clear();
91805
91812
  this._stateByField[field].currentValue.set(axisIndex, { axis, datum });
91806
91813
  }
91807
91814
  }
91808
91815
  });
91816
+ return hasDefaultCrosshair;
91809
91817
  }
91810
91818
  _updateVisibleCrosshair() {
91811
91819
  let hasVisible = false;
@@ -91824,8 +91832,8 @@ class BaseCrossHair extends BaseComponent {
91824
91832
  }
91825
91833
  _showDefaultCrosshair() {
91826
91834
  if (this.showDefault) {
91827
- this._showDefaultCrosshairBySpec();
91828
- this.layoutByValue(false);
91835
+ const hasDefault = this._showDefaultCrosshairBySpec();
91836
+ hasDefault && this.layoutByValue(false);
91829
91837
  }
91830
91838
  else {
91831
91839
  this._updateVisibleCrosshair();
@@ -91936,6 +91944,10 @@ class BaseCrossHair extends BaseComponent {
91936
91944
  this.event.on(ChartEvent.tooltipShow, { source: Event_Source_Type.chart }, this._handleTooltipShow);
91937
91945
  this.event.on(ChartEvent.tooltipRelease, { source: Event_Source_Type.chart }, this._handleTooltipHideOrRelease);
91938
91946
  }
91947
+ _renderNextFrame() {
91948
+ var _a, _b;
91949
+ (_b = (_a = this._option.globalInstance.getStage()) === null || _a === void 0 ? void 0 : _a.renderNextFrame) === null || _b === void 0 ? void 0 : _b.call(_a);
91950
+ }
91939
91951
  _getAxisInfoByField(field) {
91940
91952
  var _a, _b;
91941
91953
  const axesComponents = (_b = (_a = this._option).getComponentsByKey) === null || _b === void 0 ? void 0 : _b.call(_a, 'axes');
@@ -91961,18 +91973,20 @@ class BaseCrossHair extends BaseComponent {
91961
91973
  let y2 = -Infinity;
91962
91974
  const { x: sx, y: sy } = this.getLayoutStartPoint();
91963
91975
  bindingAxesIndex.forEach(idx => {
91976
+ var _a, _b;
91964
91977
  (x1 = Infinity), (y1 = Infinity), (x2 = -Infinity), (y2 = -Infinity);
91965
91978
  const axis = axesComponents.find(axis => axis.getSpecIndex() === idx);
91966
91979
  if (!axis) {
91967
91980
  return;
91968
91981
  }
91982
+ const innerOffset = ((_b = (_a = axis).getInnerOffset) === null || _b === void 0 ? void 0 : _b.call(_a)) || { left: 0, right: 0, top: 0, bottom: 0 };
91969
91983
  const regions = axis.getRegions();
91970
91984
  regions.forEach(r => {
91971
91985
  const { x: regionStartX, y: regionStartY } = r.getLayoutStartPoint();
91972
- x1 = Math.min(x1, regionStartX - sx);
91973
- y1 = Math.min(y1, regionStartY - sy);
91974
- x2 = Math.max(x2, regionStartX + r.getLayoutRect().width - sx);
91975
- y2 = Math.max(y2, regionStartY + r.getLayoutRect().height - sy);
91986
+ x1 = Math.min(x1, regionStartX - sx + innerOffset.left);
91987
+ y1 = Math.min(y1, regionStartY - sy + innerOffset.top);
91988
+ x2 = Math.max(x2, regionStartX + r.getLayoutRect().width - sx - innerOffset.right);
91989
+ y2 = Math.max(y2, regionStartY + r.getLayoutRect().height - sy - innerOffset.bottom);
91976
91990
  });
91977
91991
  map.set(idx, { x1, y1, x2, y2, axis: axis });
91978
91992
  });
@@ -92285,9 +92299,27 @@ class CartesianCrossHair extends BaseCrossHair {
92285
92299
  var _a;
92286
92300
  let x = relativeX;
92287
92301
  let y = relativeY;
92302
+ let tooltipAxisValue;
92303
+ const setTooltipAxisValue = () => {
92304
+ if (!tooltipAxisValue) {
92305
+ return;
92306
+ }
92307
+ const field = isXAxis(tooltipAxisValue.axis.getOrient()) ? 'xField' : 'yField';
92308
+ const { currentValue } = this._stateByField[field];
92309
+ if (!currentValue.has(tooltipAxisValue.axis.getSpecIndex())) {
92310
+ currentValue.clear();
92311
+ }
92312
+ this.setAxisValue(tooltipAxisValue.value, tooltipAxisValue.axis);
92313
+ };
92288
92314
  if (tooltipData && tooltipData.length) {
92289
92315
  if (activeType === 'dimension') {
92290
92316
  const dimensionInfo = tooltipData[0];
92317
+ if ((dimensionInfo === null || dimensionInfo === void 0 ? void 0 : dimensionInfo.axis) && isValid$1(dimensionInfo.value)) {
92318
+ tooltipAxisValue = {
92319
+ axis: dimensionInfo.axis,
92320
+ value: dimensionInfo.value
92321
+ };
92322
+ }
92291
92323
  const datumIndex = dimensionInfo.data.findIndex(dimData => dimData.datum.length > 0);
92292
92324
  let pos;
92293
92325
  if (datumIndex > -1) {
@@ -92314,6 +92346,11 @@ class CartesianCrossHair extends BaseCrossHair {
92314
92346
  this.clearAxisValue();
92315
92347
  const { xAxisMap, yAxisMap } = this._findAllAxisContains(x, y);
92316
92348
  if ((xAxisMap && xAxisMap.size === 0) || (yAxisMap && yAxisMap.size === 0)) {
92349
+ if (tooltipAxisValue) {
92350
+ setTooltipAxisValue();
92351
+ this.layoutByValue(false);
92352
+ return;
92353
+ }
92317
92354
  if (this.enableRemain) {
92318
92355
  return;
92319
92356
  }
@@ -92322,6 +92359,9 @@ class CartesianCrossHair extends BaseCrossHair {
92322
92359
  }
92323
92360
  xAxisMap && xAxisMap.size && this._setAllAxisValues(xAxisMap, { x, y }, 'xField');
92324
92361
  yAxisMap && yAxisMap.size && this._setAllAxisValues(yAxisMap, { x, y }, 'yField');
92362
+ if (tooltipAxisValue) {
92363
+ setTooltipAxisValue();
92364
+ }
92325
92365
  this.layoutByValue();
92326
92366
  }
92327
92367
  layoutByValue(enableRemain) {
package/build/index.js CHANGED
@@ -58315,7 +58315,7 @@
58315
58315
  });
58316
58316
  };
58317
58317
 
58318
- const version = "2.0.5-alpha.3";
58318
+ const version = "2.0.5-alpha.6";
58319
58319
 
58320
58320
  const addVChartProperty = (data, op) => {
58321
58321
  const context = op.beforeCall();
@@ -63130,6 +63130,9 @@
63130
63130
  getScales() {
63131
63131
  return this._scales;
63132
63132
  }
63133
+ getInnerOffset() {
63134
+ return this._innerOffset;
63135
+ }
63133
63136
  constructor(spec, options) {
63134
63137
  super(spec, options);
63135
63138
  this.type = ComponentTypeEnum.cartesianAxis;
@@ -91711,7 +91714,7 @@
91711
91714
  return;
91712
91715
  }
91713
91716
  this.clearOutEvent();
91714
- this.hide();
91717
+ this.hideCrosshair();
91715
91718
  };
91716
91719
  this._handleTooltipShow = (params) => {
91717
91720
  const tooltipData = params.tooltipData;
@@ -91730,10 +91733,12 @@
91730
91733
  this._layoutCrosshair(x, y, tooltipData, params.activeType);
91731
91734
  const components = this._getNeedClearVRenderComponents();
91732
91735
  this._hasActive = components.some(comp => comp && comp.attribute.visible !== false);
91736
+ this._renderNextFrame();
91733
91737
  };
91734
91738
  this._handleTooltipHideOrRelease = () => {
91735
91739
  this.clearOutEvent();
91736
- this.hide();
91740
+ this.hideCrosshair();
91741
+ this._renderNextFrame();
91737
91742
  };
91738
91743
  this.enable = true;
91739
91744
  this.showDefault = true;
@@ -91801,17 +91806,20 @@
91801
91806
  return this._limitBounds;
91802
91807
  }
91803
91808
  _showDefaultCrosshairBySpec() {
91809
+ let hasDefaultCrosshair = false;
91804
91810
  Object.keys(this._stateByField).forEach(field => {
91805
91811
  const fieldSpec = this._spec[field];
91806
91812
  if (fieldSpec && fieldSpec.visible && fieldSpec.defaultSelect) {
91807
91813
  const { axisIndex = 0, datum } = fieldSpec.defaultSelect;
91808
91814
  const axis = this._option.getComponentsByKey('axes').find(c => c.getSpecIndex() === axisIndex);
91809
91815
  if (axis) {
91816
+ hasDefaultCrosshair = true;
91810
91817
  this._stateByField[field].currentValue.clear();
91811
91818
  this._stateByField[field].currentValue.set(axisIndex, { axis, datum });
91812
91819
  }
91813
91820
  }
91814
91821
  });
91822
+ return hasDefaultCrosshair;
91815
91823
  }
91816
91824
  _updateVisibleCrosshair() {
91817
91825
  let hasVisible = false;
@@ -91830,8 +91838,8 @@
91830
91838
  }
91831
91839
  _showDefaultCrosshair() {
91832
91840
  if (this.showDefault) {
91833
- this._showDefaultCrosshairBySpec();
91834
- this.layoutByValue(false);
91841
+ const hasDefault = this._showDefaultCrosshairBySpec();
91842
+ hasDefault && this.layoutByValue(false);
91835
91843
  }
91836
91844
  else {
91837
91845
  this._updateVisibleCrosshair();
@@ -91942,6 +91950,10 @@
91942
91950
  this.event.on(exports.ChartEvent.tooltipShow, { source: Event_Source_Type.chart }, this._handleTooltipShow);
91943
91951
  this.event.on(exports.ChartEvent.tooltipRelease, { source: Event_Source_Type.chart }, this._handleTooltipHideOrRelease);
91944
91952
  }
91953
+ _renderNextFrame() {
91954
+ var _a, _b;
91955
+ (_b = (_a = this._option.globalInstance.getStage()) === null || _a === void 0 ? void 0 : _a.renderNextFrame) === null || _b === void 0 ? void 0 : _b.call(_a);
91956
+ }
91945
91957
  _getAxisInfoByField(field) {
91946
91958
  var _a, _b;
91947
91959
  const axesComponents = (_b = (_a = this._option).getComponentsByKey) === null || _b === void 0 ? void 0 : _b.call(_a, 'axes');
@@ -91967,18 +91979,20 @@
91967
91979
  let y2 = -Infinity;
91968
91980
  const { x: sx, y: sy } = this.getLayoutStartPoint();
91969
91981
  bindingAxesIndex.forEach(idx => {
91982
+ var _a, _b;
91970
91983
  (x1 = Infinity), (y1 = Infinity), (x2 = -Infinity), (y2 = -Infinity);
91971
91984
  const axis = axesComponents.find(axis => axis.getSpecIndex() === idx);
91972
91985
  if (!axis) {
91973
91986
  return;
91974
91987
  }
91988
+ const innerOffset = ((_b = (_a = axis).getInnerOffset) === null || _b === void 0 ? void 0 : _b.call(_a)) || { left: 0, right: 0, top: 0, bottom: 0 };
91975
91989
  const regions = axis.getRegions();
91976
91990
  regions.forEach(r => {
91977
91991
  const { x: regionStartX, y: regionStartY } = r.getLayoutStartPoint();
91978
- x1 = Math.min(x1, regionStartX - sx);
91979
- y1 = Math.min(y1, regionStartY - sy);
91980
- x2 = Math.max(x2, regionStartX + r.getLayoutRect().width - sx);
91981
- y2 = Math.max(y2, regionStartY + r.getLayoutRect().height - sy);
91992
+ x1 = Math.min(x1, regionStartX - sx + innerOffset.left);
91993
+ y1 = Math.min(y1, regionStartY - sy + innerOffset.top);
91994
+ x2 = Math.max(x2, regionStartX + r.getLayoutRect().width - sx - innerOffset.right);
91995
+ y2 = Math.max(y2, regionStartY + r.getLayoutRect().height - sy - innerOffset.bottom);
91982
91996
  });
91983
91997
  map.set(idx, { x1, y1, x2, y2, axis: axis });
91984
91998
  });
@@ -92291,9 +92305,27 @@
92291
92305
  var _a;
92292
92306
  let x = relativeX;
92293
92307
  let y = relativeY;
92308
+ let tooltipAxisValue;
92309
+ const setTooltipAxisValue = () => {
92310
+ if (!tooltipAxisValue) {
92311
+ return;
92312
+ }
92313
+ const field = isXAxis(tooltipAxisValue.axis.getOrient()) ? 'xField' : 'yField';
92314
+ const { currentValue } = this._stateByField[field];
92315
+ if (!currentValue.has(tooltipAxisValue.axis.getSpecIndex())) {
92316
+ currentValue.clear();
92317
+ }
92318
+ this.setAxisValue(tooltipAxisValue.value, tooltipAxisValue.axis);
92319
+ };
92294
92320
  if (tooltipData && tooltipData.length) {
92295
92321
  if (activeType === 'dimension') {
92296
92322
  const dimensionInfo = tooltipData[0];
92323
+ if ((dimensionInfo === null || dimensionInfo === void 0 ? void 0 : dimensionInfo.axis) && isValid$1(dimensionInfo.value)) {
92324
+ tooltipAxisValue = {
92325
+ axis: dimensionInfo.axis,
92326
+ value: dimensionInfo.value
92327
+ };
92328
+ }
92297
92329
  const datumIndex = dimensionInfo.data.findIndex(dimData => dimData.datum.length > 0);
92298
92330
  let pos;
92299
92331
  if (datumIndex > -1) {
@@ -92320,6 +92352,11 @@
92320
92352
  this.clearAxisValue();
92321
92353
  const { xAxisMap, yAxisMap } = this._findAllAxisContains(x, y);
92322
92354
  if ((xAxisMap && xAxisMap.size === 0) || (yAxisMap && yAxisMap.size === 0)) {
92355
+ if (tooltipAxisValue) {
92356
+ setTooltipAxisValue();
92357
+ this.layoutByValue(false);
92358
+ return;
92359
+ }
92323
92360
  if (this.enableRemain) {
92324
92361
  return;
92325
92362
  }
@@ -92328,6 +92365,9 @@
92328
92365
  }
92329
92366
  xAxisMap && xAxisMap.size && this._setAllAxisValues(xAxisMap, { x, y }, 'xField');
92330
92367
  yAxisMap && yAxisMap.size && this._setAllAxisValues(yAxisMap, { x, y }, 'yField');
92368
+ if (tooltipAxisValue) {
92369
+ setTooltipAxisValue();
92370
+ }
92331
92371
  this.layoutByValue();
92332
92372
  }
92333
92373
  layoutByValue(enableRemain) {