@visactor/vchart 1.3.0-beta.3 → 1.3.0-beta.5

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 (37) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.js +112 -64
  3. package/build/index.min.js +2 -2
  4. package/build/tsconfig.tsbuildinfo +1 -1
  5. package/cjs/component/tooltip/tooltip.js +4 -1
  6. package/cjs/component/tooltip/tooltip.js.map +1 -1
  7. package/cjs/core/index.d.ts +1 -1
  8. package/cjs/core/index.js +1 -1
  9. package/cjs/core/index.js.map +1 -1
  10. package/cjs/core/interface.d.ts +3 -0
  11. package/cjs/core/interface.js.map +1 -1
  12. package/cjs/core/vchart.d.ts +3 -0
  13. package/cjs/core/vchart.js +12 -0
  14. package/cjs/core/vchart.js.map +1 -1
  15. package/cjs/event/events/dimension/dimension-click.d.ts +1 -3
  16. package/cjs/event/events/dimension/dimension-click.js +9 -10
  17. package/cjs/event/events/dimension/dimension-click.js.map +1 -1
  18. package/cjs/event/events/dimension/dimension-hover.d.ts +2 -3
  19. package/cjs/event/events/dimension/dimension-hover.js +26 -17
  20. package/cjs/event/events/dimension/dimension-hover.js.map +1 -1
  21. package/esm/component/tooltip/tooltip.js +4 -1
  22. package/esm/component/tooltip/tooltip.js.map +1 -1
  23. package/esm/core/index.d.ts +1 -1
  24. package/esm/core/index.js +1 -1
  25. package/esm/core/index.js.map +1 -1
  26. package/esm/core/interface.d.ts +3 -0
  27. package/esm/core/interface.js.map +1 -1
  28. package/esm/core/vchart.d.ts +3 -0
  29. package/esm/core/vchart.js +12 -0
  30. package/esm/core/vchart.js.map +1 -1
  31. package/esm/event/events/dimension/dimension-click.d.ts +1 -3
  32. package/esm/event/events/dimension/dimension-click.js +9 -10
  33. package/esm/event/events/dimension/dimension-click.js.map +1 -1
  34. package/esm/event/events/dimension/dimension-hover.d.ts +2 -3
  35. package/esm/event/events/dimension/dimension-hover.js +25 -16
  36. package/esm/event/events/dimension/dimension-hover.js.map +1 -1
  37. package/package.json +1 -1
package/build/index.js CHANGED
@@ -7514,11 +7514,12 @@
7514
7514
  }
7515
7515
  parse(data, options) {
7516
7516
  let emit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
7517
+ var _a;
7517
7518
  this.isRunning = !0, emit && this.target.emit("beforeParse", []);
7518
7519
  const cloneData = this.cloneParseData(data, options);
7519
- if (options) {
7520
+ if (null == options ? void 0 : options.type) {
7520
7521
  this.parseOption = options, options = cloneDeep(options);
7521
- const parserData = this.dataSet.getParser(options.type || "bytejson")(cloneData, options.options, this);
7522
+ const parserData = (null !== (_a = this.dataSet.getParser(options.type)) && void 0 !== _a ? _a : this.dataSet.getParser("bytejson"))(cloneData, options.options, this);
7522
7523
  this.rawData = cloneData, this.parserData = parserData, this.history && this.historyData.push(cloneData, parserData), this.latestData = parserData;
7523
7524
  } else this.parserData = cloneData, this.rawData = cloneData, this.history && this.historyData.push(cloneData), this.latestData = cloneData;
7524
7525
  return this.isRunning = !1, emit && this.target.emit("afterParse", []), this;
@@ -7599,8 +7600,8 @@
7599
7600
  this._diffRank = next;
7600
7601
  }
7601
7602
  cloneParseData(data, options) {
7602
- let clone = !0;
7603
- return (data instanceof DataView || !1 === (null == options ? void 0 : options.clone)) && (clone = !1), clone ? data : cloneDeep(data);
7603
+ let clone = !1;
7604
+ return data instanceof DataView || !0 !== (null == options ? void 0 : options.clone) || (clone = !0), clone ? cloneDeep(data) : data;
7604
7605
  }
7605
7606
  parseNewData(data, options) {
7606
7607
  this.parse(data, options || this.parseOption), this.reRunAllTransform();
@@ -26502,6 +26503,7 @@
26502
26503
  if (heightLimit > 0 && (lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1)), lineClamp && (lineCountLimit = Math.min(lineCountLimit, lineClamp)), "number" == typeof maxLineWidth && maxLineWidth !== 1 / 0) {
26503
26504
  if (maxLineWidth > 0) for (let i = 0; i < lines.length; i++) {
26504
26505
  const str = lines[i];
26506
+ let needCut = !0;
26505
26507
  if (i === lineCountLimit - 1) {
26506
26508
  const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis);
26507
26509
  linesLayout.push({
@@ -26511,14 +26513,17 @@
26511
26513
  break;
26512
26514
  }
26513
26515
  const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth);
26514
- if ("" !== str && "" === clip.str) if (ellipsis) {
26515
- const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis);
26516
- clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
26517
- } else clip.str = "", clip.width = 0;
26516
+ if ("" !== str && "" === clip.str) {
26517
+ if (ellipsis) {
26518
+ const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis);
26519
+ clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
26520
+ } else clip.str = "", clip.width = 0;
26521
+ needCut = !1;
26522
+ }
26518
26523
  if (linesLayout.push({
26519
26524
  str: clip.str,
26520
26525
  width: clip.width
26521
- }), clip.str.length === str.length) ;else {
26526
+ }), clip.str.length === str.length) ;else if (needCut) {
26522
26527
  const newStr = str.substring(clip.str.length);
26523
26528
  lines.splice(i + 1, 0, newStr);
26524
26529
  }
