@rfkit/charts 1.1.13 → 1.1.14

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.
@@ -10,7 +10,7 @@ export default class Counter {
10
10
  *
11
11
  * @memberof Counter
12
12
  */
13
- onMixChange(id: string | number, markers: any, onChange: (arg0: any, arg1: any[]) => void): void;
13
+ onMixChange(id: string | number, markers: any, onChange: (arg0: any, arg1: any[], arg2?: string) => void, operationType?: string): void;
14
14
  /**
15
15
  * 更新状态
16
16
  *
@@ -39,7 +39,7 @@ export default class Markers {
39
39
  *
40
40
  * @memberof Markers
41
41
  */
42
- onChange(isDel?: boolean): void;
42
+ onChange(isDel?: boolean, operationType?: string): void;
43
43
  /**
44
44
  * 卸载计数器
45
45
  */
@@ -71,7 +71,15 @@ export declare enum MarkerEventType {
71
71
  Add = "add",
72
72
  Del = "del",
73
73
  Reset = "reset",
74
- Move = "move"
74
+ Move = "move",
75
+ Clear = "clear",
76
+ Hover = "hover",
77
+ Update = "update",
78
+ Format = "format",
79
+ Dashed = "dashed",
80
+ Center = "center",
81
+ Ref = "ref",
82
+ Flow = "flow"
75
83
  }
76
84
  export declare enum ToolType {
77
85
  AxisX = "axisX",
package/index.js CHANGED
@@ -3904,6 +3904,14 @@ var constants_MarkerEventType = /*#__PURE__*/ function(MarkerEventType) {
3904
3904
  MarkerEventType["Del"] = "del";
3905
3905
  MarkerEventType["Reset"] = "reset";
3906
3906
  MarkerEventType["Move"] = "move";
3907
+ MarkerEventType["Clear"] = "clear";
3908
+ MarkerEventType["Hover"] = "hover";
3909
+ MarkerEventType["Update"] = "update";
3910
+ MarkerEventType["Format"] = "format";
3911
+ MarkerEventType["Dashed"] = "dashed";
3912
+ MarkerEventType["Center"] = "center";
3913
+ MarkerEventType["Ref"] = "ref";
3914
+ MarkerEventType["Flow"] = "flow";
3907
3915
  return MarkerEventType;
3908
3916
  }({});
3909
3917
  var constants_ToolType = /*#__PURE__*/ function(ToolType) {
@@ -8453,7 +8461,7 @@ const Board = ({ markers, heatmapMode, onChange })=>{
8453
8461
  e.stopPropagation();
8454
8462
  onChange({
8455
8463
  id: i.id,
8456
- event: 'flow'
8464
+ event: constants_MarkerEventType.Flow
8457
8465
  });
8458
8466
  }
8459
8467
  },
@@ -8500,7 +8508,7 @@ const Board = ({ markers, heatmapMode, onChange })=>{
8500
8508
  setActive(null);
8501
8509
  onChange({
8502
8510
  id: i.id,
8503
- event: 'del'
8511
+ event: constants_MarkerEventType.Del
8504
8512
  });
8505
8513
  },
8506
8514
  children: "x"
@@ -8660,13 +8668,13 @@ class Counter {
8660
8668
  const { include } = this.state;
8661
8669
  this.state.include = include.filter((i)=>!cache.includes(i));
8662
8670
  }
8663
- onMixChange(id, markers, onChange) {
8671
+ onMixChange(id, markers, onChange, operationType) {
8664
8672
  this.state.markers[id] = JSON.parse(JSON.stringify(markers));
8665
8673
  const mix = [];
8666
8674
  Object.values(this.state.markers).forEach((i)=>{
8667
8675
  mix.push(...i);
8668
8676
  });
8669
- onChange?.(markers, mix);
8677
+ onChange?.(markers, mix, operationType);
8670
8678
  }
8671
8679
  setState(p) {
8672
8680
  this.state = {
@@ -8749,7 +8757,7 @@ class Markers {
8749
8757
  }, 'update');
8750
8758
  info.peak = false;
8751
8759
  markers[index] = info;
8752
- this.onChange();
8760
+ this.onChange(false, constants_MarkerEventType.Move);
8753
8761
  }
8754
8762
  }
8755
8763
  });
@@ -8805,7 +8813,7 @@ class Markers {
8805
8813
  id: ee.id,
8806
8814
  select: true
8807
8815
  });
8808
- this.onChange();
8816
+ this.onChange(false, constants_MarkerEventType.Add);
8809
8817
  }
8810
8818
  }
