@rfkit/charts 1.9.0 → 1.10.0

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
@@ -96,6 +96,8 @@ export function GaugeDemo() {
96
96
 
97
97
  `PublishSpectrum` 支持推送内置频谱数据线,包括 `data`、`maxData`、`minData`、`avgData`、`thresholdData`、`templateData`、`backgroundNoiseData` 和 `extraData`。`thresholdData` 不传 `segmentOffset` / `offset` 时按整条门限替换;传入 `segmentOffset` 或 `offset` 时按局部门限写入。
98
98
 
99
+ `extraData` 默认保持完整数组设置语义;设置 `segmentedExtraData: true` 后,同一次推送中的每条额外频谱线会独立使用 `segmentOffset + offset` 拼接,并随主实时值同步缩放。
100
+
99
101
  独立 `Heatmap` 可以显式开启 X/Y 同步缩放:
100
102
 
101
103
  ```tsx
@@ -1,6 +1,7 @@
1
- import React, { type ReactNode } from 'react';
1
+ import React, { type ReactNode, type WheelEventHandler } from 'react';
2
2
  interface Props {
3
3
  children: ReactNode;
4
+ onWheelCapture?: WheelEventHandler<HTMLDivElement>;
4
5
  }
5
6
  declare const _default: React.NamedExoticComponent<Props>;
6
7
  export default _default;
package/index.js CHANGED
@@ -19567,20 +19567,52 @@ class SpectrumAnalyzer {
19567
19567
  });
19568
19568
  this.setPendingFlag("occupancy", false);
19569
19569
  }
19570
- setExtraData(data, mode = types_ExtraDataMode.MERGE) {
19571
- if (mode === types_ExtraDataMode.CLEAR || mode === types_ExtraDataMode.REPLACE) {
19570
+ setExtraData(data, mode = types_ExtraDataMode.MERGE, options) {
19571
+ if (mode === types_ExtraDataMode.CLEAR) {
19572
19572
  this.extraData = {};
19573
19573
  this.extraOutputData = {};
19574
19574
  this.setPendingFlag("extra", false);
19575
+ return;
19575
19576
  }
19576
- if (mode === types_ExtraDataMode.CLEAR) return;
19577
- if (!data) return;
19578
- for (const [key, value1] of Object.entries(data)){
19579
- if (!value1 || 0 === value1.length) {
19577
+ if (!data) {
19578
+ if (mode === types_ExtraDataMode.REPLACE) {
19579
+ this.extraData = {};
19580
+ this.extraOutputData = {};
19581
+ this.setPendingFlag("extra", false);
19582
+ }
19583
+ return;
19584
+ }
19585
+ const entries = Object.entries(data).map(([key, value1])=>[
19586
+ key,
19587
+ value1?.length ? new Float32Array(value1) : null
19588
+ ]);
19589
+ const index = options ? this.resolveGlobalIndex(options.segmentOffset ?? 0, options.offset ?? 0) : 0;
19590
+ if (options) {
19591
+ for (const [, value1] of entries)if (value1) this.validateInput(value1, index);
19592
+ }
19593
+ if (mode === types_ExtraDataMode.REPLACE) {
19594
+ this.extraData = {};
19595
+ this.extraOutputData = {};
19596
+ this.setPendingFlag("extra", false);
19597
+ }
19598
+ for (const [key, value1] of entries){
19599
+ if (!value1) {
19580
19600
  delete this.extraData[key];
19581
19601
  continue;
19582
19602
  }
19583
- this.extraData[key] = new Float32Array(value1);
19603
+ if (!options) {
19604
+ this.extraData[key] = value1;
19605
+ continue;
19606
+ }
19607
+ let target = this.extraData[key];
19608
+ if (target?.length !== this.config.maxPoints) {
19609
+ const next = new Float32Array(this.config.maxPoints);
19610
+ next.fill(SPECTRUM.INITIAL_VALUE);
19611
+ if (target?.length) next.set(target.subarray(0, this.config.maxPoints));
19612
+ target = next;
19613
+ this.extraData[key] = target;
19614
+ }
19615
+ target.set(value1, index);
19584
19616
  }
19585
19617
  if (!this.hasProcessedData || this.isProcessing) return void this.setPendingFlag("extra", true);
19586
19618
  this.extraOutputData = resampleExtraData(this.extraData, this.antennaFactorData, this.antennaFactorSwitch, this.srcIndexCache, this.getOutputData.bind(this));
@@ -23502,13 +23534,14 @@ const Boundary_Boundary = ()=>{
23502
23534
  };
23503
23535
  const Boundary = Boundary_Boundary;
23504
23536
  const PluginBox_PluginBox = (props)=>{
23505
- const { children } = props;
23537
+ const { children, onWheelCapture } = props;
23506
23538
  const { pluginBoxWidth } = useAxisYWidth_useAxisYWidth();
23507
23539
  return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
23508
23540
  className: "absolute right-0 top-0 m-0 h-full overflow-hidden p-0",
23509
23541
  style: {
23510
23542
  width: pluginBoxWidth
23511
23543
  },
23544
+ onWheelCapture: onWheelCapture,
23512
23545
  children: children
23513
23546
  });
23514
23547
  };
@@ -25408,6 +25441,20 @@ const Heatmap_Heatmap = (props)=>{
25408
25441
  globalID
25409
25442
  }
25410
25443
  });
25444
+ const dispatchXYWheel = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
25445
+ const eventBusID = getEID(id);
25446
+ return throttle((wheel, coord)=>{
25447
+ createWheelEventManager(eventBusID)(wheel, coord);
25448
+ });
25449
+ }, [
25450
+ id
25451
+ ]);
25452
+ const handleXYWheelCapture = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((event)=>{
25453
+ event.stopPropagation();
25454
+ dispatchXYWheel(-1 * event.deltaY, calculateEventRelativePosition(event));
25455
+ }, [
25456
+ dispatchXYWheel
25457
+ ]);
25411
25458
  useWaterfallZoomEvent(id, xyZoom);
25412
25459
  useModuleSubscription({
25413
25460
  moduleType: constants_ModuleType.Heatmap,
@@ -25440,6 +25487,7 @@ const Heatmap_Heatmap = (props)=>{
25440
25487
  chart: chart
25441
25488
  }),
25442
25489
  /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(PluginBox, {
25490
+ onWheelCapture: xyZoom ? handleXYWheelCapture : void 0,
25443
25491
  children: [
25444
25492
  /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(Boundary, {}),
25445
25493
  /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(Chart, {}),
@@ -33001,7 +33049,10 @@ function useSpectrumAnalyzer(props) {
33001
33049
  if (e.avgData) analyzer.current.setAvgData(e.avgData);
33002
33050
  if (e.templateData) analyzer.current.setTemplateData(e.templateData, e.templateTolerance);
33003
33051
  if (e.backgroundNoiseData) analyzer.current.setBackgroundNoiseData(e.backgroundNoiseData);
33004
- if (e.extraData) analyzer.current?.setExtraData(e.extraData);
33052
+ if (e.extraData) analyzer.current.setExtraData(e.extraData, types_ExtraDataMode.MERGE, e.segmentedExtraData ? {
33053
+ segmentOffset: e.segmentOffset,
33054
+ offset: e.offset
33055
+ } : void 0);
33005
33056
  break;
33006
33057
  case constants_PSType.Fluorescence:
33007
33058
  if (e.data && analyzer.current) analyzer.current.setFluorescenceData(e.data.fluorescenceData, e.data.fluorescenceMaxCount);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rfkit/charts",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "type": "module",
5
5
  "description": "Chart components for wireless monitoring web applications",
6
6
  "exports": {
@@ -58,6 +58,7 @@ export interface PublishSpectrum {
58
58
  templateData?: Float32Array;
59
59
  templateTolerance?: number;
60
60
  extraData?: SpectrumExtraData;
61
+ segmentedExtraData?: boolean;
61
62
  timestamp?: string;
62
63
  offset?: number;
63
64
  segmentOffset?: number;