@@ -46208,13 +46213,31 @@
46208
46213
  }(IMarkPointItemPosition || (IMarkPointItemPosition = {}));
46209
46214
 
46210
46215
  class Marker extends AbstractComponent {
46216
+ _initContainer() {
46217
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
46218
+ const groupClip = createGroup(Object.assign(Object.assign({}, null === (_a = this.attribute) || void 0 === _a ? void 0 : _a.clipRange), {
46219
+ clip: null !== (_c = isValid(null === (_b = this.attribute) || void 0 === _b ? void 0 : _b.clipRange)) && void 0 !== _c && _c
46220
+ }));
46221
+ groupClip.name = "marker-container";
46222
+ const group = createGroup({
46223
+ x: -(null !== (_f = null === (_e = null === (_d = this.attribute) || void 0 === _d ? void 0 : _d.clipRange) || void 0 === _e ? void 0 : _e.x) && void 0 !== _f ? _f : 0),
46224
+ y: -(null !== (_j = null === (_h = null === (_g = this.attribute) || void 0 === _g ? void 0 : _g.clipRange) || void 0 === _h ? void 0 : _h.y) && void 0 !== _j ? _j : 0)
46225
+ });
46226
+ groupClip.add(group), this._containerClip = groupClip, this.add(groupClip), this._container = group;
46227
+ }
46228
+ _updateContainer() {
46229
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
46230
+ this._containerClip.setAttributes(Object.assign(Object.assign({}, null === (_a = this.attribute) || void 0 === _a ? void 0 : _a.clipRange), {
46231
+ clip: null !== (_c = isValid(null === (_b = this.attribute) || void 0 === _b ? void 0 : _b.clipRange)) && void 0 !== _c && _c
46232
+ })), this._container.setAttributes({
46233
+ x: -(null !== (_f = null === (_e = null === (_d = this.attribute) || void 0 === _d ? void 0 : _d.clipRange) || void 0 === _e ? void 0 : _e.x) && void 0 !== _f ? _f : 0),
46234
+ y: -(null !== (_j = null === (_h = null === (_g = this.attribute) || void 0 === _g ? void 0 : _g.clipRange) || void 0 === _h ? void 0 : _h.y) && void 0 !== _j ? _j : 0)
46235
+ });
46236
+ }
46211
46237
  render() {
46212
46238
  var _a, _b;
46213
46239
  const markerVisible = null === (_a = this.attribute.visible) || void 0 === _a || _a;
46214
- if (null !== (_b = this.attribute.interactive) && void 0 !== _b && _b || (this.setAttribute("pickable", !1), this.setAttribute("childrenPickable", !1)), markerVisible) if (this._container) this.updateMarker();else {
46215
- const group = createGroup({});
46216
- group.name = "marker-container", this.add(group), this._container = group, this.initMarker(group);
46217
- }
46240
+ null !== (_b = this.attribute.interactive) && void 0 !== _b && _b || (this.setAttribute("pickable", !1), this.setAttribute("childrenPickable", !1)), markerVisible && (this._containerClip ? (this._updateContainer(), this.updateMarker()) : (this._initContainer(), this.initMarker(this._container)));
46218
46241
  }
46219
46242
  }
46220
46243
 
@@ -46891,7 +46914,7 @@
46891
46914
  }(LegendStateValue || (LegendStateValue = {}));
