@rfkit/charts 1.5.0 → 1.5.1
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/README.md
CHANGED
|
@@ -94,7 +94,7 @@ export function GaugeDemo() {
|
|
|
94
94
|
- `SetSegments`
|
|
95
95
|
- `SetMarker`
|
|
96
96
|
|
|
97
|
-
`PublishSpectrum` 支持推送内置频谱数据线,包括 `data`、`maxData`、`minData`、`avgData`、`thresholdData`、`templateData`、`backgroundNoiseData` 和 `extraData
|
|
97
|
+
`PublishSpectrum` 支持推送内置频谱数据线,包括 `data`、`maxData`、`minData`、`avgData`、`thresholdData`、`templateData`、`backgroundNoiseData` 和 `extraData`。`thresholdData` 不传 `segmentOffset` / `offset` 时按整条门限替换;传入 `segmentOffset` 或 `offset` 时按局部门限写入。
|
|
98
98
|
|
|
99
99
|
工具栏相关命名统一使用:
|
|
100
100
|
|
package/config/setting.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1413,6 +1413,10 @@ var __webpack_modules__ = {
|
|
|
1413
1413
|
}
|
|
1414
1414
|
}
|
|
1415
1415
|
|
|
1416
|
+
[data-rfkit-charts-root] .border-primary\\/50 {
|
|
1417
|
+
border-color: var(--primary);
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1416
1420
|
@supports (color: color-mix(in lab, red, red)) {
|
|
1417
1421
|
[data-rfkit-charts-root] .border-primary\\/50 {
|
|
1418
1422
|
border-color: color-mix(in oklab, var(--primary) 50%, transparent);
|
|
@@ -4355,6 +4359,7 @@ const UI_CONFIG = {
|
|
|
4355
4359
|
ZOOM_MIN_RANGE: 10,
|
|
4356
4360
|
POPOVER_MARGIN: 16
|
|
4357
4361
|
};
|
|
4362
|
+
const SPECTRUM_THRESHOLD_COLOR = '#A855F7';
|
|
4358
4363
|
const setting_defaultConfig = {
|
|
4359
4364
|
line: {
|
|
4360
4365
|
realData: {
|
|
@@ -4387,7 +4392,7 @@ const setting_defaultConfig = {
|
|
|
4387
4392
|
},
|
|
4388
4393
|
thresholdData: {
|
|
4389
4394
|
name: 'thresholdData',
|
|
4390
|
-
color:
|
|
4395
|
+
color: SPECTRUM_THRESHOLD_COLOR,
|
|
4391
4396
|
thickness: 1,
|
|
4392
4397
|
label: "\u95E8\u9650\u503C",
|
|
4393
4398
|
display: true
|
|
@@ -18847,13 +18852,9 @@ class SpectrumAnalyzer {
|
|
|
18847
18852
|
if (!data?.length) return;
|
|
18848
18853
|
this.isProcessing = true;
|
|
18849
18854
|
this.hasProcessedData = true;
|
|
18850
|
-
|
|
18851
|
-
if (this.segments.length)
|
|
18852
|
-
|
|
18853
|
-
if (!segment) throw new DataValidationError(ERROR_MESSAGES.INVALID_SEGMENT(segmentOffset));
|
|
18854
|
-
index = segment.startIndex + offset;
|
|
18855
|
-
this.scanProgress = (index + data.length) / this.config.maxPoints;
|
|
18856
|
-
} else if (data.length !== this.config.maxPoints) this.updateMaxPoints(data.length);
|
|
18855
|
+
const index = this.resolveGlobalIndex(segmentOffset, offset);
|
|
18856
|
+
if (this.segments.length) this.scanProgress = (index + data.length) / this.config.maxPoints;
|
|
18857
|
+
else if (data.length !== this.config.maxPoints) this.updateMaxPoints(data.length);
|
|
18857
18858
|
if (fluorescenceData && void 0 !== fluorescenceMaxCount) {
|
|
18858
18859
|
this.fluorescenceData = fluorescenceData;
|
|
18859
18860
|
this.fluorescenceMaxCount = fluorescenceMaxCount;
|
|
@@ -18893,6 +18894,7 @@ class SpectrumAnalyzer {
|
|
|
18893
18894
|
}
|
|
18894
18895
|
initializeSegments(segments) {
|
|
18895
18896
|
if (!segments?.length) throw new DataValidationError(ERROR_MESSAGES.EMPTY_SEGMENTS);
|
|
18897
|
+
const prevMaxPoints = this.config.maxPoints;
|
|
18896
18898
|
let totalPoints = 0;
|
|
18897
18899
|
this.segments = segments.map((segment)=>{
|
|
18898
18900
|
const { startFrequency, stopFrequency, stepFrequency } = segment;
|
|
@@ -18909,7 +18911,17 @@ class SpectrumAnalyzer {
|
|
|
18909
18911
|
startIndex
|
|
18910
18912
|
};
|
|
18911
18913
|
});
|
|
18912
|
-
this.updateMaxPoints(totalPoints);
|
|
18914
|
+
this.updateMaxPoints(totalPoints, false);
|
|
18915
|
+
if (prevMaxPoints === totalPoints) {
|
|
18916
|
+
this.config = {
|
|
18917
|
+
...this.config,
|
|
18918
|
+
outputRange: {
|
|
18919
|
+
start: 0,
|
|
18920
|
+
end: totalPoints
|
|
18921
|
+
}
|
|
18922
|
+
};
|
|
18923
|
+
this.reset(false);
|
|
18924
|
+
}
|
|
18913
18925
|
}
|
|
18914
18926
|
setAntennaFactor(d) {
|
|
18915
18927
|
const { antennaFactorData, config: { maxPoints } } = this;
|
|
@@ -19133,8 +19145,9 @@ class SpectrumAnalyzer {
|
|
|
19133
19145
|
this.allocateMetricsBuffers();
|
|
19134
19146
|
this.clearMetricsBuffers();
|
|
19135
19147
|
this.templateData = new Float32Array;
|
|
19148
|
+
this.occupancyData = new Float32Array;
|
|
19136
19149
|
this.backgroundNoiseData = new Float32Array;
|
|
19137
|
-
this.
|
|
19150
|
+
this.clearThresholdDataState();
|
|
19138
19151
|
this.waterfallData = Array.from({
|
|
19139
19152
|
length: waterfallMaxFrames
|
|
19140
19153
|
}, ()=>{
|
|
@@ -19156,7 +19169,6 @@ class SpectrumAnalyzer {
|
|
|
19156
19169
|
this.templateOutputData = new Float32Array;
|
|
19157
19170
|
this.occupancyOutputData = new Float32Array;
|
|
19158
19171
|
this.backgroundNoiseOutputData = new Float32Array;
|
|
19159
|
-
this.thresholdOutputData = new Float32Array;
|
|
19160
19172
|
this.fluorescenceData = enableFluorescence ? new Uint32Array(maxPoints * FLUORESCENCE.LEVEL_RANGE) : new Uint32Array(0);
|
|
19161
19173
|
this.fluorescenceMaxCount = 0;
|
|
19162
19174
|
this.fluorescenceUpdateCounter = 0;
|
|
@@ -19253,16 +19265,30 @@ class SpectrumAnalyzer {
|
|
|
19253
19265
|
});
|
|
19254
19266
|
this.setPendingFlag("backgroundNoise", false);
|
|
19255
19267
|
}
|
|
19256
|
-
setThresholdData(data) {
|
|
19257
|
-
if (!data || 0 === data.length)
|
|
19258
|
-
|
|
19259
|
-
|
|
19260
|
-
|
|
19268
|
+
setThresholdData(data, options) {
|
|
19269
|
+
if (!data || 0 === data.length) return void this.clearThresholdDataState();
|
|
19270
|
+
const sourceData = data instanceof Float32Array ? data : new Float32Array(data);
|
|
19271
|
+
if (options) {
|
|
19272
|
+
const index = this.resolveGlobalIndex(options.segmentOffset ?? 0, options.offset ?? 0);
|
|
19273
|
+
this.validateInput(sourceData, index);
|
|
19274
|
+
if (this.thresholdData.length !== this.config.maxPoints) {
|
|
19275
|
+
const next = new Float32Array(this.config.maxPoints);
|
|
19276
|
+
next.fill(SPECTRUM.INITIAL_VALUE);
|
|
19277
|
+
if (this.thresholdData.length > 0) next.set(this.thresholdData.subarray(0, this.config.maxPoints));
|
|
19278
|
+
this.thresholdData = next;
|
|
19279
|
+
}
|
|
19280
|
+
this.thresholdData.set(sourceData, index);
|
|
19281
|
+
} else {
|
|
19282
|
+
const normalized = new Float32Array(this.config.maxPoints);
|
|
19283
|
+
normalized.fill(SPECTRUM.INITIAL_VALUE);
|
|
19284
|
+
normalized.set(sourceData.subarray(0, this.config.maxPoints));
|
|
19285
|
+
this.thresholdData = normalized;
|
|
19261
19286
|
}
|
|
19262
|
-
this.thresholdData = new Float32Array(data);
|
|
19263
19287
|
if (!this.hasProcessedData || this.isProcessing) return void this.setPendingFlag("threshold", true);
|
|
19288
|
+
const thresholdOutputData = this.resampleSingleData(this.thresholdData);
|
|
19289
|
+
this.thresholdOutputData = thresholdOutputData;
|
|
19264
19290
|
this.notifySpectrumUpdate({
|
|
19265
|
-
thresholdData:
|
|
19291
|
+
thresholdData: thresholdOutputData
|
|
19266
19292
|
});
|
|
19267
19293
|
this.setPendingFlag("threshold", false);
|
|
19268
19294
|
}
|
|
@@ -19296,6 +19322,19 @@ class SpectrumAnalyzer {
|
|
|
19296
19322
|
}
|
|
19297
19323
|
return templateOverData;
|
|
19298
19324
|
}
|
|
19325
|
+
resolveGlobalIndex(segmentOffset = 0, offset = 0) {
|
|
19326
|
+
if (this.segments.length) {
|
|
19327
|
+
const segment = this.segments[segmentOffset];
|
|
19328
|
+
if (!segment) throw new DataValidationError(ERROR_MESSAGES.INVALID_SEGMENT(segmentOffset));
|
|
19329
|
+
return segment.startIndex + offset;
|
|
19330
|
+
}
|
|
19331
|
+
return offset;
|
|
19332
|
+
}
|
|
19333
|
+
clearThresholdDataState() {
|
|
19334
|
+
this.thresholdData = new Float32Array(0);
|
|
19335
|
+
this.thresholdOutputData = new Float32Array(0);
|
|
19336
|
+
this.setPendingFlag("threshold", false);
|
|
19337
|
+
}
|
|
19299
19338
|
resampleDataSeries() {
|
|
19300
19339
|
const { antennaFactorData, antennaFactorSwitch, maxData, minData, avgData, templateData, occupancyData, backgroundNoiseData, thresholdData, config: { maxPoints, outputPoints } } = this;
|
|
19301
19340
|
const activeAntennaFactorData = antennaFactorSwitch ? antennaFactorData : new Float32Array(maxPoints);
|
|
@@ -19368,7 +19407,7 @@ class SpectrumAnalyzer {
|
|
|
19368
19407
|
this.waterfallData.push(newData);
|
|
19369
19408
|
this.waterfallOutputData.push(outputData);
|
|
19370
19409
|
}
|
|
19371
|
-
updateMaxPoints(maxPoints) {
|
|
19410
|
+
updateMaxPoints(maxPoints, preserveProcessedFlag = true) {
|
|
19372
19411
|
if (this.config.maxPoints === maxPoints) return;
|
|
19373
19412
|
this.config = {
|
|
19374
19413
|
...this.config,
|
|
@@ -19378,7 +19417,7 @@ class SpectrumAnalyzer {
|
|
|
19378
19417
|
end: maxPoints
|
|
19379
19418
|
}
|
|
19380
19419
|
};
|
|
19381
|
-
this.reset(
|
|
19420
|
+
this.reset(preserveProcessedFlag);
|
|
19382
19421
|
}
|
|
19383
19422
|
validateInput(data, index) {
|
|
19384
19423
|
if (index < 0 || index + data.length > this.config.maxPoints) throw new IndexOutOfBoundsError(ERROR_MESSAGES.INDEX_OUT_OF_BOUNDS(index), index);
|
|
@@ -19452,7 +19491,9 @@ class SpectrumAnalyzer {
|
|
|
19452
19491
|
this.setPendingFlag("backgroundNoise", false);
|
|
19453
19492
|
}
|
|
19454
19493
|
if (this.pendingDataFlags["threshold"] && this.thresholdData.length > 0) {
|
|
19455
|
-
|
|
19494
|
+
const thresholdOutputData = this.resampleSingleData(this.thresholdData);
|
|
19495
|
+
this.thresholdOutputData = thresholdOutputData;
|
|
19496
|
+
pendingOutput.thresholdData = thresholdOutputData;
|
|
19456
19497
|
this.setPendingFlag("threshold", false);
|
|
19457
19498
|
}
|
|
19458
19499
|
if (this.pendingDataFlags["extra"] && Object.keys(this.extraData).length > 0) {
|
|
@@ -26950,6 +26991,12 @@ const FrequencyTagLine_FrequencyTagLine = (props)=>{
|
|
|
26950
26991
|
});
|
|
26951
26992
|
};
|
|
26952
26993
|
const FrequencyTagLine = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].memo(FrequencyTagLine_FrequencyTagLine);
|
|
26994
|
+
const LIMIT_THRESHOLD_TEXT_STYLE = {
|
|
26995
|
+
color: SPECTRUM_THRESHOLD_COLOR
|
|
26996
|
+
};
|
|
26997
|
+
const LIMIT_THRESHOLD_LINE_STYLE = {
|
|
26998
|
+
borderColor: SPECTRUM_THRESHOLD_COLOR
|
|
26999
|
+
};
|
|
26953
27000
|
const Item_Item = ({ value: value1, onChange })=>{
|
|
26954
27001
|
const { state: { axisY, limit } } = useStore_useStore();
|
|
26955
27002
|
const { label, disabled } = limit;
|
|
@@ -27014,6 +27061,7 @@ const Item_Item = ({ value: value1, onChange })=>{
|
|
|
27014
27061
|
type: "button",
|
|
27015
27062
|
disabled: disabled,
|
|
27016
27063
|
className: "pointer-events-auto absolute right-7 top-[-28px] z-[8] flex h-6 appearance-none items-center justify-center rounded-[var(--radius-control)] border-0 bg-secondary px-2 text-xs text-foreground",
|
|
27064
|
+
style: LIMIT_THRESHOLD_TEXT_STYLE,
|
|
27017
27065
|
onClick: ()=>setIsEdit(true),
|
|
27018
27066
|
children: [
|
|
27019
27067
|
label,
|
|
@@ -27023,6 +27071,7 @@ const Item_Item = ({ value: value1, onChange })=>{
|
|
|
27023
27071
|
]
|
|
27024
27072
|
}) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
|
|
27025
27073
|
className: "pointer-events-auto absolute right-7 top-[-28px] z-[8] flex h-6 items-center justify-between bg-secondary px-2 text-xs text-foreground",
|
|
27074
|
+
style: LIMIT_THRESHOLD_TEXT_STYLE,
|
|
27026
27075
|
children: [
|
|
27027
27076
|
label,
|
|
27028
27077
|
"\xa0",
|
|
@@ -27034,7 +27083,8 @@ const Item_Item = ({ value: value1, onChange })=>{
|
|
|
27034
27083
|
min: min,
|
|
27035
27084
|
max: max,
|
|
27036
27085
|
step: step / 5,
|
|
27037
|
-
className: "h-auto w-14 border-none bg-transparent p-0 text-center
|
|
27086
|
+
className: "h-auto w-14 border-none bg-transparent p-0 text-center outline-none [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
|
|
27087
|
+
style: LIMIT_THRESHOLD_TEXT_STYLE,
|
|
27038
27088
|
onKeyDown: onEnter
|
|
27039
27089
|
}),
|
|
27040
27090
|
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
@@ -27044,7 +27094,8 @@ const Item_Item = ({ value: value1, onChange })=>{
|
|
|
27044
27094
|
]
|
|
27045
27095
|
}),
|
|
27046
27096
|
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
27047
|
-
className: "absolute right-0 top-[-0.5px] z-[8] h-0 w-full border-b border-dashed
|
|
27097
|
+
className: "absolute right-0 top-[-0.5px] z-[8] h-0 w-full border-b border-dashed",
|
|
27098
|
+
style: LIMIT_THRESHOLD_LINE_STYLE
|
|
27048
27099
|
})
|
|
27049
27100
|
]
|
|
27050
27101
|
})
|
|
@@ -29587,6 +29638,16 @@ const useMarkerPublish_useMarkerPublish = ({ globalID })=>{
|
|
|
29587
29638
|
};
|
|
29588
29639
|
};
|
|
29589
29640
|
const useMarkerPublish = useMarkerPublish_useMarkerPublish;
|
|
29641
|
+
function resolveThresholdDataOptions({ segmentOffset, offset }) {
|
|
29642
|
+
const options = {};
|
|
29643
|
+
if (void 0 !== segmentOffset) options.segmentOffset = segmentOffset;
|
|
29644
|
+
if (void 0 !== offset) options.offset = offset;
|
|
29645
|
+
return void 0 !== options.segmentOffset || void 0 !== options.offset ? options : void 0;
|
|
29646
|
+
}
|
|
29647
|
+
function setAnalyzerThresholdData(analyzer, payload) {
|
|
29648
|
+
if (!('thresholdData' in payload)) return;
|
|
29649
|
+
analyzer.setThresholdData(payload.thresholdData, resolveThresholdDataOptions(payload));
|
|
29650
|
+
}
|
|
29590
29651
|
function useTemplateComparison() {
|
|
29591
29652
|
const { state: { globalID, axisX: { frequencyFormat }, signal: { onChange } } } = useStore_useStore();
|
|
29592
29653
|
const frequencyFormatRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(frequencyFormat);
|
|
@@ -29764,7 +29825,7 @@ function useSpectrumAnalyzer(props) {
|
|
|
29764
29825
|
break;
|
|
29765
29826
|
case constants_PSType.Spectrum:
|
|
29766
29827
|
if (e.data) analyzer.current.process(e);
|
|
29767
|
-
|
|
29828
|
+
setAnalyzerThresholdData(analyzer.current, e);
|
|
29768
29829
|
if (e.maxData) analyzer.current.setMaxData(e.maxData);
|
|
29769
29830
|
if (e.minData) analyzer.current.setMinData(e.minData);
|
|
29770
29831
|
if (e.avgData) analyzer.current.setAvgData(e.avgData);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PublishSpectrum } from '../../../types';
|
|
2
|
+
export type SpectrumThresholdDataOptions = Pick<PublishSpectrum, 'segmentOffset' | 'offset'>;
|
|
3
|
+
export declare function resolveThresholdDataOptions({ segmentOffset, offset }: SpectrumThresholdDataOptions): SpectrumThresholdDataOptions | undefined;
|
|
4
|
+
type ThresholdDataTarget = {
|
|
5
|
+
setThresholdData: (data?: PublishSpectrum['thresholdData'], options?: SpectrumThresholdDataOptions) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function setAnalyzerThresholdData(analyzer: ThresholdDataTarget, payload: PublishSpectrum): void;
|
|
8
|
+
export {};
|