@visactor/vchart 2.0.10-alpha.1 → 2.0.11-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 (48) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.es.js +46 -7
  3. package/build/index.js +46 -7
  4. package/build/index.min.js +2 -2
  5. package/build/tsconfig.tsbuildinfo +1 -1
  6. package/cjs/chart/base/base-chart.d.ts +2 -0
  7. package/cjs/chart/base/base-chart.js +18 -3
  8. package/cjs/chart/base/base-chart.js.map +1 -1
  9. package/cjs/chart/interface/chart.d.ts +2 -0
  10. package/cjs/chart/interface/chart.js.map +1 -1
  11. package/cjs/chart/interface/common.d.ts +5 -1
  12. package/cjs/chart/interface/common.js.map +1 -1
  13. package/cjs/component/crosshair/base.js +2 -0
  14. package/cjs/component/crosshair/base.js.map +1 -1
  15. package/cjs/component/tooltip/tooltip.js +6 -2
  16. package/cjs/component/tooltip/tooltip.js.map +1 -1
  17. package/cjs/core/index.d.ts +1 -1
  18. package/cjs/core/index.js +1 -1
  19. package/cjs/core/index.js.map +1 -1
  20. package/cjs/core/vchart.d.ts +2 -0
  21. package/cjs/core/vchart.js +6 -1
  22. package/cjs/core/vchart.js.map +1 -1
  23. package/cjs/model/interface.d.ts +4 -0
  24. package/cjs/model/interface.js.map +1 -1
  25. package/cjs/typings/spec/common.d.ts +5 -0
  26. package/cjs/typings/spec/common.js.map +1 -1
  27. package/esm/chart/base/base-chart.d.ts +2 -0
  28. package/esm/chart/base/base-chart.js +17 -3
  29. package/esm/chart/base/base-chart.js.map +1 -1
  30. package/esm/chart/interface/chart.d.ts +2 -0
  31. package/esm/chart/interface/chart.js.map +1 -1
  32. package/esm/chart/interface/common.d.ts +5 -1
  33. package/esm/chart/interface/common.js.map +1 -1
  34. package/esm/component/crosshair/base.js +2 -0
  35. package/esm/component/crosshair/base.js.map +1 -1
  36. package/esm/component/tooltip/tooltip.js +6 -2
  37. package/esm/component/tooltip/tooltip.js.map +1 -1
  38. package/esm/core/index.d.ts +1 -1
  39. package/esm/core/index.js +1 -1
  40. package/esm/core/index.js.map +1 -1
  41. package/esm/core/vchart.d.ts +2 -0
  42. package/esm/core/vchart.js +6 -1
  43. package/esm/core/vchart.js.map +1 -1
  44. package/esm/model/interface.d.ts +4 -0
  45. package/esm/model/interface.js.map +1 -1
  46. package/esm/typings/spec/common.d.ts +5 -0
  47. package/esm/typings/spec/common.js.map +1 -1
  48. package/package.json +8 -8
package/build/index.es.js CHANGED
@@ -61218,6 +61218,10 @@ class VChart {
61218
61218
  var _a;
61219
61219
  return (_a = this._chart) === null || _a === void 0 ? void 0 : _a.setDimensionIndex(value, opt);
61220
61220
  }
61221
+ showCrosshair(cb) {
61222
+ var _a;
61223
+ (_a = this._chart) === null || _a === void 0 ? void 0 : _a.showCrosshair(cb);
61224
+ }
61221
61225
  stopAnimation() {
61222
61226
  var _a;
61223
61227
  (_a = this.getStage()) === null || _a === void 0 ? void 0 : _a.stopAnimation(true);
@@ -61408,7 +61412,8 @@ class VChart {
61408
61412
  getSpecInfo: () => { var _a; return (_a = this._specInfo) !== null && _a !== void 0 ? _a : {}; },
61409
61413
  layout: this._option.layout,
61410
61414
  onError: this._onError,
61411
- disableTriggerEvent: this._option.disableTriggerEvent === true
61415
+ disableTriggerEvent: this._option.disableTriggerEvent === true,
61416
+ componentShowContent: this._option.componentShowContent
61412
61417
  };
61413
61418
  }
61414
61419
  }
@@ -61527,7 +61532,7 @@ const lookup = (data, opt) => {
61527
61532
  });
61528
61533
  };
61529
61534
 
61530
- const version = "2.0.10-alpha.1";
61535
+ const version = "2.0.11-alpha.0";
61531
61536
 
