@visactor/react-vchart 2.1.0-alpha.6 → 2.1.0-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.
package/build/index.js CHANGED
@@ -53841,6 +53841,9 @@
53841
53841
  }
53842
53842
 
53843
53843
  class ColorOrdinalScale extends OrdinalScale {
53844
+ setSpecified(value) {
53845
+ return this._specified = value ? Object.assign({}, value) : {}, this;
53846
+ }
53844
53847
  range(value) {
53845
53848
  return value ? (this._range = value, this._resetRange(), this) : super.range();
53846
53849
  }
@@ -54972,7 +54975,7 @@
54972
54975
  return this._composedEventMap;
54973
54976
  }
54974
54977
  constructor(eventDispatcher, mode) {
54975
- this._composedEventMap = new Map(), this._eventDispatcher = eventDispatcher, this._mode = mode;
54978
+ this._composedEventMap = new Map(), this._eventHandlerMap = new Map(), this._eventDispatcher = eventDispatcher, this._mode = mode;
54976
54979
  }
54977
54980
  on(eType, query, callback) {
54978
54981
  const handler = "function" == typeof query ? {
@@ -54989,16 +54992,16 @@
54989
54992
  eventType: eType,
54990
54993
  event: composedEvent
54991
54994
  });
54992
- } else this._eventDispatcher.register(eType, handler);
54995
+ } else this._eventDispatcher.register(eType, handler), this._addEventHandler(eType, handler);
54993
54996
  return this;
54994
54997
  }
54995
54998
  off(eType, query, cb) {
54996
- var _a, _b;
54999
+ var _a, _b, _c;
54997
55000
  const callback = null != cb ? cb : query;
54998
55001
  if (Factory.getComposedEvent(eType)) {
54999
55002
  if (callback) null === (_a = this._composedEventMap.get(callback)) || void 0 === _a || _a.event.unregister(), this._composedEventMap.delete(callback);else for (const entry of this._composedEventMap.entries()) entry[1].eventType === eType && (null === (_b = this._composedEventMap.get(entry[0])) || void 0 === _b || _b.event.unregister(), this._composedEventMap.delete(entry[0]));
55000
55003
  } else if (callback) {
55001
- const handler = {
55004
+ const handler = null !== (_c = this._getEventHandler(eType, callback)) && void 0 !== _c ? _c : {
55002
55005
  callback: callback,
55003
55006
  query: null,
55004
55007
  filter: {
@@ -55011,8 +55014,8 @@
55011
55014
  userId: null
55012
55015
  }
55013
55016
  };
55014
- this._eventDispatcher.unregister(eType, handler);
55015
- } else this._eventDispatcher.unregister(eType);
55017
+ this._eventDispatcher.unregister(eType, handler), this._removeEventHandler(eType, callback);
55018
+ } else this._eventDispatcher.unregister(eType), this._eventHandlerMap.delete(eType);
55016
55019
  return this;
55017
55020
  }
55018
55021
  emit(eType, params, level) {
@@ -55025,7 +55028,24 @@
55025
55028
  return this._eventDispatcher.allow(eType), this;
55026
55029
  }
55027
55030
  release() {
55028
- this._eventDispatcher.clear(), this._composedEventMap.clear();
55031
+ this._eventHandlerMap.forEach((handlers, eventType) => {
55032
+ handlers.forEach(handler => {
55033
+ this._eventDispatcher.unregister(eventType, handler);
55034
+ });
55035
+ }), this._eventHandlerMap.clear(), this._composedEventMap.forEach(entry => {
55036
+ entry.event.unregister();
55037
+ }), this._composedEventMap.clear();
55038
+ }
55039
+ _addEventHandler(eventType, handler) {
55040
+ handler.callback && (this._eventHandlerMap.has(eventType) || this._eventHandlerMap.set(eventType, new Map()), this._eventHandlerMap.get(eventType).set(handler.callback, handler));
55041
+ }
55042
+ _getEventHandler(eventType, callback) {
55043
+ var _a;
55044
+ return null === (_a = this._eventHandlerMap.get(eventType)) || void 0 === _a ? void 0 : _a.get(callback);
55045
+ }
55046
+ _removeEventHandler(eventType, callback) {
55047
+ const handlerMap = this._eventHandlerMap.get(eventType);
55048
+ handlerMap && (handlerMap.delete(callback), handlerMap.size || this._eventHandlerMap.delete(eventType));
55029
55049
  }
55030
55050
  };
55031
55051
 
@@ -59956,10 +59976,7 @@
59956
59976
  }
