@rfkit/charts 1.2.2 → 1.2.3
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/index.js +35 -26
- package/package.json +1 -1
- package/utils/series/index.d.ts +1 -0
- package/utils/series/subscription.d.ts +43 -0
package/index.js
CHANGED
|
@@ -7558,6 +7558,37 @@ function toggleSeriesMode(globalID, currentMode) {
|
|
|
7558
7558
|
const nextMode = getNextMode(mode);
|
|
7559
7559
|
setSeriesMode(globalID, nextMode);
|
|
7560
7560
|
}
|
|
7561
|
+
function initSeriesSubscription(renderer) {
|
|
7562
|
+
const { globalID } = renderer.state;
|
|
7563
|
+
if (!globalID) {
|
|
7564
|
+
console.warn("[Series] globalID is required for series subscription");
|
|
7565
|
+
return null;
|
|
7566
|
+
}
|
|
7567
|
+
const subscriptions = [];
|
|
7568
|
+
subscriptions.push(subscribeToSeries(globalID, events_SeriesEventName.UPDATED, (data)=>{
|
|
7569
|
+
renderer.setSeries(data.config, true);
|
|
7570
|
+
renderer.state.chart?.draw();
|
|
7571
|
+
}));
|
|
7572
|
+
subscriptions.push(subscribeToSeries(globalID, events_SeriesEventName.MODE_CHANGED, ()=>{
|
|
7573
|
+
renderer.initSeries();
|
|
7574
|
+
}));
|
|
7575
|
+
subscriptions.push(subscribeToSeries(globalID, events_SeriesEventName.TYPE_OVERRIDE_CHANGED, ()=>{
|
|
7576
|
+
renderer.initSeries();
|
|
7577
|
+
}));
|
|
7578
|
+
subscriptions.push(subscribeToSeries(globalID, events_SeriesEventName.BATCH_UPDATED, (data)=>{
|
|
7579
|
+
data.configs.forEach((config)=>{
|
|
7580
|
+
renderer.setSeries(config, true);
|
|
7581
|
+
});
|
|
7582
|
+
renderer.state.chart?.draw();
|
|
7583
|
+
}));
|
|
7584
|
+
subscriptions.push(subscribeToSeries(globalID, events_SeriesEventName.RESET, ()=>{
|
|
7585
|
+
if (renderer.state.series) renderer.state.series = {};
|
|
7586
|
+
renderer.initSeries();
|
|
7587
|
+
}));
|
|
7588
|
+
return ()=>{
|
|
7589
|
+
for (const unsubscribe of subscriptions)unsubscribe();
|
|
7590
|
+
};
|
|
7591
|
+
}
|
|
7561
7592
|
const chartTypeSeriesOverrides = new Map();
|
|
7562
7593
|
function setChartTypeSeriesOverride(globalID, seriesName, type) {
|
|
7563
7594
|
if (!chartTypeSeriesOverrides.has(globalID)) chartTypeSeriesOverrides.set(globalID, new Map());
|
|
@@ -10113,29 +10144,7 @@ class Spectrum {
|
|
|
10113
10144
|
this.initSeriesSubscription();
|
|
10114
10145
|
}
|
|
10115
10146
|
initSeriesSubscription() {
|
|
10116
|
-
|
|
10117
|
-
const subscriptions = [];
|
|
10118
|
-
subscriptions.push(subscribeToSeries(this.state.globalID, events_SeriesEventName.UPDATED, (data)=>{
|
|
10119
|
-
this.setSeries(data.config, true);
|
|
10120
|
-
}));
|
|
10121
|
-
subscriptions.push(subscribeToSeries(this.state.globalID, events_SeriesEventName.MODE_CHANGED, ()=>{
|
|
10122
|
-
this.initSeries();
|
|
10123
|
-
}));
|
|
10124
|
-
subscriptions.push(subscribeToSeries(this.state.globalID, events_SeriesEventName.TYPE_OVERRIDE_CHANGED, ()=>{
|
|
10125
|
-
this.initSeries();
|
|
10126
|
-
}));
|
|
10127
|
-
subscriptions.push(subscribeToSeries(this.state.globalID, events_SeriesEventName.BATCH_UPDATED, (data)=>{
|
|
10128
|
-
data.configs.forEach((config)=>{
|
|
10129
|
-
this.setSeries(config, true);
|
|
10130
|
-
});
|
|
10131
|
-
}));
|
|
10132
|
-
subscriptions.push(subscribeToSeries(this.state.globalID, events_SeriesEventName.RESET, ()=>{
|
|
10133
|
-
this.state.series = {};
|
|
10134
|
-
this.initSeries();
|
|
10135
|
-
}));
|
|
10136
|
-
this.seriesUnsubscribe = ()=>{
|
|
10137
|
-
for (const unsubscribe of subscriptions)unsubscribe();
|
|
10138
|
-
};
|
|
10147
|
+
this.seriesUnsubscribe = initSeriesSubscription(this) || void 0;
|
|
10139
10148
|
}
|
|
10140
10149
|
init() {
|
|
10141
10150
|
const { id, renderRange } = this.state;
|
|
@@ -15628,7 +15637,7 @@ const Zoom_Zoom = ()=>{
|
|
|
15628
15637
|
return null;
|
|
15629
15638
|
};
|
|
15630
15639
|
const Zoom = Zoom_Zoom;
|
|
15631
|
-
const
|
|
15640
|
+
const useMarkerPublish_useMarkerPublish = ({ globalID })=>{
|
|
15632
15641
|
const handleMarkerPublish = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((e)=>{
|
|
15633
15642
|
if (!globalID) return;
|
|
15634
15643
|
switch(e.pstype){
|
|
@@ -15650,7 +15659,7 @@ const useMarkerPublish = ({ globalID })=>{
|
|
|
15650
15659
|
handleMarkerPublish
|
|
15651
15660
|
};
|
|
15652
15661
|
};
|
|
15653
|
-
const
|
|
15662
|
+
const useMarkerPublish = useMarkerPublish_useMarkerPublish;
|
|
15654
15663
|
function useTemplateComparison() {
|
|
15655
15664
|
const { state: { globalID, axisX: { frequencyFormat }, signal: { onChange } } } = useStore_useStore();
|
|
15656
15665
|
const frequencyFormatRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(frequencyFormat);
|
|
@@ -16172,7 +16181,7 @@ const Spectrum_Chart_Chart = (props)=>{
|
|
|
16172
16181
|
}
|
|
16173
16182
|
});
|
|
16174
16183
|
const handleSpectrumRule = useSpectrumRule();
|
|
16175
|
-
const { handleMarkerPublish } =
|
|
16184
|
+
const { handleMarkerPublish } = useMarkerPublish({
|
|
16176
16185
|
globalID
|
|
16177
16186
|
});
|
|
16178
16187
|
hooks_usePublish({
|
package/package.json
CHANGED
package/utils/series/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export declare function resetSeries(globalID: string): void;
|
|
|
58
58
|
export declare function batchUpdateSeries(globalID: string, configs: PartialSeriesConfig[]): void;
|
|
59
59
|
export * from './events';
|
|
60
60
|
export * from './modes';
|
|
61
|
+
export * from './subscription';
|
|
61
62
|
/**
|
|
62
63
|
* 获取带有正确 GraphicType 的 series 配置
|
|
63
64
|
* 优先级:ChartType 覆盖 > SeriesMode 配置 > 默认类型
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Series 订阅工具
|
|
3
|
+
* 提供可复用的 series 事件订阅函数
|
|
4
|
+
*/
|
|
5
|
+
import type { SeriesConfig } from './index';
|
|
6
|
+
/**
|
|
7
|
+
* Series 渲染器接口
|
|
8
|
+
* 定义渲染器必须实现的方法
|
|
9
|
+
*/
|
|
10
|
+
export interface SeriesRenderer {
|
|
11
|
+
state: {
|
|
12
|
+
globalID?: string;
|
|
13
|
+
chart?: {
|
|
14
|
+
draw: () => void;
|
|
15
|
+
};
|
|
16
|
+
series?: Record<string, unknown>;
|
|
17
|
+
};
|
|
18
|
+
setSeries: (config: SeriesConfig, skipEvent?: boolean) => void;
|
|
19
|
+
initSeries: () => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 初始化 Series 事件订阅
|
|
23
|
+
*
|
|
24
|
+
* @param renderer 渲染器实例(必须实现 SeriesRenderer 接口)
|
|
25
|
+
* @returns 取消订阅函数
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* class MyRender implements SeriesRenderer {
|
|
30
|
+
* private seriesUnsubscribe: (() => void) | null = null;
|
|
31
|
+
*
|
|
32
|
+
* constructor(props: any) {
|
|
33
|
+
* this.state = { chart: null, globalID: props.globalID };
|
|
34
|
+
* this.seriesUnsubscribe = initSeriesSubscription(this);
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* destroy() {
|
|
38
|
+
* this.seriesUnsubscribe?.();
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function initSeriesSubscription(renderer: SeriesRenderer): (() => void) | null;
|