61532
61537
  const addVChartProperty = (data, op) => {
61533
61538
  const context = op.beforeCall();
@@ -69363,7 +69368,7 @@ class BaseChart extends CompilableBase {
69363
69368
  _setModelOption() {
69364
69369
  }
69365
69370
  constructor(spec, option) {
69366
- var _a, _b, _c;
69371
+ var _a, _b, _c, _d;
69367
69372
  super(option);
69368
69373
  this.type = 'chart';
69369
69374
  this.id = createID();
@@ -69494,7 +69499,7 @@ class BaseChart extends CompilableBase {
69494
69499
  this._event = new Event$1(option.eventDispatcher, option.mode);
69495
69500
  this._dataSet = option.dataSet;
69496
69501
  this._chartData = new ChartData(this._dataSet);
69497
- this._modelOption = Object.assign(Object.assign({}, option), { mode: this._option.mode, map: this._idMap, getChartLayoutRect: () => this._layoutRect, getChartViewRect: () => this._viewRect, getChart: () => this, globalScale: this._globalScale, onError: (_b = this._option) === null || _b === void 0 ? void 0 : _b.onError, disableTriggerEvent: ((_c = this._option) === null || _c === void 0 ? void 0 : _c.disableTriggerEvent) === true, getSeriesData: this._chartData.getSeriesData.bind(this._chartData), dispatchEvent: (eType, params) => this._option.globalInstance.event.emit(eType, params) });
69502
+ this._modelOption = Object.assign(Object.assign({}, option), { mode: this._option.mode, map: this._idMap, getChartLayoutRect: () => this._layoutRect, getChartViewRect: () => this._viewRect, getChart: () => this, globalScale: this._globalScale, onError: (_b = this._option) === null || _b === void 0 ? void 0 : _b.onError, disableTriggerEvent: ((_c = this._option) === null || _c === void 0 ? void 0 : _c.disableTriggerEvent) === true, componentShowContent: (_d = this._option) === null || _d === void 0 ? void 0 : _d.componentShowContent, getSeriesData: this._chartData.getSeriesData.bind(this._chartData), dispatchEvent: (eType, params) => this._option.globalInstance.event.emit(eType, params) });
69498
69503
  if (this._setModelOption) {
69499
69504
  this._setModelOption();
69500
69505
  }
@@ -70276,10 +70281,12 @@ class BaseChart extends CompilableBase {
70276
70281
  }
70277
70282
  });
70278
70283
  const isUnableValue = isNil$1(value) || !dimensionInfo || dimensionInfo.every(d => isDiscrete(d.axis.getScale().type) && isNil$1(d.index));
70284
+ const isUnableTooltip = isUnableValue ||
70285
+ dimensionInfo.every(d => isDiscrete(d.axis.getScale().type) && d.data.every(_data => _data.datum.length === 0));
70279
70286
  if (opt.tooltip !== false) {
70280
70287
  const tooltip = this.getComponentsByType(ComponentTypeEnum.tooltip)[0];
70281
70288
  if (tooltip === null || tooltip === void 0 ? void 0 : tooltip.getVisible()) {
70282
- if (isUnableValue) {
70289
+ if (isUnableValue || isUnableTooltip) {
70283
70290
  (_b = (_a = tooltip).hideTooltip) === null || _b === void 0 ? void 0 : _b.call(_a);
70284
70291
  }
70285
70292
  else {
@@ -70309,6 +70316,25 @@ class BaseChart extends CompilableBase {
70309
70316
  }
70310
70317
  }
70311
70318
  }
70319
+ showCrosshair(cb) {
70320
+ var _a;
70321
+ const crosshair = (_a = this.getComponentsByType(ComponentTypeEnum.cartesianCrosshair)[0]) !== null && _a !== void 0 ? _a : this.getComponentsByType(ComponentTypeEnum.polarCrosshair)[0];
70322
+ if (!crosshair) {
70323
+ return;
70324
+ }
70325
+ const axes = this.getComponentsByKey('axes');
70326
+ const dimInfo = [];
70327
+ axes.forEach(axis => {
70328
+ const value = cb(axis);
70329
+ if (value !== false) {
70330
+ dimInfo.push({
70331
+ axis,
70332
+ value
70333
+ });
70334
+ }
70335
+ });
70336
+ crosshair.showCrosshair(dimInfo);
70337
+ }
70312
70338
  getColorScheme() {
70313
70339
  var _a, _b;
70314
70340
  return (_b = (_a = this._option).getTheme) === null || _b === void 0 ? void 0 : _b.call(_a, 'colorScheme');
@@ -95877,7 +95903,16 @@ class Tooltip extends BaseComponent {
95877
95903
  }
95878
95904
  };
95879
95905
  this._showTooltipByMouseEvent = (activeType, mouseEventData, params, isClick, useCache) => {
95880
- var _a;
95906
+ var _a, _b;
95907
+ if ((_a = this._option) === null || _a === void 0 ? void 0 : _a.componentShowContent) {
95908
+ if (this._option.componentShowContent.tooltip === false) {
95909
+ return false;
95910
+ }
95911
+ if (isObject$2(this._option.componentShowContent.tooltip) &&
95912
+ this._option.componentShowContent.tooltip[activeType] === false) {
95913
+ return false;
95914
+ }
95915
+ }
95881
95916
  const processor = this.processor[activeType];
95882
95917
  if (!processor.shouldHandleTooltip(params, mouseEventData.tooltipInfo[activeType])) {
95883
95918
  return false;
@@ -95910,7 +95945,7 @@ class Tooltip extends BaseComponent {
95910
95945
  }, this._spec.hideTimer);
95911
95946
  }
95912
95947
  }
95913
- const vchart = (_a = this._option) === null || _a === void 0 ? void 0 : _a.globalInstance;
95948
+ const vchart = (_b = this._option) === null || _b === void 0 ? void 0 : _b.globalInstance;
95914
95949
  if (success && VChart.globalConfig.uniqueTooltip && vchart) {
95915
95950
  VChart.hideTooltip(vchart.id);
95916
95951
  }
@@ -96490,6 +96525,10 @@ class BaseCrossHair extends BaseComponent {
96490
96525
  }
96491
96526
  }
96492
96527
  _registerEvent(eventName, isOut, click) {
96528
+ var _a;
96529
+ if (!isOut && ((_a = this._option.componentShowContent) === null || _a === void 0 ? void 0 : _a.crosshair) === false) {
96530
+ return;
96531
+ }
96493
96532
  const handler = isOut ? this._handleOutEvent : click ? this._handleClickInEvent : this._handleHoverInEvent;
96494
96533
  const cfg = isOut ? { level: Event_Bubble_Level.chart } : { source: Event_Source_Type.chart };
96495
96534
  if (isArray$1(eventName)) {
package/build/index.js CHANGED
@@ -61224,6 +61224,10 @@
61224
61224
  var _a;
61225
61225
  return (_a = this._chart) === null || _a === void 0 ? void 0 : _a.setDimensionIndex(value, opt);
61226
61226
  }
61227
+ showCrosshair(cb) {
61228
+ var _a;
61229
+ (_a = this._chart) === null || _a === void 0 ? void 0 : _a.showCrosshair(cb);
61230
+ }
61227
61231
  stopAnimation() {
61228
61232
  var _a;
61229
61233
  (_a = this.getStage()) === null || _a === void 0 ? void 0 : _a.stopAnimation(true);
@@ -61414,7 +61418,8 @@
61414
61418
  getSpecInfo: () => { var _a; return (_a = this._specInfo) !== null && _a !== void 0 ? _a : {}; },
61415
61419
  layout: this._option.layout,
61416
61420
  onError: this._onError,
61417
- disableTriggerEvent: this._option.disableTriggerEvent === true
61421
+ disableTriggerEvent: this._option.disableTriggerEvent === true,
61422
+ componentShowContent: this._option.componentShowContent
61418
61423
  };
61419
61424
  }
61420
61425
  }
@@ -61533,7 +61538,7 @@
61533
61538
  });