46892
46915
  var LegendEvent;
46893
46916
  !function (LegendEvent) {
46894
- LegendEvent.legendItemHover = "legendItemHover", LegendEvent.legendItemUnHover = "legendItemUnHover", LegendEvent.legendItemClick = "legendItemClick";
46917
+ LegendEvent.legendItemHover = "legendItemHover", LegendEvent.legendItemUnHover = "legendItemUnHover", LegendEvent.legendItemClick = "legendItemClick", LegendEvent.legendItemAttributeUpdate = "legendItemAttributeUpdate";
46895
46918
  }(LegendEvent || (LegendEvent = {}));
46896
46919
  var LEGEND_ELEMENT_NAME;
46897
46920
  !function (LEGEND_ELEMENT_NAME) {
@@ -46990,11 +47013,12 @@
46990
47013
  const target = e.target;
46991
47014
  if (null === (_a = null == target ? void 0 : target.name) || void 0 === _a ? void 0 : _a.startsWith(LEGEND_ELEMENT_NAME.item)) {
46992
47015
  const legendItem = target.delegate;
46993
- legendItem.removeState(LegendStateValue.unSelectedHover), legendItem.removeState(LegendStateValue.selectedHover), legendItem.getChildren()[0].getChildren().forEach(child => {
46994
- child.removeState(LegendStateValue.unSelectedHover), child.removeState(LegendStateValue.selectedHover);
47016
+ let attributeUpdate = !1;
47017
+ (legendItem.hasState(LegendStateValue.unSelectedHover) || legendItem.hasState(LegendStateValue.selectedHover)) && (attributeUpdate = !0), legendItem.removeState(LegendStateValue.unSelectedHover), legendItem.removeState(LegendStateValue.selectedHover), legendItem.getChildren()[0].getChildren().forEach(child => {
47018
+ attributeUpdate || !child.hasState(LegendStateValue.unSelectedHover) && !child.hasState(LegendStateValue.selectedHover) || (attributeUpdate = !0), child.removeState(LegendStateValue.unSelectedHover), child.removeState(LegendStateValue.selectedHover);
46995
47019
  });
46996
47020
  const focusButton = legendItem.getChildren()[0].find(node => node.name === LEGEND_ELEMENT_NAME.focus, !1);
46997
- focusButton && focusButton.setAttribute("visible", !1), this._dispatchEvent(LegendEvent.legendItemUnHover, legendItem);
47021
+ focusButton && focusButton.setAttribute("visible", !1), attributeUpdate && this._dispatchEvent(LegendEvent.legendItemAttributeUpdate, legendItem), this._dispatchEvent(LegendEvent.legendItemUnHover, legendItem);
46998
47022
  }
46999
47023
  }, this._onClick = e => {
47000
47024
  var _a, _b, _c, _d, _e;
@@ -47290,18 +47314,20 @@
47290
47314
  }
47291
47315
  _setLegendItemState(legendItem, stateName) {
47292
47316
  let keepCurrentStates = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !0;
47293
- legendItem.addState(stateName, keepCurrentStates), legendItem.getChildren()[0].getChildren().forEach(child => {
47294
- child.name !== LEGEND_ELEMENT_NAME.focus && child.addState(stateName, keepCurrentStates);
47295
- });
47317
+ let attributeUpdate = !1;
47318
+ legendItem.hasState(stateName) || (attributeUpdate = !0), legendItem.addState(stateName, keepCurrentStates), legendItem.getChildren()[0].getChildren().forEach(child => {
47319
+ child.name !== LEGEND_ELEMENT_NAME.focus && (attributeUpdate || child.hasState(stateName) || (attributeUpdate = !0), child.addState(stateName, keepCurrentStates));
47320
+ }), attributeUpdate && this._dispatchEvent(LegendEvent.legendItemAttributeUpdate, legendItem);
47296
47321
  }
47297
47322
  _removeLegendItemState(legendItem, stateNames) {
47323
+ let attributeUpdate = !1;
47298
47324
  stateNames.forEach(name => {
47299
- legendItem.removeState(name);
47325
+ !attributeUpdate && legendItem.hasState(name) && (attributeUpdate = !0), legendItem.removeState(name);
47300
47326
  }), legendItem.getChildren()[0].getChildren().forEach(child => {
47301
47327
  child.name !== LEGEND_ELEMENT_NAME.focus && stateNames.forEach(name => {
47302
- child.removeState(name);
47328
+ !attributeUpdate && child.hasState(name) && (attributeUpdate = !0), child.removeState(name);
47303
47329
  });
47304
- });
47330
+ }), attributeUpdate && this._dispatchEvent(LegendEvent.legendItemAttributeUpdate, legendItem);
47305
47331
  }
