@rfkit/charts 1.1.14 → 1.1.15

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.
@@ -1,25 +1,38 @@
1
+ interface CounterState {
2
+ id: string;
3
+ count: number;
4
+ all: string[];
5
+ include: string[];
6
+ markers: Record<string | number, unknown[]>;
7
+ }
8
+ interface CounterProps {
9
+ id?: string;
10
+ count?: number;
11
+ all?: string[];
12
+ include?: string[];
13
+ markers?: Record<string | number, unknown[]>;
14
+ }
1
15
  export default class Counter {
2
- [x: string]: any;
3
- constructor(props: any);
4
- add(): any;
5
- remove(no: any): boolean;
16
+ private state;
17
+ constructor(props?: CounterProps);
18
+ add(): string | false;
19
+ remove(no: string): boolean;
6
20
  clear(): void;
7
- destroy(cache: string | any[]): void;
21
+ destroy(cache: string[]): void;
8
22
  /**
9
23
  * 混合onChange,可能包含多个markers实例公用counter
10
24
  *
11
- * @memberof Counter
25
+ * @param id 实例ID
26
+ * @param markers 标记数组
27
+ * @param onChange 变更回调函数
28
+ * @param operationType 操作类型
12
29
  */
13
- onMixChange(id: string | number, markers: any, onChange: (arg0: any, arg1: any[], arg2?: string) => void, operationType?: string): void;
14
30
  /**
15
31
  * 更新状态
16
32
  *
17
- * @param {*} p
18
- * @memberof Range
33
+ * @param p 状态更新参数
19
34
  */
20
- setState(p: {
21
- all: any;
22
- include: any;
23
- count: any;
24
- }): void;
35
+ setState(p: Partial<CounterState>): void;
36
+ onMixChange(id: string | number, markers: unknown[], onChange: (markers: unknown[], mix: unknown[], operationType?: string) => void, operationType?: string): void;
25
37
  }
38
+ export {};
@@ -1,28 +1,35 @@
1
1
  /**
2
2
  * 处理唯一选中
3
3
  */
4
+ type SelecterCallback = (event: {
5
+ select: boolean;
6
+ parentID: string;
7
+ attribute: Record<string, unknown>;
8
+ }) => void;
9
+ interface MarkerAttribute {
10
+ select: boolean;
11
+ [key: string]: unknown;
12
+ }
4
13
  export default class Selecter {
5
- [x: string]: any;
14
+ private state;
6
15
  constructor();
7
16
  /**
8
17
  * 设置当前选中
9
18
  *
10
- * @param {*} parentID 实例的id
11
- * @param {*} id 被选中的marker的id
12
- * @returns
13
- * @memberof Select
19
+ * @param parentID 实例的id
20
+ * @param id 被选中的marker的id
21
+ * @param attribute 标记属性
14
22
  */
15
- set(parentID: string, id: any, attribute: {
16
- select: any;
17
- }): void;
23
+ set(parentID: string, id: string, attribute: MarkerAttribute): void;
18
24
  /**
19
25
  * 取消选中
20
- * @param {*} parentID
26
+ * @param parentID 实例的id
21
27
  */
22
- cancel(parentID: string | number): void;
28
+ cancel(parentID: string): void;
23
29
  /**
24
30
  * 订阅变更
25
- * @param {*} func
31
+ * @param func 回调函数
26
32
  */
27
- subscription(func: any): void;
33
+ subscription(func: SelecterCallback): void;
28
34
  }