8811
8819
  updateAttribute(attr) {
@@ -8834,19 +8842,19 @@ class Markers {
8834
8842
  onDel();
8835
8843
  }
8836
8844
  }
8837
- if ('clear' === event) {
8845
+ if (event === constants_MarkerEventType.Clear) {
8838
8846
  markers.forEach((_, index)=>{
8839
8847
  counter.remove(markers[index].label);
8840
8848
  });
8841
8849
  markers.splice(0, markers.length);
8842
8850
  isDel = true;
8843
8851
  }
8844
- if ('dashed' === event) for(let index = 0; index < markers.length; index += 1){
8852
+ if (event === constants_MarkerEventType.Dashed) for(let index = 0; index < markers.length; index += 1){
8845
8853
  const item = markers[index];
8846
8854
  item.dashed = false;
8847
8855
  if (data.includes(item.id)) item.dashed = true;
8848
8856
  }
8849
- if ('center' === event) {
8857
+ if (event === constants_MarkerEventType.Center) {
8850
8858
  const index = markers.findIndex((i)=>i.id === id);
8851
8859
  const center = 50;
8852
8860
  if (index >= 0) {
@@ -8870,7 +8878,7 @@ class Markers {
8870
8878
  }
8871
8879
  }
8872
8880
  }
8873
- if ('format' === event) {
8881
+ if (event === constants_MarkerEventType.Format) {
8874
8882
  const index = markers.findIndex((i)=>i.id === id);
8875
8883
  const { left } = attribute;
8876
8884
  if (index >= 0 && void 0 !== left) markers[index] = this.formatMarker({
@@ -8878,7 +8886,7 @@ class Markers {
8878
8886
  left
8879
8887
  });
8880
8888
  }
8881
- if ('ref' === event) {
8889
+ if (event === constants_MarkerEventType.Ref) {
8882
8890
  const index = markers.findIndex((i)=>i.id === id);
8883
8891
  if (index >= 0) {
8884
8892
  markers[index].refId = refId;
@@ -8908,14 +8916,20 @@ class Markers {
8908
8916
  }
8909
8917
  }
8910
8918
  if (void 0 !== peak && true === peak) return void this.updateByData();
8911
- this.onChange(isDel);
8919
+ let operationType = constants_MarkerEventType.Update;
8920
+ if (event === constants_MarkerEventType.Add) operationType = constants_MarkerEventType.Add;
8921
+ else if (event === constants_MarkerEventType.Del) operationType = constants_MarkerEventType.Del;
8922
+ else if (event === constants_MarkerEventType.Clear) operationType = constants_MarkerEventType.Clear;
8923
+ else if (event === constants_MarkerEventType.Center) operationType = constants_MarkerEventType.Move;
8924
+ else if (event === constants_MarkerEventType.Format) operationType = constants_MarkerEventType.Move;
8925
+ this.onChange(isDel, operationType);
8912
8926
  }
8913
8927
  updateByData(data = this.state.data) {
8914
8928
  this.state.data = data;
8915
8929
  this.formatPeaks?.();
8916
8930
  const { markers } = this.state;
8917
8931
  this.state.markers = markers.map((marker)=>this.formatMarker(marker, 'update'));
8918
- this.onChange();
8932
+ this.onChange(false, constants_MarkerEventType.Update);
8919
8933
  }
8920
8934
  updateParams(e) {
8921
8935
  this.state = {
@@ -8927,7 +8941,7 @@ class Markers {
8927
8941
  const { show } = this.state;
8928
8942
  if (!show) this.reset();
8929
8943
  }
8930
- onChange(isDel = false) {
8944
+ onChange(isDel = false, operationType) {
8931
8945
  const { id, markers, onChange, counter } = this.state;
8932
8946
  if (!isDel) this.state.markers = markers.map((marker)=>{
8933
8947
  const { refId, frequency, level, timestamp } = marker;
@@ -8945,7 +8959,7 @@ class Markers {
8945
8959
  ...refData
8946
8960
  };
8947
8961
  });
8948
- if (markers.length || isDel) counter.onMixChange(id, markers, onChange);
8962
+ if (markers.length || isDel) counter.onMixChange(id, markers, onChange, operationType);
8949
8963
  }
8950
8964
  destroyCounter() {
8951
8965
  const { counter, labelCache } = this.state;
@@ -8959,12 +8973,12 @@ class Markers {
8959
8973
  hoverChange = item.hover;
8960
8974
  item.hover = false;
8961
8975
  }
8962
- if (hoverChange) this.onChange();
8976
+ if (hoverChange) this.onChange(false, constants_MarkerEventType.Reset);
8963
8977
  }
8964
8978
  reset() {
8965
8979
  this.state.markers = [];
8966
8980
  this.state.counter.clear();
8967
- this.onChange(true);
8981
+ this.onChange(true, constants_MarkerEventType.Reset);
8968
8982
  }
8969
8983
  }
8970
8984
  const MARKER_UPDATE_PARAMS = (id, func)=>subscription_createSubscriptionManager(`MARKER_UPDATE_PARAMS-${id}`, '0', func);
@@ -9021,7 +9035,7 @@ const setMarkerMove = (e, segments, func)=>{
9021
9035
  const left = (frequency - start) * 100 / width;
9022
9036
  func?.({
9023
9037
  pstype: constants_PSType.Marker,
9024
- event: 'format',
9038
+ event: constants_MarkerEventType.Format,
9025
9039
  id,
9026
9040
  left
9027
9041
  });
@@ -9042,7 +9056,7 @@ const setMarkerBatchAdd = (e, segments, func)=>{
9042
9056
  }
9043
9057
  func?.({
9044
9058
  pstype: constants_PSType.Marker,
9045
- event: 'add',
9059
+ event: constants_MarkerEventType.Add,
9046
9060
  data: r
9047
9061
  });
9048
9062
  }
@@ -9153,7 +9167,7 @@ class FreeMarkers extends Markers {
9153
9167
  }
9154
9168
  }
9155
9169
  }
9156
- if (hoverChange) this.onChange();
9170
+ if (hoverChange) this.onChange(false, constants_MarkerEventType.Hover);
9157
9171
  }
9158
9172
  return isHover;
9159
9173
  }
@@ -9947,7 +9961,7 @@ class LineMarkers extends Markers {
9947
9961
  }
9948
9962
  }
9949
9963
  }
9950
- if (hoverChange) this.onChange();
9964
+ if (hoverChange) this.onChange(false, constants_MarkerEventType.Hover);
9951
9965
  }
9952
9966
  return isHover;
9953
9967
  }