47306
47332
  _getSelectedLegends() {
47307
47333
  var _a;
@@ -56098,9 +56124,20 @@
56098
56124
  }
56099
56125
 
56100
56126
  class DimensionClickEvent extends DimensionEvent {
56101
- constructor(eventDispatcher, mode) {
56102
- super(eventDispatcher, mode);
56103
- this.onClick = this.onClick.bind(this);
56127
+ constructor() {
56128
+ super(...arguments);
56129
+ this.onClick = (params) => {
56130
+ if (!params) {
56131
+ return;
56132
+ }
56133
+ const x = params.event.viewX;
56134
+ const y = params.event.viewY;
56135
+ const targetDimensionInfo = this.getTargetDimensionInfo(x, y);
56136
+ if (!targetDimensionInfo) {
56137
+ return;
56138
+ }
56139
+ this._callback.call(null, Object.assign(Object.assign({}, params), { action: 'click', dimensionInfo: [...targetDimensionInfo] }));
56140
+ };
56104
56141
  }
56105
56142
  register(eType, handler) {
56106
56143
  this._callback = handler.callback;
@@ -56115,25 +56152,41 @@
56115
56152
  callback: this.onClick
56116
56153
  });
56117
56154
  }
56118
- onClick(params) {
56119
- if (!params) {
56120
- return;
56121
- }
56122
- const x = params.event.viewX;
56123
- const y = params.event.viewY;
56124
- const targetDimensionInfo = this.getTargetDimensionInfo(x, y);
56125
- if (!targetDimensionInfo) {
56126
- return;
56127
- }
56128
- this._callback.call(null, Object.assign(Object.assign({}, params), { action: 'click', dimensionInfo: [...targetDimensionInfo] }));
56129
- }
56130
56155
  }
56131
56156
 
56132
56157
  class DimensionHoverEvent extends DimensionEvent {
56133
- constructor(eventDispatcher, mode) {
56134
- super(eventDispatcher, mode);
56158
+ constructor() {
56159
+ super(...arguments);
56135
56160
  this._cacheDimensionInfo = null;
56136
- this.onMouseMove = this.onMouseMove.bind(this);
56161
+ this.onMouseMove = (params) => {
56162
+ if (!params) {
56163
+ return;
56164
+ }
56165
+ const x = params.event.viewX;
56166
+ const y = params.event.viewY;
56167
+ const targetDimensionInfo = this.getTargetDimensionInfo(x, y);
56168
+ if (targetDimensionInfo === null && this._cacheDimensionInfo !== null) {
56169
+ this._callback.call(null, Object.assign(Object.assign({}, params), { action: 'leave', dimensionInfo: [...this._cacheDimensionInfo] }));
56170
+ this._cacheDimensionInfo = targetDimensionInfo;
56171
+ }
56172
+ else if (targetDimensionInfo !== null &&
56173
+ (this._cacheDimensionInfo === null ||
56174
+ targetDimensionInfo.length !== this._cacheDimensionInfo.length ||
56175
+ targetDimensionInfo.some((info, i) => !isSameDimensionInfo(info, this._cacheDimensionInfo[i])))) {
56176
+ this._callback.call(null, Object.assign(Object.assign({}, params), { action: 'enter', dimensionInfo: [...targetDimensionInfo] }));
56177
+ this._cacheDimensionInfo = targetDimensionInfo;
56178
+ }
56179
+ else if (targetDimensionInfo !== null) {
56180
+ this._callback.call(null, Object.assign(Object.assign({}, params), { action: 'move', dimensionInfo: [...targetDimensionInfo] }));
56181
+ }
56182
+ };
56183
+ this.onMouseOut = (params) => {
56184
+ if (!params) {
56185
+ return;
56186
+ }
56187
+ this._callback.call(null, Object.assign(Object.assign({}, params), { action: 'leave', dimensionInfo: this._cacheDimensionInfo ? [...this._cacheDimensionInfo] : [] }));
56188
+ this._cacheDimensionInfo = null;
56189
+ };
56137
56190
  }
56138
56191
  register(eType, handler) {
56139
56192
  this._callback = handler.callback;
@@ -56141,6 +56194,10 @@
56141
56194
  query: Object.assign(Object.assign({}, handler.query), { source: Event_Source_Type.chart }),
56142
56195
  callback: this.onMouseMove
56143
56196
  });
56197
+ this._eventDispatcher.register('pointerout', {
56198
+ query: Object.assign(Object.assign({}, handler.query), { source: Event_Source_Type.chart }),
56199
+ callback: this.onMouseOut
56200
+ });
56144
56201
  if (isMobileLikeMode(this._mode)) {
56145
56202
  this._eventDispatcher.register('pointerdown', {
56146
56203
  query: Object.assign(Object.assign({}, handler.query), { source: Event_Source_Type.chart }),
@@ -56160,28 +56217,6 @@
56160
56217
  });
56161
56218
  }
56162
56219
  }