61534
61539
  };
61535
61540
 
61536
- const version = "2.0.10-alpha.1";
61541
+ const version = "2.0.11-alpha.0";
61537
61542
 
61538
61543
  const addVChartProperty = (data, op) => {
61539
61544
  const context = op.beforeCall();
@@ -69369,7 +69374,7 @@
69369
69374
  _setModelOption() {
69370
69375
  }
69371
69376
  constructor(spec, option) {
69372
- var _a, _b, _c;
69377
+ var _a, _b, _c, _d;
69373
69378
  super(option);
69374
69379
  this.type = 'chart';
69375
69380
  this.id = createID();
@@ -69500,7 +69505,7 @@
69500
69505
  this._event = new Event$1(option.eventDispatcher, option.mode);
69501
69506
  this._dataSet = option.dataSet;
69502
69507
  this._chartData = new ChartData(this._dataSet);
69503
- this._modelOption = Object.assign(Object.assign({}, option), { mode: this._option.mode, map: this._idMap, getChartLayoutRect: () => this._layoutRect, getChartViewRect: () => this._viewRect, getChart: () => this, globalScale: this._globalScale, onError: (_b = this._option) === null || _b === void 0 ? void 0 : _b.onError, disableTriggerEvent: ((_c = this._option) === null || _c === void 0 ? void 0 : _c.disableTriggerEvent) === true, getSeriesData: this._chartData.getSeriesData.bind(this._chartData), dispatchEvent: (eType, params) => this._option.globalInstance.event.emit(eType, params) });
69508
+ this._modelOption = Object.assign(Object.assign({}, option), { mode: this._option.mode, map: this._idMap, getChartLayoutRect: () => this._layoutRect, getChartViewRect: () => this._viewRect, getChart: () => this, globalScale: this._globalScale, onError: (_b = this._option) === null || _b === void 0 ? void 0 : _b.onError, disableTriggerEvent: ((_c = this._option) === null || _c === void 0 ? void 0 : _c.disableTriggerEvent) === true, componentShowContent: (_d = this._option) === null || _d === void 0 ? void 0 : _d.componentShowContent, getSeriesData: this._chartData.getSeriesData.bind(this._chartData), dispatchEvent: (eType, params) => this._option.globalInstance.event.emit(eType, params) });
69504
69509
  if (this._setModelOption) {
69505
69510
  this._setModelOption();
69506
69511
  }
@@ -70282,10 +70287,12 @@
70282
70287
  }
70283
70288
  });