@@ -9971,7 +9985,7 @@ class LineMarkers extends Markers {
9971
9985
  const attribute = attr;
9972
9986
  const { markers } = this.state;
9973
9987
  const { event, id } = attribute;
9974
- if ('flow' === event) {
9988
+ if (event === constants_MarkerEventType.Flow) {
9975
9989
  const index = markers.findIndex((i)=>i.id === id);
9976
9990
  markers[index].flow = {
9977
9991
  name: SERIES.realData.name,
@@ -10027,13 +10041,15 @@ const Markers_Markers = ({ id, counter, selecter, heatmapMode = false })=>{
10027
10041
  const [markers, setMarkers] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)([]);
10028
10042
  const { state: { marker, axisX, axisY, zoom, segments, globalID }, dispatch } = useStore_useStore();
10029
10043
  const { show: markerShow, display, count, onChange, dot: { fixed }, selectMax } = marker;
10030
- const managerOnChange = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((e, mix)=>{
10044
+ const managerOnChange = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((e, mix, operationType)=>{
10031
10045
  const m = mix;
10032
10046
  setMarkers(JSON.parse(JSON.stringify(e)));
10033
10047
  m.heatmapMode = heatmapMode;
10048
+ m.operationType = operationType;
10034
10049
  onChange?.(m);
10035
10050
  }, [
10036
- onChange
10051
+ onChange,
10052
+ heatmapMode
10037
10053
  ]);
10038
10054
  const [manager] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(()=>new (heatmapMode ? FreeMarkers : LineMarkers)({
10039
10055
  id,
@@ -10158,7 +10174,7 @@ const Markers_Markers = ({ id, counter, selecter, heatmapMode = false })=>{
10158
10174
  manager?.updateAttribute({
10159
10175
  id: m.id,
10160
10176
  left: m.left,
10161
- event: 'format'
10177
+ event: constants_MarkerEventType.Format
10162
10178
  });
10163
10179
  }
10164
10180
  if ('ArrowRight' === key) {
@@ -10168,7 +10184,7 @@ const Markers_Markers = ({ id, counter, selecter, heatmapMode = false })=>{
10168
10184
  manager?.updateAttribute({
10169
10185
  id: m.id,
10170
10186
  left: m.left,
10171
- event: 'format'
10187
+ event: constants_MarkerEventType.Format
10172
10188
  });
10173
10189
  }
10174
10190
  }
package/package.json CHANGED
@@ -5,6 +5,6 @@
5
5
  "types": "index.d.ts",
6
6
  "author": "Hxgh",
7
7
  "license": "MIT",
8
- "version": "1.1.13",
8
+ "version": "1.1.14",
9
9
  "private": false
10
10
  }