35
+ export {};
@@ -53,10 +53,14 @@ export declare const setMarkerMove: (e: MarkerType, segments: SegmentsType, func
53
53
  */
54
54
  export declare const setMarkerBatchAdd: (e: {
55
55
  data: any;
56
+ clear?: boolean;
57
+ [key: string]: any;
56
58
  }, segments: SegmentsType, func: (arg0: {
57
59
  pstype: string;
58
60
  event: string;
59
61
  data: number[];
62
+ clear?: boolean;
63
+ [key: string]: any;
60
64
  }) => void) => void;
61
65
  /**
62
66
  * 峰值算法
package/index.js CHANGED
@@ -8633,20 +8633,21 @@ const Dot = ({ heatmapMode, markers })=>{
8633
8633
  };
8634
8634
  const Markers_Dot = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].memo(Dot);
8635
8635
  class Counter {
8636
- constructor(props){
8637
- this.setState({
8636
+ state;
8637
+ constructor(props = {}){
8638
+ this.state = {
8638
8639
  id: 'id',
8639
8640
  count: 10,
8640
8641
  all: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''),
8641
8642
  include: [],
8642
8643
  markers: {},
8643
8644
  ...props
8644
- });
8645
+ };
8645
8646
  }
8646
8647
  add() {
8647
8648
  const { all, include, count } = this.state;
8648
8649
  if (include.length >= count) return false;
8649
- const difference = all.filter((i)=>-1 === include.indexOf(i));
8650
+ const difference = all.filter((item)=>!include.includes(item));
8650
8651
  const atom = difference[0];
8651
8652
  if (atom) {
8652
8653
  include.push(atom);
@@ -8657,7 +8658,7 @@ class Counter {
8657
8658
  remove(no) {
8658
8659
  const { include } = this.state;
8659
8660
  if (!no || 0 === include.length) return false;
8660
- this.state.include = include.filter((i)=>i !== no);
8661
+ this.state.include = include.filter((item)=>item !== no);
8661
8662
  return true;
8662
8663
  }
8663
8664
  clear() {
@@ -8666,15 +8667,7 @@ class Counter {
8666
8667
  destroy(cache) {
8667
8668
  if (!cache || 0 === cache.length) return;
8668
8669
  const { include } = this.state;
8669
- this.state.include = include.filter((i)=>!cache.includes(i));
8670
- }
8671
- onMixChange(id, markers, onChange, operationType) {
8672
- this.state.markers[id] = JSON.parse(JSON.stringify(markers));
8673
- const mix = [];
8674
- Object.values(this.state.markers).forEach((i)=>{
8675
- mix.push(...i);
8676
- });
8677
- onChange?.(markers, mix, operationType);
8670
+ this.state.include = include.filter((item)=>!cache.includes(item));
8678
8671
  }
8679
8672
  setState(p) {
8680
8673
  this.state = {
@@ -8682,6 +8675,14 @@ class Counter {
8682
8675
  ...p
8683
8676
  };
8684
8677
  }
8678
+ onMixChange(id, markers, onChange, operationType) {
8679
+ this.state.markers[id] = JSON.parse(JSON.stringify(markers));
8680
+ const mix = [];
8681
+ Object.values(this.state.markers).forEach((markerArray)=>{
8682
+ mix.push(...markerArray);
8683
+ });
8684
+ onChange?.(markers, mix, operationType);
8685
+ }
8685
8686
  }
8686
8687
  const markerColors = getConfig('marker');
8687
8688
  const Markers_COMPONENT_KEY = constants_ToolType.Markers;
@@ -8819,8 +8820,12 @@ class Markers {
8819
8820
  updateAttribute(attr) {
8820
8821
  const attribute = attr;
8821
8822
  const { markers, counter, selecter, id: parentID, onDel, heatmapMode } = this.state;
8822
- const { id, peak, select, event, data, refId } = attribute;
8823
+ const { id, peak, select, event, data, refId, clear } = attribute;
8823
8824
  if (event === constants_MarkerEventType.Add) {
8825
+ if (clear) {
8826
+ counter.clear();
8827
+ markers.splice(0, markers.length);
8828
+ }
8824
8829
  if (data?.length) for(let i = 0; i < data.length; i += 1)this.create({
8825
8830
  left: data[i]
8826
8831
  }, true);
@@ -9043,7 +9048,7 @@ const setMarkerMove = (e, segments, func)=>{
9043
9048
  }
9044
9049
  };
9045
9050
  const setMarkerBatchAdd = (e, segments, func)=>{
9046
- const { data } = e;
9051
+ const { data, ...otherProps } = e;
9047
9052
  const seg = segments[0];
9048
9053
  if (data?.length && seg) {
9049
9054
  const { start, stop } = seg;
@@ -9052,9 +9057,10 @@ const setMarkerBatchAdd = (e, segments, func)=>{
9052
9057
  const r = [];
9053
9058
  for(let i = 0; i < data.length; i += 1){
9054
9059
  const frequency = data[i];
9055
- if (frequency < stop && frequency > start) r.push((frequency - start) * 100 / width);
9060
+ if (frequency <= stop && frequency >= start) r.push((frequency - start) * 100 / width);
9056
9061
  }
9057
9062
  func?.({
9063
+ ...otherProps,
9058
9064
  pstype: constants_PSType.Marker,
9059
9065
  event: constants_MarkerEventType.Add,
9060
9066
  data: r
@@ -9995,6 +10001,7 @@ class LineMarkers extends Markers {
9995
10001
  }
9996
10002
  }
9997
10003
  class Selecter {
10004
+ state;
9998
10005
  constructor(){
9999
10006
  this.state = {
10000
10007
  onChange: [],
@@ -10014,7 +10021,7 @@ class Selecter {
10014
10021
  }
10015
10022
  });
10016
10023
  this.state.marker[parentID] = id;
10017
- if (attribute.select) this.state.onChange.forEach((i)=>i?.({
10024
+ if (attribute.select) this.state.onChange.forEach((callback)=>callback?.({
10018
10025
  select: true,
10019
10026
  parentID,
10020
10027
  attribute
@@ -10025,7 +10032,7 @@ class Selecter {
10025
10032
  const { marker } = this.state;
10026
10033
  const all = Object.entries(marker).every(([, v])=>!v);
10027
10034
  if (all) {
10028
- this.state.onChange.forEach((i)=>i?.({
10035
+ this.state.onChange.forEach((callback)=>callback?.({
10029
10036
  select: false,
10030
10037
  parentID,
10031
10038
  attribute: {}
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.14",
8
+ "version": "1.1.15",
9
9
  "private": false
10
10
  }
@@ -40,6 +40,7 @@ export interface SetMarker {
40
40
  event: MarkerEventType;
41
41
  data: number[];
42
42
  heatmapMode?: boolean;
43
+ clear?: boolean;
43
44
  }
44
45
  export interface SpectrumExtraData {
45
46
  [key: string]: Float32Array;