56163
- onMouseMove(params) {
56164
- if (!params) {
56165
- return;
56166
- }
56167
- const x = params.event.viewX;
56168
- const y = params.event.viewY;
56169
- const targetDimensionInfo = this.getTargetDimensionInfo(x, y);
56170
- if (targetDimensionInfo === null && this._cacheDimensionInfo !== null) {
56171
- this._callback.call(null, Object.assign(Object.assign({}, params), { action: 'leave', dimensionInfo: [...this._cacheDimensionInfo] }));
56172
- this._cacheDimensionInfo = targetDimensionInfo;
56173
- }
56174
- else if (targetDimensionInfo !== null &&
56175
- (this._cacheDimensionInfo === null ||
56176
- targetDimensionInfo.length !== this._cacheDimensionInfo.length ||
56177
- targetDimensionInfo.some((info, i) => !isSameDimensionInfo(info, this._cacheDimensionInfo[i])))) {
56178
- this._callback.call(null, Object.assign(Object.assign({}, params), { action: 'enter', dimensionInfo: [...targetDimensionInfo] }));
56179
- this._cacheDimensionInfo = targetDimensionInfo;
56180
- }
56181
- else if (targetDimensionInfo !== null) {
56182
- this._callback.call(null, Object.assign(Object.assign({}, params), { action: 'move', dimensionInfo: [...targetDimensionInfo] }));
56183
- }
56184
- }
56185
56220
  }
56186
56221
 
56187
56222
  var DimensionEventEnum;
@@ -57872,6 +57907,18 @@
57872
57907
  var _a;
57873
57908
  return (_a = this._chart) === null || _a === void 0 ? void 0 : _a.setDimensionIndex(value, opt);
57874
57909
  }
57910
+ stopAnimation() {
57911
+ var _a, _b, _c;
57912
+ (_c = (_b = (_a = this._compiler) === null || _a === void 0 ? void 0 : _a.getVGrammarView()) === null || _b === void 0 ? void 0 : _b.animate) === null || _c === void 0 ? void 0 : _c.stop();
57913
+ }
57914
+ pauseAnimation() {
57915
+ var _a, _b, _c;
57916
+ (_c = (_b = (_a = this._compiler) === null || _a === void 0 ? void 0 : _a.getVGrammarView()) === null || _b === void 0 ? void 0 : _b.animate) === null || _c === void 0 ? void 0 : _c.pause();
57917
+ }
57918
+ resumeAnimation() {
57919
+ var _a, _b, _c;
57920
+ (_c = (_b = (_a = this._compiler) === null || _a === void 0 ? void 0 : _a.getVGrammarView()) === null || _b === void 0 ? void 0 : _b.animate) === null || _c === void 0 ? void 0 : _c.resume();
57921
+ }
57875
57922
  convertDatumToPosition(datum, dataLinkInfo = {}, isRelativeToCanvas = false) {
57876
57923
  var _a;
57877
57924
  if (!this._chart) {
@@ -60699,7 +60746,7 @@
60699
60746
  VChart.useMark([ComponentMark, GroupMark, ImageMark]);
60700
60747
  Factory.registerRegion('region', Region);
60701
60748
  Factory.registerLayout('base', Layout);
60702
- const version = "1.3.0-beta.3";
60749
+ const version = "1.3.0-beta.5";
60703
60750
  Logger.getInstance(LoggerLevel.Error);
60704
60751
 
60705
60752
  var SeriesMarkNameEnum;
@@ -90305,6 +90352,7 @@
90305
90352
  this._mountEvent('pointerdown', { level: Event_Bubble_Level.chart }, this._handleMouseMove);
90306
90353
  this._mountEvent('pointerup', { source: 'window' }, this._handleMouseOut);
90307
90354
  }
90355
+ this._mountEvent('pointerout', { level: Event_Bubble_Level.chart, source: 'chart' }, this._handleMouseOut);
90308
90356
  this._mountEvent('pointermove', { source: 'window' }, this._handleMouseOut);
90309
90357
  }
90310
90358
  else if (trigger === 'click') {