70284
70289
  const isUnableValue = isNil$1(value) || !dimensionInfo || dimensionInfo.every(d => isDiscrete(d.axis.getScale().type) && isNil$1(d.index));
70290
+ const isUnableTooltip = isUnableValue ||
70291
+ dimensionInfo.every(d => isDiscrete(d.axis.getScale().type) && d.data.every(_data => _data.datum.length === 0));
70285
70292
  if (opt.tooltip !== false) {
70286
70293
  const tooltip = this.getComponentsByType(ComponentTypeEnum.tooltip)[0];
70287
70294
  if (tooltip === null || tooltip === void 0 ? void 0 : tooltip.getVisible()) {
70288
- if (isUnableValue) {
70295
+ if (isUnableValue || isUnableTooltip) {
70289
70296
  (_b = (_a = tooltip).hideTooltip) === null || _b === void 0 ? void 0 : _b.call(_a);
70290
70297
  }
70291
70298
  else {
@@ -70315,6 +70322,25 @@
70315
70322
  }
70316
70323
  }
70317
70324
  }
70325
+ showCrosshair(cb) {
70326
+ var _a;
70327
+ const crosshair = (_a = this.getComponentsByType(ComponentTypeEnum.cartesianCrosshair)[0]) !== null && _a !== void 0 ? _a : this.getComponentsByType(ComponentTypeEnum.polarCrosshair)[0];
70328
+ if (!crosshair) {
70329
+ return;
70330
+ }
70331
+ const axes = this.getComponentsByKey('axes');
70332
+ const dimInfo = [];
70333
+ axes.forEach(axis => {
70334
+ const value = cb(axis);
70335
+ if (value !== false) {
70336
+ dimInfo.push({
70337
+ axis,
70338
+ value
70339
+ });
70340
+ }
70341
+ });
70342
+ crosshair.showCrosshair(dimInfo);
70343
+ }
70318
70344
  getColorScheme() {
70319
70345
  var _a, _b;
70320
70346
  return (_b = (_a = this._option).getTheme) === null || _b === void 0 ? void 0 : _b.call(_a, 'colorScheme');
@@ -95883,7 +95909,16 @@
95883
95909
  }
95884
95910
  };
95885
95911
  this._showTooltipByMouseEvent = (activeType, mouseEventData, params, isClick, useCache) => {
95886
- var _a;
95912
+ var _a, _b;
95913
+ if ((_a = this._option) === null || _a === void 0 ? void 0 : _a.componentShowContent) {
95914
+ if (this._option.componentShowContent.tooltip === false) {
95915
+ return false;
95916
+ }
95917
+ if (isObject$2(this._option.componentShowContent.tooltip) &&
95918
+ this._option.componentShowContent.tooltip[activeType] === false) {
95919
+ return false;
95920
+ }
95921
+ }
95887
95922
  const processor = this.processor[activeType];
95888
95923
  if (!processor.shouldHandleTooltip(params, mouseEventData.tooltipInfo[activeType])) {
95889
95924
  return false;
@@ -95916,7 +95951,7 @@
95916
95951
  }, this._spec.hideTimer);
95917
95952
  }
95918
95953
  }
95919
- const vchart = (_a = this._option) === null || _a === void 0 ? void 0 : _a.globalInstance;
95954
+ const vchart = (_b = this._option) === null || _b === void 0 ? void 0 : _b.globalInstance;
95920
95955
  if (success && VChart.globalConfig.uniqueTooltip && vchart) {
95921
95956
  VChart.hideTooltip(vchart.id);
95922
95957
  }
@@ -96496,6 +96531,10 @@
96496
96531
  }
96497
96532
  }
96498
96533
  _registerEvent(eventName, isOut, click) {
96534
+ var _a;
96535
+ if (!isOut && ((_a = this._option.componentShowContent) === null || _a === void 0 ? void 0 : _a.crosshair) === false) {
96536
+ return;
96537
+ }
96499
96538
  const handler = isOut ? this._handleOutEvent : click ? this._handleClickInEvent : this._handleHoverInEvent;
96500
96539
  const cfg = isOut ? { level: Event_Bubble_Level.chart } : { source: Event_Source_Type.chart };
96501
96540
  if (isArray$1(eventName)) {