59957
59977
  _reCompile(updateResult, morphConfig) {
59958
59978
  var _a, _b, _c, _d, _e, _f, _g;
59959
- if (updateResult.reMake && (this._releaseData(), this._initDataSet(), null === (_a = this._chart) || void 0 === _a || _a.release(!1), this._chart = null), updateResult.reTransformSpec && (this._chartSpecTransformer = null), updateResult.changeTheme ? (this._setCurrentTheme(), this._setFontFamilyTheme(this.getTheme("fontFamily"))) : updateResult.changeBackground && (null === (_b = this._compiler) || void 0 === _b || _b.setBackground(this._getBackground())), updateResult.reMake ? (null === (_c = this._compiler) || void 0 === _c || _c.releaseGrammar(!0), this._userEvents.forEach(e => {
59960
- var _a;
59961
- return null === (_a = this._event) || void 0 === _a ? void 0 : _a.on(e.eType, e.query, e.handler);
59962
- })) : updateResult.reCompile && (null === (_d = this._compiler) || void 0 === _d || _d.clear({
59979
+ if (updateResult.reMake && (this._releaseData(), this._initDataSet(), null === (_a = this._chart) || void 0 === _a || _a.release(!1), this._chart = null), updateResult.reTransformSpec && (this._chartSpecTransformer = null), updateResult.changeTheme ? (this._setCurrentTheme(), this._setFontFamilyTheme(this.getTheme("fontFamily"))) : updateResult.changeBackground && (null === (_b = this._compiler) || void 0 === _b || _b.setBackground(this._getBackground())), updateResult.reMake ? null === (_c = this._compiler) || void 0 === _c || _c.releaseGrammar(!0) : updateResult.reCompile && (null === (_d = this._compiler) || void 0 === _d || _d.clear({
59963
59980
  chart: this._chart,
59964
59981
  vChart: this
59965
59982
  }), null === (_e = this._compiler) || void 0 === _e || _e.compile({
@@ -66102,7 +66119,15 @@
66102
66119
  const lastSpec = this._spec.find(_s => _s.id === s.id);
66103
66120
  if (!lastSpec.id) return result.reMake = !0, result;
66104
66121
  if (lastSpec.type !== s.type) return result.reMake = !0, result;
66105
- if (!isEqual(lastSpec.specified, s.specified)) return result.reMake = !0, result;
66122
+ if (!isEqual(lastSpec.specified, s.specified)) {
66123
+ if ("color" !== s.id) return result.reMake = !0, result;
66124
+ const colorScale = scale;
66125
+ if (colorScale.setSpecified) colorScale.setSpecified(s.specified);else {
66126
+ if (!s.specified || !colorScale.specified) return result.reMake = !0, result;
66127
+ colorScale.specified(s.specified);
66128
+ }
66129
+ result.reRender = !0;
66130
+ }
66106
66131
  s.range && !isEqual(s.range, scale.range()) && (scale.range(s.range), result.reRender = !0), isDataDomainSpec(s.domain) ? result.reRender = !0 : isEqual(s.domain, scale.domain()) || (scale.domain(s.domain), result.reRender = !0), this._scaleSpecMap.set(s.id, s);
66107
66132
  }
66108
66133
  return this._spec = spec, result;
@@ -66334,17 +66359,10 @@
66334
66359
  [ComponentTypeEnum.markArea]: !0
66335
66360
  },
66336
66361
  MARKER_ADDITION_REMAKE_SPEC_KEYS = {
66337
- autoRange: !0,
66338
66362
  regionId: !0,
66339
66363
  regionIndex: !0,
66340
66364
  seriesId: !0,
66341
66365
  seriesIndex: !0,
66342
- relativeSeriesId: !0,
66343
- relativeSeriesIndex: !0,
66344
- startRelativeSeriesId: !0,
66345
- startRelativeSeriesIndex: !0,
66346
- endRelativeSeriesId: !0,
66347
- endRelativeSeriesIndex: !0,
66348
66366
  specifiedDataSeriesId: !0,
66349
66367
  specifiedDataSeriesIndex: !0
66350
66368
  };
@@ -66423,7 +66441,11 @@
66423
66441
  }, this.getComponentsByKey = key => this._components.filter(c => (c.specKey || c.type) === key), this.getComponentByUserId = userId => {
66424
66442
  const component = this._components.find(s => s.userId === userId);
66425
66443
  if (component) return component;
66426
- }, this.getComponentsByType = type => this._components.filter(c => c.type === type), this._isMarkerAdditionSpecSafeWithoutRemake = spec => !(!spec || "object" != typeof spec || !1 === spec.visible) && !Object.keys(MARKER_ADDITION_REMAKE_SPEC_KEYS).some(key => !isNil$1(spec[key])), this._paddingSpec = normalizeLayoutPaddingSpec(null !== (_a = spec.padding) && void 0 !== _a ? _a : option.getTheme("padding")), this._event = new Event$1(option.eventDispatcher, option.mode), this._dataSet = option.dataSet, this._chartData = new ChartData(this._dataSet), this._modelOption = Object.assign(Object.assign({}, option), {
66444
+ }, this.getComponentsByType = type => this._components.filter(c => c.type === type), this._isMarkerAdditionSpecSafeWithoutRemake = spec => {
66445
+ if (!spec || "object" != typeof spec) return !1;
66446
+ const markerSpec = spec;
66447
+ return !1 !== markerSpec.visible && !Object.keys(MARKER_ADDITION_REMAKE_SPEC_KEYS).some(key => !isNil$1(markerSpec[key]));
66448
+ }, this._paddingSpec = normalizeLayoutPaddingSpec(null !== (_a = spec.padding) && void 0 !== _a ? _a : option.getTheme("padding")), this._event = new Event$1(option.eventDispatcher, option.mode), this._dataSet = option.dataSet, this._chartData = new ChartData(this._dataSet), this._modelOption = Object.assign(Object.assign({}, option), {
66427
66449
  mode: this._option.mode,
66428
66450
  map: this._idMap,
66429
66451
  getChartLayoutRect: () => this._layoutRect,
@@ -66841,6 +66863,9 @@
66841
66863
  _canAddMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) {
66842
66864
  return !!(MARKER_COMPONENT_SPEC_KEYS[key] && isArray$1(currentSpec) && isArray$1(nextSpec)) && !(nextSpec.length <= currentSpec.length) && nextSpec.slice(currentSpec.length).every(this._isMarkerAdditionSpecSafeWithoutRemake);
66843
66865
  }
66866
+ _isAutoRangeMarkerSpec(spec) {
66867
+ return !!spec && "object" == typeof spec && !0 === spec.autoRange;
66868
+ }
66844
66869
  _canRemoveMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) {
66845
66870
  return MARKER_COMPONENT_SPEC_KEYS[key] && isArray$1(currentSpec) && currentSpec.length > 0 && isArray$1(nextSpec) && 0 === nextSpec.length;
66846
66871
  }
@@ -66906,13 +66931,17 @@
66906
66931
  }
66907
66932
  _createMissingMarkerComponentsForSpecs(result, componentCache) {
66908
66933
  var _a;
66909
- let createdCount = 0;
66934
+ let createdCount = 0,
66935
+ hasAutoRangeMarker = !1;
66910
66936
  null === (_a = this._specTransformer) || void 0 === _a || _a.forEachComponentInSpec(this._spec, (constructor, specInfo) => {
66911
66937
  if (result.reMake) return;
66912
66938
  const compSpecKey = constructor.specKey || constructor.type;
66913
- MARKER_COMPONENT_SPEC_KEYS[compSpecKey] && !this._hasComponentForSpecInfo(compSpecKey, specInfo) && (this._isMarkerAdditionSpecSafeWithoutRemake(specInfo.spec) ? (this._createComponent(constructor, specInfo), componentCache[compSpecKey] && componentCache[compSpecKey].componentCount++, createdCount++) : result.reMake = !0);
66914
- }, this._option.getSpecInfo()), createdCount && (result.change = !0, result.effects = Object.assign(Object.assign({}, result.effects), {
66915
- component: !0,
66939
+ MARKER_COMPONENT_SPEC_KEYS[compSpecKey] && !this._hasComponentForSpecInfo(compSpecKey, specInfo) && (this._isMarkerAdditionSpecSafeWithoutRemake(specInfo.spec) ? (this._createComponent(constructor, specInfo), componentCache[compSpecKey] && componentCache[compSpecKey].componentCount++, createdCount++, hasAutoRangeMarker = hasAutoRangeMarker || this._isAutoRangeMarkerSpec(specInfo.spec)) : result.reMake = !0);
66940
+ }, this._option.getSpecInfo()), createdCount && (result.change = !0, result.effects = Object.assign(Object.assign(Object.assign(Object.assign({}, result.effects), {
66941
+ component: !0
66942
+ }), hasAutoRangeMarker ? {
66943
+ scaleDomain: !0
66944
+ } : null), {
66916
66945
  layout: !0,
66917
66946
  render: !0
66918
66947
  }));
@@ -90844,20 +90873,31 @@
90844
90873
  MARKER_COORDINATE_PLACEHOLDER = "__vchart_marker_coordinate__",
90845
90874
  MARKER_TEXT_PLACEHOLDER = "__vchart_marker_text__",
90846
90875
  MARKER_AUTO_RANGE_PLACEHOLDER = "__vchart_marker_auto_range__",
90876
+ MARKER_STYLE_PLACEHOLDER = "__vchart_marker_style__",
90847
90877
  MARKER_DOMAIN_POSITION_SPEC_KEYS = ["coordinate", "coordinates", "x", "y", "x1", "y1", "angle", "angle1", "radius", "radius1"],
90848
90878
  MARKER_LAYOUT_POSITION_SPEC_KEYS = ["position", "positions", "coordinatesOffset", "regionRelative"],
90849
90879
  normalizeMarkerLabelFormatMethod = label => Array.isArray(label) ? label.map(normalizeMarkerLabelFormatMethod) : label && "object" == typeof label ? "function" != typeof label.formatMethod ? label : Object.assign(Object.assign({}, label), {
90850
90880
  formatMethod: MARKER_FORMAT_METHOD_PLACEHOLDER
90851
90881
  }) : label,
90882
+ normalizeMarkerStyles = value => {
90883
+ if (Array.isArray(value)) return value.map(normalizeMarkerStyles);
90884
+ if (!value || "object" != typeof value) return value;
90885
+ const normalized = Object.assign({}, value);
90886
+ return Object.keys(normalized).forEach(key => {
90887
+ "style" === key || key.endsWith("Style") ? normalized[key] = MARKER_STYLE_PLACEHOLDER : normalized[key] = normalizeMarkerStyles(normalized[key]);
90888
+ }), normalized;
90889
+ },
90852
90890
  normalizeMarkerSpecForComponentOnlyUpdate = (spec, options) => {
90853
90891
  var _a;
90854
90892
  if (!spec || "object" != typeof spec) return spec;
90855
90893
  const normalized = Object.assign({}, spec);
90856
90894
  options.normalizeDomainPosition && MARKER_DOMAIN_POSITION_SPEC_KEYS.forEach(key => {
90857
- key in normalized && (normalized[key] = MARKER_COORDINATE_PLACEHOLDER);
90895
+ normalized[key] = MARKER_COORDINATE_PLACEHOLDER;
90858
90896
  }), options.normalizeAutoRange && "autoRange" in normalized && (normalized.autoRange = MARKER_AUTO_RANGE_PLACEHOLDER), MARKER_LAYOUT_POSITION_SPEC_KEYS.forEach(key => {
90859
90897
  key in normalized && (normalized[key] = MARKER_COORDINATE_PLACEHOLDER);
90860
- }), "label" in normalized && (normalized.label = normalizeMarkerLabelFormatMethod(normalized.label));
90898
+ }), "label" in normalized && (normalized.label = normalizeMarkerLabelFormatMethod(normalized.label)), Object.keys(normalized).forEach(key => {
90899
+ normalized[key] = normalizeMarkerStyles(normalized[key]);
90900
+ });
90861
90901
  const text = null === (_a = normalized.itemContent) || void 0 === _a ? void 0 : _a.text;
90862
90902
  return text && "object" == typeof text && (normalized.itemContent = Object.assign(Object.assign({}, normalized.itemContent), {
90863
90903
  text: Object.assign(Object.assign({}, normalizeMarkerLabelFormatMethod(text)), {
@@ -91044,7 +91084,7 @@
91044
91084
  }));
91045
91085
  }
91046
91086
  reInit(spec) {
91047
- super.reInit(spec), this._bindSeries(), this._initDataView(), this._buildMarkerAttributeContext(), this._markerComponent && this._updateMarkerLayout();
91087
+ super.reInit(spec), this._releaseMarkerData(), this._bindSeries(), this._initDataView(), this._buildMarkerAttributeContext(), this._markerComponent && this._updateMarkerLayout();
91048
91088
  }
91049
91089
  _initCommonDataView() {
91050
91090
  const {
@@ -93093,7 +93133,7 @@
93093
93133
  return new MarkPoint$1(markPointAttrs);
93094
93134
  }
93095
93135
  _markerLayout() {
93096
- var _a, _b, _c, _d, _e, _f;
93136
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
93097
93137
  const spec = this._spec,
93098
93138
  data = this._markerData,
93099
93139
  relativeSeries = this._relativeSeries,
@@ -93101,9 +93141,30 @@
93101
93141
  point: point
93102
93142
  } = this._computePointsAttr(),
93103
93143
  seriesData = this._getRelativeDataView().latestData,
93104
- dataPoints = data ? data.latestData[0] && data.latestData[0].latestData ? data.latestData[0].latestData : data.latestData : seriesData;
93144
+ dataPoints = data ? data.latestData[0] && data.latestData[0].latestData ? data.latestData[0].latestData : data.latestData : seriesData,
93145
+ {
93146
+ itemLine = {},
93147
+ itemContent = {}
93148
+ } = this._spec,
93149
+ {
93150
+ visible: itemLineVisible,
93151
+ line = {}
93152
+ } = itemLine,
93153
+ restItemLine = __rest$1(itemLine, ["visible", "line"]),
93154
+ itemLineAttrs = !1 !== itemLineVisible ? Object.assign(Object.assign({}, restItemLine), {
93155
+ visible: !0,
93156
+ lineStyle: transformToGraphic(line.style)
93157
+ }) : {
93158
+ visible: !1
93159
+ },
93160
+ labelAttrs = transformLabelAttributes(Object.assign(Object.assign({}, itemContent.text), {
93161
+ style: merge$1({
93162
+ dx: 0,
93163
+ dy: 0
93164
+ }, null !== (_b = null === (_a = itemContent.text) || void 0 === _a ? void 0 : _a.style) && void 0 !== _b ? _b : itemContent.style)
93165
+ }), data, this._markAttributeContext);
93105
93166
  let limitRect;
93106
- if (spec.clip || (null === (_a = spec.itemContent) || void 0 === _a ? void 0 : _a.confine)) {
93167
+ if (spec.clip || (null === (_c = spec.itemContent) || void 0 === _c ? void 0 : _c.confine)) {
93107
93168
  const {
93108
93169
  minX: minX,
93109
93170
  maxX: maxX,
@@ -93118,21 +93179,24 @@
93118
93179
  };
93119
93180
  }
93120
93181
  if (this._markerComponent) {
93121
- const attribute = null !== (_b = this._markerComponent.attribute) && void 0 !== _b ? _b : {},
93122
- textStyle = null !== (_d = null === (_c = attribute.itemContent) || void 0 === _c ? void 0 : _c.textStyle) && void 0 !== _d ? _d : {},
93123
- specText = null === (_e = this._spec.itemContent.text) || void 0 === _e ? void 0 : _e.text;
93182
+ const attribute = null !== (_d = this._markerComponent.attribute) && void 0 !== _d ? _d : {},
93183
+ textStyle = null !== (_f = null === (_e = attribute.itemContent) || void 0 === _e ? void 0 : _e.textStyle) && void 0 !== _f ? _f : {},
93184
+ specText = null === (_g = this._spec.itemContent.text) || void 0 === _g ? void 0 : _g.text;
93124
93185
  this._markerComponent.setAttributes({
93125
93186
  position: void 0 === point ? {
93126
93187
  x: null,
93127
93188
  y: null
93128
93189
  } : point,
93129
93190
  itemContent: Object.assign(Object.assign({}, attribute.itemContent), {
93130
- textStyle: Object.assign(Object.assign({}, textStyle), {
93131
- text: (null === (_f = this._spec.itemContent.text) || void 0 === _f ? void 0 : _f.formatMethod) ? this._spec.itemContent.text.formatMethod(dataPoints, seriesData) : isValid$1(specText) ? specText : textStyle.text
93191
+ panel: null !== (_h = labelAttrs.panel) && void 0 !== _h ? _h : null === (_j = attribute.itemContent) || void 0 === _j ? void 0 : _j.panel,
93192
+ padding: null !== (_k = labelAttrs.padding) && void 0 !== _k ? _k : null === (_l = attribute.itemContent) || void 0 === _l ? void 0 : _l.padding,
93193
+ textStyle: Object.assign(Object.assign(Object.assign({}, textStyle), null !== (_m = labelAttrs.textStyle) && void 0 !== _m ? _m : {}), {
93194
+ text: (null === (_o = this._spec.itemContent.text) || void 0 === _o ? void 0 : _o.formatMethod) ? this._spec.itemContent.text.formatMethod(dataPoints, seriesData) : isValid$1(specText) ? specText : textStyle.text
93132
93195
  }),
93133
93196
  offsetX: computeOffsetFromRegion(point, attribute.itemContent.offsetX, this._relativeSeries.getRegion()),
93134
93197
  offsetY: computeOffsetFromRegion(point, attribute.itemContent.offsetY, this._relativeSeries.getRegion())
93135
93198
  }),
93199
+ itemLine: itemLineAttrs,
93136
93200
  limitRect: limitRect,
93137
93201
  dx: this._layoutOffsetX,
93138
93202
  dy: this._layoutOffsetY