waveform-analysis 0.1.30 → 0.1.32
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 +12 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +827 -602
- package/dist/style.css +1 -1
- package/dist/types/components/WaveformChart.vue.d.ts +2 -2
- package/dist/types/components/core/useWaveformChartController.d.ts +2 -14
- package/dist/types/components/core/useWaveformChartLifecycle.d.ts +4 -1
- package/dist/types/components/core/useWaveformData.d.ts +1 -1
- package/dist/types/components/core/waveformChartTypes.d.ts +8 -5
- package/dist/types/components/data/types.d.ts +1 -1
- package/dist/types/components/interaction/pointerCapture.d.ts +1 -0
- package/dist/types/components/interaction/viewportInteractionState.d.ts +39 -0
- package/dist/types/components/interaction/zoomConstraints.d.ts +14 -0
- package/dist/types/core/rendering.d.ts +1 -4
- package/dist/types/core/renderingStrategies.d.ts +22 -0
- package/dist/types/demo/types.d.ts +0 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types/chart.d.ts +5 -0
- package/dist/types/types/index.d.ts +1 -1
- package/package.json +5 -1
- package/src/App.vue +0 -4
- package/src/components/WaveformChartView.vue +2 -2
- package/src/components/core/useWaveformChartController.ts +7 -2
- package/src/components/core/useWaveformChartLifecycle.ts +47 -3
- package/src/components/core/useWaveformData.ts +6 -1
- package/src/components/core/waveformChartTypes.ts +6 -4
- package/src/components/data/types.ts +1 -0
- package/src/components/interaction/WaveformTooltip.test.ts +39 -0
- package/src/components/interaction/WaveformTooltip.vue +72 -22
- package/src/components/interaction/pointerCapture.ts +10 -0
- package/src/components/interaction/useWaveformHover.ts +1 -1
- package/src/components/interaction/useWaveformViewport.ts +101 -75
- package/src/components/interaction/useWaveformZoom.ts +46 -14
- package/src/components/interaction/viewportInteractionState.test.ts +101 -0
- package/src/components/interaction/viewportInteractionState.ts +89 -0
- package/src/components/interaction/zoomConstraints.ts +167 -0
- package/src/components/waveformChartCases/viewportConstraintsAndReset.test.ts +0 -65
- package/src/components/waveformChartCases/viewportLifecycle.test.ts +132 -0
- package/src/components/waveformChartCases/viewportReset.test.ts +114 -0
- package/src/components/waveformChartCases/zoomPointConstraints.test.ts +248 -0
- package/src/core/rendering.ts +11 -81
- package/src/core/renderingStrategies.test.ts +90 -0
- package/src/core/renderingStrategies.ts +131 -0
- package/src/data/simulatedWaveforms.ts +9 -10
- package/src/demo/DemoChartHost.vue +1 -2
- package/src/demo/types.ts +0 -1
- package/src/index.ts +1 -0
- package/src/types/chart.ts +6 -0
- package/src/types/index.ts +1 -0
- package/src/utils/formatters.test.ts +4 -3
- package/src/utils/formatters.ts +1 -2
- package/src/utils/sampling.ts +2 -1
package/src/utils/formatters.ts
CHANGED
|
@@ -42,8 +42,7 @@ export function shouldUseScientificAxisLabel(maxAbsoluteValue: number): boolean
|
|
|
42
42
|
export function resolveScientificAxisExponent(axisMin?: number, axisMax?: number): number | null {
|
|
43
43
|
if (typeof axisMin !== 'number' || typeof axisMax !== 'number') return null
|
|
44
44
|
|
|
45
|
-
const
|
|
46
|
-
const absoluteMaxValue = Math.abs(maxValue)
|
|
45
|
+
const absoluteMaxValue = Math.max(Math.abs(axisMin), Math.abs(axisMax))
|
|
47
46
|
return shouldUseScientificAxisLabel(absoluteMaxValue)
|
|
48
47
|
? Math.floor(Math.log10(absoluteMaxValue))
|
|
49
48
|
: null
|
package/src/utils/sampling.ts
CHANGED
|
@@ -37,7 +37,8 @@ export function downsampleLTTB(data: WaveformPoint[], threshold: number): Wavefo
|
|
|
37
37
|
|
|
38
38
|
// 确保阈值至少为 3
|
|
39
39
|
const sampledLength = Math.max(3, Math.floor(threshold))
|
|
40
|
-
const sampled: WaveformPoint[] =
|
|
40
|
+
const sampled: WaveformPoint[] = []
|
|
41
|
+
sampled.length = sampledLength
|
|
41
42
|
|
|
42
43
|
// 始终保留第一个和最后一个点
|
|
43
44
|
sampled[0] = data[0]!
|