first commit
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
李启源
2026-07-20 10:21:30 +08:00
commit ea832229da
75 changed files with 16864 additions and 0 deletions

161
src/App.vue Normal file
View File

@@ -0,0 +1,161 @@
<script setup lang="ts">
import { InputNumber, Radio, Tag } from 'ant-design-vue'
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import {
WaveformChart,
type WaveformAnnotation,
type WaveformData,
type WaveformDisplayMode,
type WaveformInteractionMode,
type WaveformSeries,
} from './components'
import waveformJson from './data/wData.json'
interface WaveformSourceRow {
chnl: string
chnl_id: number
dat_unit: string
data: number[]
dev: number
shot: number
time: number[]
time_unit: 'ms'
}
const importedSourceRows = waveformJson as unknown as WaveformSourceRow[]
const testChannelRows: WaveformSourceRow[] = importedSourceRows.slice(0, 2).map((row, index) => ({
...row,
chnl: `TEST_CH_${index + 1}`,
chnl_id: 9001 + index,
data: row.data.map(
(value, sampleIndex) =>
value * (index === 0 ? 0.72 : 1.12) +
Math.sin(sampleIndex / (index === 0 ? 11 : 18)) * (index === 0 ? 0.015 : 0.01),
),
}))
const sourceRows = [...importedSourceRows, ...testChannelRows]
const visibleRange = ref<[number, number] | null>(null)
const displayMode = ref<WaveformDisplayMode>('independent')
const rowCount = ref(2)
const columnCount = ref(1)
const annotations = ref<WaveformAnnotation[]>([])
const annotationsVisible = ref(true)
const interactionMode = ref<WaveformInteractionMode>('zoom')
const resolveChartHeight = () =>
Math.min(800, Math.max(560, (typeof window === 'undefined' ? 750 : window.innerHeight) - 190))
const chartHeight = ref(resolveChartHeight())
const waveformSeries: WaveformSeries[] = sourceRows.map((row) => {
const pointCount = Math.min(row.time.length, row.data.length)
return {
id: String(row.chnl_id),
name: row.chnl,
unit: row.dat_unit,
data: {
kind: 'points',
points: Array.from({ length: pointCount }, (_, index) => ({
x: row.time[index] / 1000,
y: row.data[index],
})),
},
}
})
const chartData: WaveformData = { kind: 'series', series: waveformSeries }
const totalPointCount = waveformSeries.reduce((total, series) => {
const seriesPointCount =
series.data.kind === 'points' ? series.data.points.length : series.data.values.length
return total + seriesPointCount
}, 0)
const initialTimeRange: [number, number] = [
Math.min(...sourceRows.flatMap((row) => row.time)) / 1000,
Math.max(...sourceRows.flatMap((row) => row.time)) / 1000,
]
const displayedRange = computed(() => visibleRange.value ?? initialTimeRange)
const formatMilliseconds = (seconds: number) =>
(seconds * 1000).toLocaleString('zh-CN', { maximumFractionDigits: 1 })
function updateChartHeight() {
chartHeight.value = resolveChartHeight()
}
watch(displayMode, () => {
visibleRange.value = null
})
watch([rowCount, columnCount], () => {
visibleRange.value = null
})
onMounted(() => {
window.addEventListener('resize', updateChartHeight)
})
onBeforeUnmount(() => {
window.removeEventListener('resize', updateChartHeight)
})
</script>
<template>
<main class="workspace">
<header class="workspace__header">
<div>
<p class="workspace__eyebrow">Vue 3 · TypeScript · D3</p>
<h1>波形分析组件</h1>
</div>
</header>
<section class="control-bar" aria-label="波形图控制与摘要">
<div class="control-bar__leading">
<Tag color="blue">真实 + 测试数据</Tag>
<Radio.Group
v-model:value="displayMode"
class="display-mode-control"
button-style="solid"
size="small"
aria-label="波形展示方式"
>
<Radio.Button value="independent">单独坐标</Radio.Button>
<Radio.Button value="separated">多道分离</Radio.Button>
<Radio.Button value="compact">多道紧凑</Radio.Button>
</Radio.Group>
<div class="grid-size-control" aria-label="波形网格尺寸">
<span>网格</span>
<InputNumber v-model:value="rowCount" :min="1" :max="10" size="small" />
<span> ×</span>
<InputNumber v-model:value="columnCount" :min="1" :max="10" size="small" />
<span></span>
</div>
</div>
<div class="metrics">
<span>{{ sourceRows.length }} 通道</span>
<span>{{ totalPointCount.toLocaleString() }} 数据点</span>
<span>{{ annotations.length }} 标注</span>
<span>炮号 {{ sourceRows[0]?.shot }}</span>
<span>设备 {{ sourceRows[0]?.dev }}</span>
<span>
范围 {{ formatMilliseconds(displayedRange[0]) }}{{
formatMilliseconds(displayedRange[1])
}}
ms
</span>
</div>
</section>
<section class="chart-panel">
<WaveformChart
:data="chartData"
:display-mode="displayMode"
:grid="{ rowCount, columnCount, showPagination: true }"
:height="chartHeight"
:frame-number="1"
v-model:annotations="annotations"
v-model:annotations-visible="annotationsVisible"
v-model:interaction-mode="interactionMode"
@zoom-change="visibleRange = $event"
/>
</section>
</main>
</template>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,59 @@
<script setup lang="ts">
interface Props {
visible: boolean
x: number
y: number
canEdit: boolean
}
const props = defineProps<Props>()
const emit = defineEmits<{
(event: 'edit'): void
(event: 'delete'): void
(event: 'close'): void
}>()
</script>
<template>
<div
v-if="props.visible && props.canEdit"
class="waveform-annotation-context-menu"
:style="{ left: `${props.x}px`, top: `${props.y}px` }"
role="menu"
@contextmenu.prevent
>
<button type="button" role="menuitem" @click="emit('edit')">编辑标注</button>
<button type="button" role="menuitem" @click="emit('delete')">删除标注</button>
<button type="button" role="menuitem" @click="emit('close')">取消</button>
</div>
</template>
<style scoped>
.waveform-annotation-context-menu {
position: absolute;
z-index: 30;
display: grid;
min-width: 112px;
padding: 4px;
background: #fff;
border: 1px solid #dfe5ef;
border-radius: 4px;
box-shadow: 0 4px 14px rgb(16 24 40 / 16%);
}
.waveform-annotation-context-menu button {
padding: 7px 10px;
color: #344054;
font-size: 12px;
text-align: left;
white-space: nowrap;
background: transparent;
border: 0;
border-radius: 3px;
cursor: pointer;
}
.waveform-annotation-context-menu button:hover {
background: #f2f4f7;
}
</style>

View File

@@ -0,0 +1,519 @@
<script setup lang="ts">
import { computed, defineAsyncComponent, nextTick, ref, useId, watch } from 'vue'
import type { WaveformAnnotation } from '../../types'
import { formatAnnotationTime, formatPlainNumber, type TimeUnit } from '../../utils'
import { ANNOTATION_MAX_TEXT_LENGTH, resolveAnnotationStyle } from './markup'
import type { AnnotationSeriesCandidate, AnnotationSeriesInfo } from './types'
const ColorPicker = defineAsyncComponent(async () => {
await import('vue3-colorpicker/style.css')
return (await import('vue3-colorpicker')).ColorPicker
})
interface Props {
annotation: WaveformAnnotation
mode: 'add' | 'edit'
series?: AnnotationSeriesInfo
seriesOptions?: AnnotationSeriesCandidate[]
timeUnit?: TimeUnit
}
const props = withDefaults(defineProps<Props>(), {
timeUnit: 'ms',
})
const emit = defineEmits<{
(event: 'confirm', annotation: WaveformAnnotation): void
(event: 'cancel'): void
(event: 'series-change', seriesId: string): void
}>()
const textarea = ref<HTMLTextAreaElement>()
const dialogTitleId = `waveform-annotation-editor-title-${useId()}`
const text = ref('')
const borderColor = ref('')
const textColor = ref('')
const backgroundColor = ref('')
const canConfirm = computed(() => text.value.trim().length > 0)
const characterCount = computed(() => text.value.length)
const selectedSeries = computed(() => {
const option = props.seriesOptions?.find(
(candidate) => candidate.seriesId === props.annotation.seriesId,
)
return option
? { id: option.seriesId, name: option.name, color: option.color, unit: option.unit }
: props.series
})
function hydrate() {
const style = resolveAnnotationStyle(props.annotation.style)
text.value = props.annotation.text
borderColor.value = style.borderColor
textColor.value = style.textColor
backgroundColor.value = style.backgroundColor
void nextTick(() => textarea.value?.focus())
}
watch(() => props.annotation, hydrate, { immediate: true })
function confirm() {
if (!canConfirm.value) return
emit('confirm', {
...props.annotation,
text: text.value.trim(),
style: {
borderColor: borderColor.value,
textColor: textColor.value,
backgroundColor: backgroundColor.value.trim() || 'rgba(255, 255, 255, 0.92)',
},
})
}
function handleKeydown(event: KeyboardEvent) {
if (event.key === 'Escape') emit('cancel')
if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {
event.preventDefault()
confirm()
}
}
function handleSeriesChange(event: Event) {
const select = event.target as HTMLSelectElement
if (select.value) emit('series-change', select.value)
}
</script>
<template>
<div
class="waveform-annotation-editor"
role="dialog"
aria-modal="true"
:aria-labelledby="dialogTitleId"
@click.self="emit('cancel')"
>
<section class="waveform-annotation-editor__panel">
<header class="waveform-annotation-editor__header">
<div>
<h2 :id="dialogTitleId">
{{ props.mode === 'add' ? '添加标注' : '编辑标注' }}
</h2>
</div>
<button
type="button"
class="waveform-annotation-editor__close"
aria-label="关闭标注编辑器"
title="关闭"
@click="emit('cancel')"
>
×
</button>
</header>
<div class="waveform-annotation-editor__coordinates" aria-label="标注坐标">
<span
><b>X ({{ props.timeUnit }})</b
><code>{{ formatAnnotationTime(props.annotation.x, props.timeUnit) }}</code></span
>
<span
><b>Y</b><code>{{ formatPlainNumber(props.annotation.y) }}</code></span
>
</div>
<label
v-if="selectedSeries"
class="waveform-annotation-editor__series"
aria-label="标注所属波形"
>
<i :style="{ backgroundColor: selectedSeries.color }" aria-hidden="true" />
<span class="waveform-annotation-editor__series-label">
<small>标注波形</small>
<b>{{ selectedSeries.name }}</b>
</span>
<select
v-if="props.seriesOptions?.length"
:value="props.annotation.seriesId"
aria-label="选择标注波形"
@change="handleSeriesChange"
>
<option
v-for="candidate in props.seriesOptions"
:key="candidate.seriesId"
:value="candidate.seriesId"
>
{{ candidate.name }}{{ candidate.unit ? ` (${candidate.unit})` : '' }}
</option>
</select>
<code v-else-if="selectedSeries.unit">{{ selectedSeries.unit }}</code>
</label>
<label class="waveform-annotation-editor__field">
<span class="waveform-annotation-editor__label-row">
<b>标注文本</b>
<small>{{ characterCount }}/{{ ANNOTATION_MAX_TEXT_LENGTH }}</small>
</span>
<textarea
ref="textarea"
v-model="text"
rows="4"
:maxlength="ANNOTATION_MAX_TEXT_LENGTH"
aria-label="标注文本"
placeholder="输入这处波形的说明"
@keydown="handleKeydown"
/>
</label>
<fieldset class="waveform-annotation-editor__colors">
<legend>颜色与透明度</legend>
<label class="waveform-annotation-editor__color-field" title="调整标注边框色和透明度">
<span>边框色</span>
<ColorPicker
v-model:pure-color="borderColor"
aria-label="标注边框色"
use-type="pure"
picker-type="chrome"
format="rgb"
:disable-alpha="false"
:blur-close="true"
/>
</label>
<label class="waveform-annotation-editor__color-field" title="调整标注文字色和透明度">
<span>文字色</span>
<ColorPicker
v-model:pure-color="textColor"
aria-label="标注文字色"
use-type="pure"
picker-type="chrome"
format="rgb"
:disable-alpha="false"
:blur-close="true"
/>
</label>
<label class="waveform-annotation-editor__color-field" title="调整标注背景色和透明度">
<span>背景色</span>
<ColorPicker
v-model:pure-color="backgroundColor"
aria-label="标注背景色"
use-type="pure"
picker-type="chrome"
format="rgb"
:disable-alpha="false"
:blur-close="true"
/>
</label>
</fieldset>
<footer class="waveform-annotation-editor__actions">
<button type="button" @click="emit('cancel')">取消</button>
<button type="button" class="is-primary" :disabled="!canConfirm" @click="confirm">
保存标注
</button>
</footer>
</section>
</div>
</template>
<style scoped>
.waveform-annotation-editor {
position: absolute;
inset: 0;
z-index: 40;
display: grid;
place-items: center;
padding: 20px;
background: rgb(16 24 40 / 32%);
animation: waveform-annotation-editor-fade-in 160ms ease-out;
}
.waveform-annotation-editor__panel {
display: grid;
gap: 20px;
width: min(440px, 100%);
max-height: 100%;
overflow-y: auto;
padding: 22px;
color: #344054;
font-size: 13px;
background: #fff;
border: 1px solid #e4e7ec;
border-radius: 12px;
box-shadow: 0 20px 50px rgb(16 24 40 / 22%);
animation: waveform-annotation-editor-rise-in 180ms ease-out;
}
.waveform-annotation-editor__header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
}
.waveform-annotation-editor__header h2 {
margin: 0;
color: #101828;
font-size: 18px;
line-height: 1.3;
}
.waveform-annotation-editor__header p {
margin: 5px 0 0;
color: #667085;
font-size: 12px;
}
.waveform-annotation-editor__close {
display: inline-grid;
flex: 0 0 30px;
width: 30px;
height: 30px;
padding: 0;
place-items: center;
color: #667085;
font-size: 22px;
line-height: 1;
background: transparent;
border: 0;
border-radius: 6px;
cursor: pointer;
}
.waveform-annotation-editor__close:hover {
color: #101828;
background: #f2f4f7;
}
.waveform-annotation-editor__coordinates {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 8px;
}
.waveform-annotation-editor__coordinates span {
display: flex;
min-width: 0;
align-items: center;
gap: 8px;
padding: 9px 10px;
color: #667085;
background: #f8fafc;
border: 1px solid #eaecf0;
border-radius: 7px;
}
.waveform-annotation-editor__coordinates b {
color: #1677ff;
font-size: 11px;
}
.waveform-annotation-editor__coordinates code {
min-width: 0;
overflow: hidden;
color: #344054;
font-family: 'SFMono-Regular', Consolas, monospace;
font-size: 11px;
text-overflow: ellipsis;
white-space: nowrap;
}
.waveform-annotation-editor__series {
display: flex;
min-width: 0;
align-items: center;
gap: 10px;
padding: 9px 10px;
background: #f8fafc;
border: 1px solid #eaecf0;
border-radius: 7px;
}
.waveform-annotation-editor__series i {
flex: 0 0 12px;
width: 12px;
height: 12px;
border: 1px solid rgb(0 0 0 / 12%);
border-radius: 2px;
}
.waveform-annotation-editor__series-label {
display: grid;
min-width: 0;
gap: 1px;
}
.waveform-annotation-editor__series select {
min-width: 0;
max-width: 190px;
margin-left: auto;
padding: 5px 7px;
color: #344054;
font: inherit;
background: #fff;
border: 1px solid #d0d5dd;
border-radius: 5px;
}
.waveform-annotation-editor__series small {
color: #667085;
font-size: 10px;
}
.waveform-annotation-editor__series b {
overflow: hidden;
color: #344054;
font-size: 12px;
text-overflow: ellipsis;
white-space: nowrap;
}
.waveform-annotation-editor__series code {
margin-left: auto;
color: #667085;
font-size: 11px;
}
.waveform-annotation-editor__field,
.waveform-annotation-editor__color-field {
display: grid;
gap: 4px;
}
.waveform-annotation-editor__label-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.waveform-annotation-editor__label-row b,
.waveform-annotation-editor__colors legend {
color: #344054;
font-size: 12px;
font-weight: 600;
}
.waveform-annotation-editor__label-row small {
color: #98a2b3;
font-size: 11px;
}
.waveform-annotation-editor textarea {
box-sizing: border-box;
width: 100%;
min-height: 92px;
padding: 10px 11px;
color: #1d2939;
font: inherit;
line-height: 1.5;
background: #fff;
border: 1px solid #d0d5dd;
border-radius: 7px;
resize: vertical;
}
.waveform-annotation-editor textarea:focus {
border-color: #1677ff;
outline: 3px solid rgb(22 119 255 / 14%);
}
.waveform-annotation-editor__colors {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 12px;
min-width: 0;
margin: 0;
padding: 14px 0 0;
border: 0;
border-top: 1px solid #eaecf0;
}
.waveform-annotation-editor__colors legend {
grid-column: 1 / -1;
padding: 0;
}
.waveform-annotation-editor__color-field {
align-items: stretch;
min-width: 0;
justify-items: stretch;
color: #667085;
font-size: 11px;
text-align: left;
}
.waveform-annotation-editor__color-field :deep(.vc-color-wrap) {
width: 100%;
height: 34px;
margin-right: 0;
border: 1px solid #cfd5df;
border-radius: 6px;
box-shadow: inset 0 0 0 1px rgb(255 255 255 / 38%);
}
.waveform-annotation-editor__color-field :deep(.vc-color-wrap:hover) {
border-color: #98a2b3;
box-shadow: 0 0 0 3px rgb(22 119 255 / 12%);
}
.waveform-annotation-editor__actions {
display: flex;
justify-content: flex-end;
gap: 8px;
padding-top: 2px;
border-top: 1px solid #eaecf0;
}
.waveform-annotation-editor__actions button {
height: 34px;
padding: 0 12px;
color: #475467;
background: #fff;
border: 1px solid #d0d5dd;
border-radius: 6px;
cursor: pointer;
}
.waveform-annotation-editor__actions button.is-primary {
color: #fff;
background: #1677ff;
border-color: #1677ff;
}
.waveform-annotation-editor__actions button:disabled {
opacity: 0.45;
cursor: not-allowed;
}
@keyframes waveform-annotation-editor-fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes waveform-annotation-editor-rise-in {
from {
opacity: 0;
transform: translateY(8px) scale(0.98);
}
to {
opacity: 1;
transform: translateY(0) scale(1);
}
}
@media (max-width: 420px) {
.waveform-annotation-editor {
padding: 12px;
}
.waveform-annotation-editor__panel {
gap: 16px;
padding: 18px;
}
.waveform-annotation-editor__coordinates {
grid-template-columns: 1fr;
}
}
</style>

View File

@@ -0,0 +1,119 @@
<script setup lang="ts">
import type { RenderedAnnotation } from './types'
import { ANNOTATION_TEXT_FONT, ANNOTATION_TEXT_LINE_HEIGHT } from './markup'
interface Props {
annotations: RenderedAnnotation[]
visible: boolean
}
const props = defineProps<Props>()
const emit = defineEmits<{
(event: 'contextmenu', annotationId: string, mouseEvent: MouseEvent): void
}>()
function handleContextMenu(annotationId: string, event: MouseEvent) {
event.preventDefault()
event.stopPropagation()
emit('contextmenu', annotationId, event)
}
function markerId(annotationId: string) {
return `waveform-annotation-arrow-${annotationId.replace(/[^a-zA-Z0-9_-]/g, '-')}`
}
</script>
<template>
<g v-if="props.visible" class="waveform-annotation-layer">
<g
v-for="rendered in props.annotations"
:key="rendered.annotation.id"
class="waveform-annotation"
:data-annotation-id="rendered.annotation.id"
:data-placement="rendered.placement"
@contextmenu="handleContextMenu(rendered.annotation.id, $event)"
>
<defs>
<marker
:id="markerId(rendered.annotation.id)"
markerWidth="8"
markerHeight="8"
refX="8"
refY="4"
orient="auto"
markerUnits="userSpaceOnUse"
>
<path d="M0,0 L8,4 L0,8 Z" :fill="rendered.style.borderColor" />
</marker>
</defs>
<line
class="waveform-annotation__arrow"
:x1="rendered.box.lineEndX"
:y1="rendered.box.lineEndY"
:x2="rendered.anchorX"
:y2="rendered.anchorY"
:stroke="rendered.style.borderColor"
:marker-end="`url(#${markerId(rendered.annotation.id)})`"
/>
<rect
class="waveform-annotation__box"
:x="rendered.box.x"
:y="rendered.box.y"
:width="rendered.box.width"
:height="rendered.box.height"
:fill="rendered.style.backgroundColor"
:stroke="rendered.style.borderColor"
/>
<text
class="waveform-annotation__text"
:x="rendered.box.x + rendered.box.width / 2"
:y="
rendered.box.y +
rendered.box.height / 2 -
((rendered.lines.length - 1) * ANNOTATION_TEXT_LINE_HEIGHT) / 2
"
:fill="rendered.style.textColor"
:style="{ font: ANNOTATION_TEXT_FONT }"
text-anchor="middle"
dominant-baseline="central"
>
<tspan
v-for="(line, index) in rendered.lines"
:key="`${rendered.annotation.id}-${index}`"
:x="rendered.box.x + rendered.box.width / 2"
:dy="index === 0 ? 0 : ANNOTATION_TEXT_LINE_HEIGHT"
>
{{ line }}
</tspan>
</text>
</g>
</g>
</template>
<style scoped>
.waveform-annotation-layer {
pointer-events: none;
}
.waveform-annotation {
pointer-events: auto;
cursor: context-menu;
}
.waveform-annotation__arrow {
stroke-width: 2;
stroke-linecap: round;
pointer-events: none;
}
.waveform-annotation__box {
stroke-width: 1;
rx: 3;
pointer-events: auto;
}
.waveform-annotation__text {
pointer-events: none;
user-select: none;
}
</style>

View File

@@ -0,0 +1,81 @@
<script setup lang="ts">
import type { WaveformInteractionMode } from '../../types'
interface Props {
interactionMode?: WaveformInteractionMode
annotationsVisible: boolean
}
const props = defineProps<Props>()
const emit = defineEmits<{
(event: 'update:interaction-mode', mode: WaveformInteractionMode): void
(event: 'update:annotations-visible', visible: boolean): void
}>()
</script>
<template>
<div class="waveform-annotation-toolbar" role="toolbar" aria-label="波形标注工具">
<button
type="button"
:class="{ 'is-active': props.interactionMode === 'zoom' }"
aria-label="缩放模式"
title="缩放模式"
@click="emit('update:interaction-mode', 'zoom')"
>
缩放
</button>
<button
type="button"
:class="{ 'is-active': props.interactionMode === 'annotation' }"
aria-label="添加标注"
title="添加标注"
@click="emit('update:interaction-mode', 'annotation')"
>
标注
</button>
<button
type="button"
:class="{ 'is-active': props.annotationsVisible }"
:aria-pressed="props.annotationsVisible"
:aria-label="props.annotationsVisible ? '隐藏标注' : '显示标注'"
title="显示/隐藏标注"
@click="emit('update:annotations-visible', !props.annotationsVisible)"
>
{{ props.annotationsVisible ? '隐藏' : '显示' }}
</button>
</div>
</template>
<style scoped>
.waveform-annotation-toolbar {
position: absolute;
top: 8px;
right: 8px;
z-index: 10;
display: flex;
gap: 4px;
padding: 5px;
background: #fff;
border: 1px solid #dfe5ef;
border-radius: 4px;
box-shadow: 0 2px 8px rgb(0 0 0 / 8%);
}
.waveform-annotation-toolbar button {
min-width: 42px;
height: 28px;
padding: 0 7px;
color: #667085;
font-size: 12px;
background: transparent;
border: 0;
border-radius: 3px;
cursor: pointer;
}
.waveform-annotation-toolbar button:hover,
.waveform-annotation-toolbar button.is-active {
color: #1677ff;
background: #e6f4ff;
}
</style>

View File

@@ -0,0 +1,229 @@
import { flushPromises, mount } from '@vue/test-utils'
import { describe, expect, it } from 'vitest'
import { ColorPicker } from 'vue3-colorpicker'
import WaveformAnnotationContextMenu from './WaveformAnnotationContextMenu.vue'
import WaveformAnnotationEditor from './WaveformAnnotationEditor.vue'
import WaveformAnnotationLayer from './WaveformAnnotationLayer.vue'
import WaveformAnnotationToolbar from './WaveformAnnotationToolbar.vue'
describe('waveform annotation controls', () => {
it('allows changing the annotation series inside the editor', async () => {
const wrapper = mount(WaveformAnnotationEditor, {
props: {
annotation: { id: 'note', seriesId: 'a', x: 1, y: 2, text: '说明' },
mode: 'edit',
series: { id: 'a', name: '通道 A', color: '#f00', unit: 'V' },
seriesOptions: [
{
trackIndex: 0,
seriesId: 'a',
name: '通道 A',
color: '#f00',
unit: 'V',
point: { x: 1, y: 2 },
screenX: 100,
screenY: 50,
distance: 0,
xValue: 1,
},
{
trackIndex: 1,
seriesId: 'b',
name: '通道 B',
color: '#00f',
unit: 'A',
point: { x: 1, y: 3 },
screenX: 100,
screenY: 60,
distance: 10,
xValue: 1,
},
],
},
})
await flushPromises()
expect(
(wrapper.get('select[aria-label="选择标注波形"]').element as HTMLSelectElement).value,
).toBe('a')
await wrapper.get('select[aria-label="选择标注波形"]').setValue('b')
expect(wrapper.emitted('series-change')).toEqual([['b']])
expect(wrapper.get('.waveform-annotation-editor__series').text()).toContain('通道 A')
})
it('emits controlled toolbar changes', async () => {
const wrapper = mount(WaveformAnnotationToolbar, {
props: { interactionMode: 'zoom', annotationsVisible: true },
})
await wrapper.get('button[aria-label="添加标注"]').trigger('click')
await wrapper.get('button[aria-label="隐藏标注"]').trigger('click')
expect(wrapper.emitted('update:interaction-mode')).toEqual([['annotation']])
expect(wrapper.emitted('update:annotations-visible')).toEqual([[false]])
})
it('validates text and emits an immutable edited annotation with style defaults', async () => {
const annotation = { id: 'note', seriesId: 'a', x: 1, y: 2, text: '' }
const wrapper = mount(WaveformAnnotationEditor, {
props: { annotation, mode: 'add' },
})
await flushPromises()
expect(wrapper.get('textarea').attributes('maxlength')).toBe('40')
expect(wrapper.get('.waveform-annotation-editor__coordinates').text()).toContain(
'X (ms)1000.000',
)
expect(wrapper.get('.waveform-annotation-editor__coordinates').text()).toContain('Y2')
expect(wrapper.get('button.is-primary').attributes('disabled')).toBeDefined()
const colorPickers = wrapper.findAllComponents(ColorPicker)
expect(colorPickers).toHaveLength(3)
expect(wrapper.findAll('.waveform-annotation-editor__color-field')).toHaveLength(3)
expect(colorPickers.map((picker) => picker.props('pureColor'))).toEqual([
'#1677ff',
'#333333',
'rgba(255, 255, 255, 0.92)',
])
colorPickers.forEach((picker) => {
expect(picker.props()).toMatchObject({
useType: 'pure',
pickerType: 'chrome',
format: 'rgb',
disableAlpha: false,
blurClose: true,
})
})
await wrapper.get('textarea').setValue('新标注')
colorPickers[0].vm.$emit('update:pureColor', 'rgba(22, 119, 255, 0.7)')
colorPickers[1].vm.$emit('update:pureColor', 'rgba(51, 51, 51, 0.8)')
colorPickers[2].vm.$emit('update:pureColor', 'rgba(255, 255, 255, 0.5)')
await wrapper.vm.$nextTick()
await wrapper.get('button.is-primary').trigger('click')
const emitted = wrapper.emitted('confirm')?.[0]?.[0] as
| {
text: string
style?: { borderColor?: string; textColor?: string; backgroundColor?: string }
}
| undefined
expect(emitted).toMatchObject({
text: '新标注',
style: {
borderColor: 'rgba(22, 119, 255, 0.7)',
textColor: 'rgba(51, 51, 51, 0.8)',
backgroundColor: 'rgba(255, 255, 255, 0.5)',
},
})
expect(annotation.text).toBe('')
})
it('formats annotation coordinates using the selected display context', () => {
const wrapper = mount(WaveformAnnotationEditor, {
props: {
annotation: { id: 'note', seriesId: 'series', x: 1, y: 0.0000001, text: '说明' },
mode: 'edit',
timeUnit: 's',
},
})
const coordinates = wrapper.get('.waveform-annotation-editor__coordinates').text()
expect(coordinates).toContain('X (s)1.000')
expect(coordinates).toContain('Y0.0000001')
expect(coordinates).not.toContain('e-')
})
it('hydrates hexadecimal and rgba annotation colors', async () => {
const wrapper = mount(WaveformAnnotationEditor, {
props: {
annotation: {
id: 'colored-note',
seriesId: 'a',
x: 1,
y: 2,
text: '已有标注',
style: {
borderColor: '#ff0000',
textColor: 'rgba(0, 0, 0, 0.75)',
backgroundColor: 'rgba(255, 255, 255, 0.4)',
},
},
mode: 'edit',
},
})
await flushPromises()
expect(
wrapper.findAllComponents(ColorPicker).map((picker) => picker.props('pureColor')),
).toEqual(['#ff0000', 'rgba(0, 0, 0, 0.75)', 'rgba(255, 255, 255, 0.4)'])
})
it('supports modal dismissal and live character counting', async () => {
const editor = mount(WaveformAnnotationEditor, {
props: {
annotation: { id: 'note', seriesId: 'a', x: 1, y: 2, text: '原文字' },
mode: 'edit',
},
})
expect(editor.get('[role="dialog"]').attributes('aria-modal')).toBe('true')
expect(editor.get('h2').text()).toBe('编辑标注')
await editor.get('textarea').setValue('三字说明')
expect(editor.get('.waveform-annotation-editor__label-row').text()).toContain('4/40')
await editor.get('textarea').trigger('keydown', { key: 'Escape' })
await editor.get('.waveform-annotation-editor').trigger('click')
expect(editor.emitted('cancel')).toHaveLength(2)
})
it('supports cancellation and context menu actions', async () => {
const editor = mount(WaveformAnnotationEditor, {
props: {
annotation: { id: 'note', seriesId: 'a', x: 1, y: 2, text: '原文字' },
mode: 'edit',
},
})
await editor.findAll('button')[0].trigger('click')
expect(editor.emitted('cancel')).toHaveLength(1)
const menu = mount(WaveformAnnotationContextMenu, {
props: { visible: true, x: 10, y: 20, canEdit: true },
})
await menu.findAll('button')[0].trigger('click')
await menu.findAll('button')[1].trigger('click')
expect(menu.emitted('edit')).toHaveLength(1)
expect(menu.emitted('delete')).toHaveLength(1)
})
it('centers single-line and multiline annotation text inside its box', () => {
const wrapper = mount(WaveformAnnotationLayer, {
props: {
visible: true,
annotations: [
{
annotation: { id: 'centered', seriesId: 'a', x: 1, y: 2, text: '第一行\n第二行' },
trackIndex: 0,
anchorX: 80,
anchorY: 80,
placement: 'top',
lines: ['第一行', '第二行'],
box: { x: 20, y: 20, width: 80, height: 42, lineEndX: 60, lineEndY: 62 },
style: {
borderColor: '#1677ff',
textColor: '#333333',
backgroundColor: '#ffffff',
},
},
],
},
})
const text = wrapper.get('.waveform-annotation__text')
expect(text.attributes('text-anchor')).toBe('middle')
expect(text.attributes('dominant-baseline')).toBe('central')
expect(text.attributes('x')).toBe('60')
expect(text.attributes('y')).toBe('33')
expect(wrapper.findAll('tspan').map((line) => line.attributes('x'))).toEqual(['60', '60'])
})
})

View File

@@ -0,0 +1,6 @@
export { default as WaveformAnnotationLayer } from './WaveformAnnotationLayer.vue'
export { default as WaveformAnnotationToolbar } from './WaveformAnnotationToolbar.vue'
export { default as WaveformAnnotationContextMenu } from './WaveformAnnotationContextMenu.vue'
export * from './markup'
export * from './types'
export * from './useWaveformAnnotationInteraction'

View File

@@ -0,0 +1,229 @@
import { scaleLinear } from 'd3'
import { describe, expect, it } from 'vitest'
import type { WaveformAnnotation } from '../../types'
import {
ANNOTATION_TEXT_HORIZONTAL_PADDING,
ANNOTATION_TEXT_PADDING,
ANNOTATION_TEXT_VERTICAL_PADDING,
findAnnotationSeriesCandidates,
findNearestAnnotationPoint,
interpolateAnnotationPoint,
layoutAnnotations,
resolveAnnotationStyle,
wrapAnnotationText,
} from './markup'
import type { AnnotationTrackLayout } from './types'
const createTrack = (
index: number,
id: string,
top: number,
points: Array<{ x: number; y: number }>,
height = 100,
): AnnotationTrackLayout => ({
index,
series: { id, points },
top,
height,
xScale: scaleLinear([0, 2], [0, 200]),
yScale: scaleLinear([0, 10], [height, 0]),
})
describe('waveform annotation markup', () => {
it('interpolates a line value at the pointer X', () => {
expect(interpolateAnnotationPoint([{ x: 0, y: 0 }, { x: 2, y: 10 }], 1)).toEqual({
x: 1,
y: 5,
})
expect(interpolateAnnotationPoint([{ x: 0, y: 0 }, { x: 2, y: 10 }], 3)).toBeNull()
})
it('sorts line candidates by screen distance and keeps series metadata', () => {
const first = createTrack(0, 'first', 0, [
{ x: 0, y: 0 },
{ x: 2, y: 10 },
])
first.series.name = '第一通道'
first.series.color = '#f00'
first.series.unit = 'V'
const second = createTrack(1, 'second', 0, [
{ x: 0, y: 4 },
{ x: 2, y: 8 },
])
const candidates = findAnnotationSeriesCandidates([first, second], 1, 100, 50)
expect(candidates[0]).toMatchObject({
seriesId: 'first',
name: '第一通道',
color: '#f00',
unit: 'V',
point: { x: 1, y: 5 },
distance: 0,
})
expect(candidates[1].point).toEqual({ x: 1, y: 6 })
})
it('uses equal horizontal and vertical annotation padding', () => {
expect(ANNOTATION_TEXT_HORIZONTAL_PADDING).toBe(ANNOTATION_TEXT_PADDING)
expect(ANNOTATION_TEXT_VERTICAL_PADDING).toBe(ANNOTATION_TEXT_PADDING)
})
it('finds the closest visible sample across candidate tracks', () => {
const hit = findNearestAnnotationPoint(
[
createTrack(0, 'a', 0, [
{ x: 0, y: 1 },
{ x: 1, y: 2 },
]),
createTrack(1, 'b', 100, [
{ x: 0, y: 1 },
{ x: 1, y: 8 },
]),
],
100,
120,
12,
)
expect(hit).toMatchObject({ seriesId: 'b', trackIndex: 1 })
expect(hit?.point).toEqual({ x: 1, y: 8 })
})
it('returns no hit outside the configured screen radius', () => {
const hit = findNearestAnnotationPoint([createTrack(0, 'a', 0, [{ x: 1, y: 2 }])], 160, 10, 12)
expect(hit).toBeNull()
})
it('wraps labels by Unicode characters and resolves style defaults', () => {
expect(wrapAnnotationText('1234567890中文')).toEqual(['1234567890', '中文'])
expect(resolveAnnotationStyle({ textColor: '#ffffff' })).toEqual({
borderColor: '#1677ff',
textColor: '#ffffff',
backgroundColor: 'rgba(255, 255, 255, 0.92)',
})
})
it('filters invalid entries and separates nearby annotation boxes', () => {
const track = createTrack(0, 'a', 0, [
{ x: 0, y: 1 },
{ x: 1, y: 2 },
], 300)
const annotations: WaveformAnnotation[] = [
{ id: 'first', seriesId: 'a', x: 1, y: 2, text: '第一个标注' },
{ id: 'second', seriesId: 'a', x: 1, y: 2, text: '第二个标注' },
{ id: 'unknown', seriesId: 'missing', x: 1, y: 2, text: '不显示' },
{ id: 'invalid', seriesId: 'a', x: Number.NaN, y: 2, text: '不显示' },
]
const rendered = layoutAnnotations(annotations, [track], 300, 300)
expect(rendered.map((item) => item.annotation.id)).toEqual(['first', 'second'])
expect(rendered[0].box.lineEndX).toBe(rendered[0].anchorX)
expect(rendered[0].box.lineEndY).not.toBe(rendered[0].anchorY)
expect(rendered[0].placement).toBe('top')
expect(rendered[0].box).not.toMatchObject({
x: rendered[1].box.x,
y: rendered[1].box.y,
})
rendered.forEach((item) => {
expect(item.box.x).toBeGreaterThanOrEqual(0)
expect(item.box.y).toBeGreaterThanOrEqual(0)
expect(item.box.x + item.box.width).toBeLessThanOrEqual(300)
expect(item.box.y + item.box.height).toBeLessThanOrEqual(300)
})
})
it('prefers centered vertical placements and moves below a top boundary', () => {
const track = createTrack(0, 'a', 0, [
{ x: 0, y: 0 },
{ x: 1, y: 5 },
], 200)
const centered = layoutAnnotations(
[{ id: 'centered', seriesId: 'a', x: 1, y: 5, text: '居中' }],
[track],
200,
200,
)[0]
expect(centered.placement).toBe('top')
expect(centered.box.x + centered.box.width / 2).toBe(centered.anchorX)
expect(centered.box.lineEndX).toBe(centered.anchorX)
expect(centered.box.lineEndY).toBe(centered.box.y + centered.box.height)
const nearTop = layoutAnnotations(
[{ id: 'top-edge', seriesId: 'a', x: 1, y: 9.5, text: '顶部' }],
[track],
200,
200,
)[0]
expect(nearTop.placement).toBe('bottom')
expect(nearTop.box.lineEndX).toBe(nearTop.anchorX)
expect(nearTop.box.lineEndY).toBe(nearTop.box.y)
expect(nearTop.box.height).toBe(30)
expect(nearTop.box.lineEndY - nearTop.anchorY).toBe(32)
})
it('reverses direction when the preferred placement is clipped by a boundary', () => {
const track = createTrack(0, 'a', 0, [
{ x: 0, y: 0 },
{ x: 1, y: 5 },
], 200)
const nearTop = layoutAnnotations(
[{ id: 'top-space', seriesId: 'a', x: 1, y: 7.5, text: '顶部空间不足' }],
[track],
200,
200,
)[0]
expect(nearTop.placement).toBe('bottom')
expect(nearTop.box.y).toBeGreaterThanOrEqual(0)
expect(nearTop.box.y + nearTop.box.height).toBeLessThanOrEqual(200)
const nearBottom = layoutAnnotations(
[{ id: 'bottom-space', seriesId: 'a', x: 1, y: 0.5, text: '底部空间不足' }],
[track],
200,
200,
)[0]
expect(nearBottom.placement).toBe('top')
expect(nearBottom.box.y).toBeGreaterThanOrEqual(0)
expect(nearBottom.box.y + nearBottom.box.height).toBeLessThanOrEqual(200)
})
it('keeps a clipped fallback when the plot is smaller than the annotation box', () => {
const track = createTrack(0, 'a', 0, [{ x: 1, y: 5 }])
const rendered = layoutAnnotations(
[{ id: 'tiny-plot', seriesId: 'a', x: 1, y: 5, text: '无法完整放置' }],
[track],
40,
20,
)[0]
expect(rendered).toBeDefined()
expect(rendered.box.x).toBeGreaterThanOrEqual(0)
expect(rendered.box.y).toBeGreaterThanOrEqual(0)
})
it('uses later directional candidates when vertical candidates collide', () => {
const track = createTrack(0, 'a', 0, [
{ x: 0, y: 0 },
{ x: 1, y: 5 },
], 200)
const rendered = layoutAnnotations(
[
{ id: 'one', seriesId: 'a', x: 1, y: 5, text: '同一位置一' },
{ id: 'two', seriesId: 'a', x: 1, y: 5, text: '同一位置二' },
],
[track],
200,
200,
)
expect(rendered[0].placement).toBe('top')
expect(rendered[1].placement).not.toBe('top')
expect(rendered[1].box).not.toMatchObject({ x: rendered[0].box.x, y: rendered[0].box.y })
})
})

View File

@@ -0,0 +1,435 @@
import { bisector } from 'd3'
import type { WaveformAnnotation, WaveformAnnotationStyle } from '../../types'
import type {
AnnotationBoxLayout,
AnnotationHit,
AnnotationPlacement,
AnnotationSeriesCandidate,
AnnotationTrackLayout,
RenderedAnnotation,
} from './types'
export const DEFAULT_ANNOTATION_STYLE = {
borderColor: '#1677ff',
textColor: '#333333',
backgroundColor: 'rgba(255, 255, 255, 0.92)',
} as const
export const ANNOTATION_HIT_RADIUS = 12
export const ANNOTATION_AMBIGUITY_DISTANCE = 5
export const ANNOTATION_MAX_TEXT_LENGTH = 40
export const ANNOTATION_TEXT_PADDING = 8
export const ANNOTATION_BOX_MIN_WIDTH = ANNOTATION_TEXT_PADDING * 2
export const ANNOTATION_BOX_MAX_WIDTH = 240
export const ANNOTATION_BOX_MIN_HEIGHT = 26
export const ANNOTATION_TEXT_HORIZONTAL_PADDING = ANNOTATION_TEXT_PADDING
export const ANNOTATION_TEXT_VERTICAL_PADDING = ANNOTATION_TEXT_PADDING
export const ANNOTATION_TEXT_LINE_HEIGHT = 16
export const ANNOTATION_TEXT_GLYPH_HEIGHT = 14
export const ANNOTATION_TEXT_FONT = '12px Arial, sans-serif'
export const ANNOTATION_CONNECTOR_LENGTH = 32
const ANNOTATION_PLACEMENTS: AnnotationPlacement[] = [
'top',
'bottom',
'right',
'left',
'top-right',
'top-left',
'bottom-right',
'bottom-left',
]
const pointBisector = bisector((point: { x: number }) => point.x)
export function interpolateAnnotationPoint(
points: Array<{ x: number; y: number }>,
xValue: number,
): { x: number; y: number } | null {
if (!points.length || !Number.isFinite(xValue)) return null
const first = points[0]
const last = points[points.length - 1]
if (xValue < first.x || xValue > last.x) return null
if (points.length === 1) return xValue === first.x ? { ...first } : null
const rightIndex = pointBisector.left(points, xValue)
const right = points[Math.min(rightIndex, points.length - 1)]
if (right.x === xValue || rightIndex === 0) return { x: xValue, y: right.y }
const left = points[rightIndex - 1]
const xSpan = right.x - left.x
if (xSpan === 0) return { x: xValue, y: right.y }
const ratio = (xValue - left.x) / xSpan
return { x: xValue, y: left.y + (right.y - left.y) * ratio }
}
export function findAnnotationSeriesCandidates(
tracks: AnnotationTrackLayout[],
xValue: number,
pointerX: number,
pointerY: number,
): AnnotationSeriesCandidate[] {
return tracks
.flatMap((track): AnnotationSeriesCandidate[] => {
const point = interpolateAnnotationPoint(track.series.points, xValue)
if (!point) return []
const screenX = track.xScale(point.x)
const screenY = track.top + track.yScale(point.y)
return [
{
trackIndex: track.index,
seriesId: track.series.id,
name: track.series.name?.trim() || track.series.id,
color: track.series.color || DEFAULT_ANNOTATION_STYLE.borderColor,
unit: track.series.unit,
point,
screenX,
screenY,
distance: Math.hypot(screenX - pointerX, screenY - pointerY),
xValue,
},
]
})
.sort((first, second) => first.distance - second.distance || first.trackIndex - second.trackIndex)
}
let annotationTextMeasurementContext: CanvasRenderingContext2D | null | undefined
function fallbackAnnotationTextWidth(text: string): number {
return Array.from(text).reduce(
(width, character) => width + (character.codePointAt(0)! > 0xff ? 12 : 6.7),
0,
)
}
export function measureAnnotationTextWidth(text: string): number {
if (annotationTextMeasurementContext === undefined) {
annotationTextMeasurementContext = null
if (typeof document !== 'undefined' && typeof CanvasRenderingContext2D !== 'undefined') {
const canvas = document.createElement('canvas')
annotationTextMeasurementContext = canvas.getContext('2d')
if (annotationTextMeasurementContext) {
annotationTextMeasurementContext.font = ANNOTATION_TEXT_FONT
}
}
}
return annotationTextMeasurementContext?.measureText(text).width ?? fallbackAnnotationTextWidth(text)
}
export function resolveAnnotationStyle(style?: WaveformAnnotationStyle) {
return {
borderColor: style?.borderColor || DEFAULT_ANNOTATION_STYLE.borderColor,
textColor: style?.textColor || DEFAULT_ANNOTATION_STYLE.textColor,
backgroundColor: style?.backgroundColor || DEFAULT_ANNOTATION_STYLE.backgroundColor,
}
}
export function isFiniteAnnotation(annotation: WaveformAnnotation): boolean {
return (
Boolean(annotation.id && annotation.seriesId) &&
Number.isFinite(annotation.x) &&
Number.isFinite(annotation.y) &&
typeof annotation.text === 'string' &&
annotation.text.trim().length > 0
)
}
export function wrapAnnotationText(text: string, maxChars = 10): string[] {
const lines: string[] = []
text.split(/\r?\n/).forEach((paragraph) => {
const chars = Array.from(paragraph)
if (chars.length === 0) {
lines.push('')
return
}
for (let index = 0; index < chars.length; index += maxChars) {
lines.push(chars.slice(index, index + maxChars).join(''))
}
})
return lines.length ? lines : ['']
}
export function findNearestAnnotationPoint(
tracks: AnnotationTrackLayout[],
pointerX: number,
pointerY: number,
maxDistance = ANNOTATION_HIT_RADIUS,
): AnnotationHit | null {
let closest: AnnotationHit | null = null
tracks.forEach((track) => {
const localY = pointerY - track.top
if (localY < 0 || localY > track.height || track.series.points.length === 0) return
const xValue = track.xScale.invert(pointerX)
const centerIndex = pointBisector.center(track.series.points, xValue)
const firstIndex = Math.max(0, centerIndex - 2)
const lastIndex = Math.min(track.series.points.length - 1, centerIndex + 2)
for (let candidateIndex = firstIndex; candidateIndex <= lastIndex; candidateIndex += 1) {
const point = track.series.points[candidateIndex]
const screenX = track.xScale(point.x)
const screenY = track.yScale(point.y) + track.top
const distance = Math.hypot(screenX - pointerX, screenY - pointerY)
if (distance > maxDistance || (closest && distance >= closest.distance)) continue
closest = {
trackIndex: track.index,
seriesId: track.series.id,
point,
screenX,
screenY,
distance,
}
}
})
return closest
}
function isWithin(value: number, domain: [number, number]): boolean {
return value >= Math.min(domain[0], domain[1]) && value <= Math.max(domain[0], domain[1])
}
function overlaps(first: AnnotationBoxLayout, second: AnnotationBoxLayout): boolean {
return (
first.x < second.x + second.width &&
first.x + first.width > second.x &&
first.y < second.y + second.height &&
first.y + first.height > second.y
)
}
function containsPoint(box: AnnotationBoxLayout, x: number, y: number): boolean {
return x >= box.x && x <= box.x + box.width && y >= box.y && y <= box.y + box.height
}
function clampBox(box: AnnotationBoxLayout, width: number, height: number): AnnotationBoxLayout {
const x = Math.max(0, Math.min(box.x, Math.max(0, width - box.width)))
const y = Math.max(0, Math.min(box.y, Math.max(0, height - box.height)))
return {
...box,
x,
y,
lineEndX: Math.max(x, Math.min(box.lineEndX, x + box.width)),
lineEndY: Math.max(y, Math.min(box.lineEndY, y + box.height)),
}
}
function resolveConnectorStart(
box: AnnotationBoxLayout,
anchorX: number,
anchorY: number,
): { x: number; y: number } {
const centerX = box.x + box.width / 2
const centerY = box.y + box.height / 2
const deltaX = anchorX - centerX
const deltaY = anchorY - centerY
if (Math.abs(deltaX) * box.height > Math.abs(deltaY) * box.width) {
const x = deltaX >= 0 ? box.x + box.width : box.x
const ratio = deltaX === 0 ? 0 : (x - centerX) / deltaX
return {
x,
y: Math.max(box.y, Math.min(box.y + box.height, centerY + deltaY * ratio)),
}
}
const y = deltaY >= 0 ? box.y + box.height : box.y
const ratio = deltaY === 0 ? 0 : (y - centerY) / deltaY
return {
x: Math.max(box.x, Math.min(box.x + box.width, centerX + deltaX * ratio)),
y,
}
}
function boxPosition(
anchorX: number,
anchorY: number,
width: number,
height: number,
placement: AnnotationPlacement,
): { x: number; y: number } {
const centeredX = anchorX - width / 2
const centeredY = anchorY - height / 2
const rightX = anchorX + ANNOTATION_CONNECTOR_LENGTH
const leftX = anchorX - width - ANNOTATION_CONNECTOR_LENGTH
const topY = anchorY - height - ANNOTATION_CONNECTOR_LENGTH
const bottomY = anchorY + ANNOTATION_CONNECTOR_LENGTH
switch (placement) {
case 'top':
return { x: centeredX, y: topY }
case 'bottom':
return { x: centeredX, y: bottomY }
case 'right':
return { x: rightX, y: centeredY }
case 'left':
return { x: leftX, y: centeredY }
case 'top-right':
return { x: rightX, y: topY }
case 'top-left':
return { x: leftX, y: topY }
case 'bottom-right':
return { x: rightX, y: bottomY }
case 'bottom-left':
return { x: leftX, y: bottomY }
}
}
function annotationBoxSize(
lines: string[],
plotWidth: number,
plotHeight: number,
): { width: number; height: number } {
return {
width: Math.min(
plotWidth,
Math.max(
ANNOTATION_BOX_MIN_WIDTH,
Math.min(
ANNOTATION_BOX_MAX_WIDTH,
Math.ceil(Math.max(...lines.map(measureAnnotationTextWidth), 0)) +
ANNOTATION_TEXT_PADDING * 2,
),
),
),
height: Math.min(
plotHeight,
Math.max(
ANNOTATION_BOX_MIN_HEIGHT,
(lines.length - 1) * ANNOTATION_TEXT_LINE_HEIGHT +
ANNOTATION_TEXT_GLYPH_HEIGHT +
ANNOTATION_TEXT_VERTICAL_PADDING * 2,
),
),
}
}
function isPlacementWithinBounds(
anchorX: number,
anchorY: number,
lines: string[],
plotWidth: number,
plotHeight: number,
placement: AnnotationPlacement,
): boolean {
const { width, height } = annotationBoxSize(lines, plotWidth, plotHeight)
const position = boxPosition(anchorX, anchorY, width, height, placement)
return (
position.x >= 0 &&
position.y >= 0 &&
position.x + width <= plotWidth &&
position.y + height <= plotHeight
)
}
export function layoutAnnotationBox(
anchorX: number,
anchorY: number,
lines: string[],
plotWidth: number,
plotHeight: number,
placement: AnnotationPlacement,
): AnnotationBoxLayout {
const { width, height } = annotationBoxSize(lines, plotWidth, plotHeight)
const position = boxPosition(anchorX, anchorY, width, height, placement)
const clamped = clampBox(
{ x: position.x, y: position.y, width, height, lineEndX: anchorX, lineEndY: anchorY },
plotWidth,
plotHeight,
)
const connectorStart = resolveConnectorStart(clamped, anchorX, anchorY)
return { ...clamped, lineEndX: connectorStart.x, lineEndY: connectorStart.y }
}
export function layoutAnnotations(
annotations: WaveformAnnotation[],
tracks: AnnotationTrackLayout[],
plotWidth: number,
plotHeight: number,
): RenderedAnnotation[] {
const placedByTrack = new Map<number, AnnotationBoxLayout[]>()
const rendered: RenderedAnnotation[] = []
annotations.forEach((annotation) => {
if (!isFiniteAnnotation(annotation)) return
const track = tracks.find((candidate) => candidate.series.id === annotation.seriesId)
if (!track) return
const xDomain = track.xScale.domain() as [number, number]
const yDomain = track.yScale.domain() as [number, number]
if (!isWithin(annotation.x, xDomain) || !isWithin(annotation.y, yDomain)) return
const lines = wrapAnnotationText(annotation.text)
const trackLeft = track.left ?? 0
const trackWidth = track.width ?? plotWidth
const localAnchorX = track.xScale(annotation.x)
const anchorX = trackLeft + localAnchorX
const anchorY = track.yScale(annotation.y) + track.top
const localHeight = Math.min(track.height, Math.max(0, plotHeight - track.top))
const localAnchorY = anchorY - track.top
const placed = placedByTrack.get(track.index) || []
let placement = ANNOTATION_PLACEMENTS[0]
let box = layoutAnnotationBox(
localAnchorX,
localAnchorY,
lines,
trackWidth,
localHeight,
placement,
)
for (const candidatePlacement of ANNOTATION_PLACEMENTS) {
if (
!isPlacementWithinBounds(
localAnchorX,
localAnchorY,
lines,
trackWidth,
localHeight,
candidatePlacement,
)
) {
continue
}
const candidate = layoutAnnotationBox(
localAnchorX,
localAnchorY,
lines,
trackWidth,
localHeight,
candidatePlacement,
)
if (
!containsPoint(candidate, localAnchorX, localAnchorY) &&
!placed.some((item) => overlaps(candidate, item))
) {
box = candidate
placement = candidatePlacement
break
}
}
const globalBox = {
...box,
x: box.x + trackLeft,
y: box.y + track.top,
lineEndX: box.lineEndX + trackLeft,
lineEndY: box.lineEndY + track.top,
}
placed.push(box)
placedByTrack.set(track.index, placed)
rendered.push({
annotation,
trackIndex: track.index,
anchorX,
anchorY,
placement,
lines,
box: {
...globalBox,
},
style: resolveAnnotationStyle(annotation.style),
})
})
return rendered
}

View File

@@ -0,0 +1,100 @@
import type { ScaleLinear } from 'd3'
import type { WaveformAnnotation, WaveformPoint } from '../../types'
export interface AnnotationTrackLayout {
index: number
series: {
id: string
name?: string
color?: string
unit?: string
points: WaveformPoint[]
}
left?: number
top: number
width?: number
height: number
xScale: ScaleLinear<number, number>
yScale: ScaleLinear<number, number>
}
export interface AnnotationHit {
trackIndex: number
seriesId: string
point: WaveformPoint
screenX: number
screenY: number
distance: number
/** Data-space X under the pointer; omitted for snapped sample hits. */
xValue?: number
}
export interface AnnotationSeriesCandidate extends AnnotationHit {
name: string
color: string
unit?: string
}
export interface AnnotationEditorAnchor {
x: number
y: number
}
export interface AnnotationBoxLayout {
x: number
y: number
width: number
height: number
lineEndX: number
lineEndY: number
}
export type AnnotationPlacement =
| 'top'
| 'bottom'
| 'right'
| 'left'
| 'top-right'
| 'top-left'
| 'bottom-right'
| 'bottom-left'
export interface RenderedAnnotation {
annotation: WaveformAnnotation
trackIndex: number
anchorX: number
anchorY: number
placement: AnnotationPlacement
lines: string[]
box: AnnotationBoxLayout
style: {
borderColor: string
textColor: string
backgroundColor: string
}
}
export type AnnotationEditorDraft =
| { mode: 'add'; annotation: WaveformAnnotation; anchor: AnnotationEditorAnchor }
| {
mode: 'edit'
annotation: WaveformAnnotation
previous: WaveformAnnotation
anchor: AnnotationEditorAnchor
}
export interface AnnotationContextMenuState {
x: number
y: number
annotationId?: string
createHit?: AnnotationHit
editorAnchor?: AnnotationEditorAnchor
}
export interface AnnotationSeriesInfo {
id: string
name: string
color: string
unit?: string
}

View File

@@ -0,0 +1,66 @@
import { ref } from 'vue'
import type { WaveformAnnotation } from '../../types'
import type {
AnnotationContextMenuState,
AnnotationEditorAnchor,
AnnotationEditorDraft,
AnnotationHit,
} from './types'
export function useWaveformAnnotationInteraction() {
const editorDraft = ref<AnnotationEditorDraft | null>(null)
const contextMenu = ref<AnnotationContextMenuState | null>(null)
const openCreate = (
hit: AnnotationHit,
createId: () => string,
anchor: AnnotationEditorAnchor,
) => {
editorDraft.value = {
mode: 'add',
annotation: {
id: createId(),
seriesId: hit.seriesId,
x: hit.xValue ?? hit.point.x,
y: hit.point.y,
text: '',
createdAt: new Date().toISOString(),
},
anchor,
}
contextMenu.value = null
}
const openEdit = (annotation: WaveformAnnotation, anchor: AnnotationEditorAnchor) => {
editorDraft.value = {
mode: 'edit',
annotation: { ...annotation },
previous: { ...annotation },
anchor,
}
contextMenu.value = null
}
const openContextMenu = (state: AnnotationContextMenuState) => {
contextMenu.value = state
}
const closeEditor = () => {
editorDraft.value = null
}
const closeContextMenu = () => {
contextMenu.value = null
}
return {
editorDraft,
contextMenu,
openCreate,
openEdit,
openContextMenu,
closeEditor,
closeContextMenu,
}
}

View File

@@ -0,0 +1,23 @@
/**
* 核心常量定义
*/
/** 通道颜色 */
export const channelColors = [
'#0960bd',
'#ff7f0e',
'#389e0d',
'#cf1322',
'#531dab',
'#08979c',
'#c41d7f',
'#434343',
'#7cb305',
'#1d39c4',
]
/** 图表边距 */
export const margin = { top: 18, right: 24, bottom: 52, left: 64 }
/** 最小高度 */
export const minimumHeight = 180

View File

@@ -0,0 +1,59 @@
import { describe, expect, it } from 'vitest'
import {
getBottomRowCellIndexes,
getPageCount,
normalizeGridOptions,
paginateSeries,
resolveGridCellGeometry,
X_AXIS_BAND,
} from './grid'
describe('waveform grid helpers', () => {
it('normalizes grid counts and uses a two by one default', () => {
expect(normalizeGridOptions()).toEqual({ rowCount: 2, columnCount: 1, showPagination: true })
expect(normalizeGridOptions({ rowCount: 0, columnCount: 99 })).toEqual({
rowCount: 1,
columnCount: 10,
showPagination: true,
})
})
it('paginates row-major slots and keeps at least one page for empty data', () => {
const options = normalizeGridOptions({ rowCount: 2, columnCount: 2 })
expect(getPageCount([1, 2, 3, 4, 5].length, options)).toBe(2)
expect(paginateSeries([1, 2, 3, 4, 5], 2, options)).toEqual([5])
expect(getPageCount(0, options)).toBe(1)
})
it('resolves mode-specific gaps and bottom cells', () => {
const options = normalizeGridOptions({ rowCount: 2, columnCount: 2 })
const separated = resolveGridCellGeometry(400, 200, options, 'separated', [true, true, true, true])
const compact = resolveGridCellGeometry(400, 200, options, 'compact', [true, true, true, true])
const independent = resolveGridCellGeometry(400, 200, options, 'independent', [true, true, false, false])
expect(separated[1].left).toBeGreaterThan(separated[0].left + separated[0].width)
expect(separated[2].top).toBe(separated[0].plotHeight + 16)
expect(separated[2].xAxisBand).toBe(X_AXIS_BAND)
expect(compact[2].top).toBe(compact[0].top + compact[0].plotHeight)
expect(compact[2].xAxisBand).toBe(X_AXIS_BAND)
expect(independent[2].top).toBe(
independent[0].top + independent[0].plotHeight + X_AXIS_BAND + 14,
)
expect(independent[0].cellHeight).toBe(independent[0].plotHeight + X_AXIS_BAND)
expect(
getBottomRowCellIndexes(
separated.map((cell, index) => ({ ...cell, hasSeries: index !== 3 })),
2,
),
).toEqual(new Set([2, 1]))
})
it('accepts an independent horizontal gap without changing vertical spacing', () => {
const options = normalizeGridOptions({ rowCount: 2, columnCount: 2 })
const cells = resolveGridCellGeometry(400, 200, options, 'independent', [true, true, true, true], 64)
expect(cells[0].width).toBe(168)
expect(cells[1].left).toBe(232)
expect(cells[2].top).toBe(cells[0].plotHeight + X_AXIS_BAND + 14)
})
})

139
src/components/core/grid.ts Normal file
View File

@@ -0,0 +1,139 @@
import type { WaveformDisplayMode } from '../../types'
export const GRID_MIN_COUNT = 1
export const GRID_MAX_COUNT = 10
export const X_AXIS_BAND = 16
export interface WaveformGridOptions {
rowCount?: number
columnCount?: number
showPagination?: boolean
}
export interface NormalizedWaveformGridOptions {
rowCount: number
columnCount: number
showPagination: boolean
}
export interface GridCellGeometry {
slotIndex: number
row: number
column: number
left: number
top: number
width: number
/** Backward-compatible alias for the actual plot height. */
height: number
plotHeight: number
cellHeight: number
xAxisBand: number
}
const normalizeCount = (value: unknown, fallback: number) => {
const numeric = typeof value === 'number' ? value : Number(value)
if (!Number.isFinite(numeric)) return fallback
return Math.min(GRID_MAX_COUNT, Math.max(GRID_MIN_COUNT, Math.floor(numeric)))
}
export function normalizeGridOptions(options?: WaveformGridOptions): NormalizedWaveformGridOptions {
return {
rowCount: normalizeCount(options?.rowCount, 2),
columnCount: normalizeCount(options?.columnCount, 1),
showPagination: options?.showPagination ?? true,
}
}
export function getPageSize(options: NormalizedWaveformGridOptions): number {
return options.rowCount * options.columnCount
}
export function getPageCount(seriesCount: number, options: NormalizedWaveformGridOptions): number {
return Math.max(1, Math.ceil(Math.max(0, seriesCount) / getPageSize(options)))
}
export function paginateSeries<T>(
series: T[],
page: number,
options: NormalizedWaveformGridOptions,
): T[] {
const pageCount = getPageCount(series.length, options)
const safePage = Math.min(pageCount, Math.max(1, Math.floor(page)))
const start = (safePage - 1) * getPageSize(options)
return series.slice(start, start + getPageSize(options))
}
export function getGridGap(displayMode: WaveformDisplayMode): number {
return displayMode === 'compact' ? 0 : displayMode === 'separated' ? 16 : 14
}
export function resolveGridCellGeometry(
innerWidth: number,
innerHeight: number,
options: NormalizedWaveformGridOptions,
displayMode: WaveformDisplayMode,
slotHasSeries: boolean[] = [],
horizontalGap?: number,
): GridCellGeometry[] {
const defaultGap = getGridGap(displayMode)
const columnGap = Number.isFinite(horizontalGap) ? Math.max(0, horizontalGap as number) : defaultGap
const totalHorizontalGap = Math.max(0, options.columnCount - 1) * columnGap
const axisRows = new Set<number>()
if (displayMode === 'independent') {
for (let row = 0; row < options.rowCount; row += 1) axisRows.add(row)
} else {
for (let column = 0; column < options.columnCount; column += 1) {
for (let slotIndex = getPageSize(options) - 1; slotIndex >= 0; slotIndex -= 1) {
if (slotIndex % options.columnCount !== column) continue
if (slotHasSeries[slotIndex]) {
axisRows.add(Math.floor(slotIndex / options.columnCount))
break
}
}
}
}
const totalVerticalGap = Math.max(0, options.rowCount - 1) * defaultGap
const totalAxisBand = axisRows.size * X_AXIS_BAND
const width = Math.max(1, (innerWidth - totalHorizontalGap) / options.columnCount)
const plotHeight = Math.max(1, (innerHeight - totalVerticalGap - totalAxisBand) / options.rowCount)
return Array.from({ length: getPageSize(options) }, (_, slotIndex) => {
const row = Math.floor(slotIndex / options.columnCount)
const column = slotIndex % options.columnCount
const xAxisBand = axisRows.has(row) ? X_AXIS_BAND : 0
const cellHeight = plotHeight + xAxisBand
const top = Array.from({ length: row }, (_, previousRow) => {
const previousBand = axisRows.has(previousRow) ? X_AXIS_BAND : 0
return plotHeight + previousBand + defaultGap
}).reduce((sum, value) => sum + value, 0)
return {
slotIndex,
row,
column,
left: column * (width + columnGap),
top,
width,
height: plotHeight,
plotHeight,
cellHeight,
xAxisBand,
}
})
}
export function getBottomRowCellIndexes(
cells: Array<GridCellGeometry & { hasSeries?: boolean }>,
columnCount: number,
): Set<number> {
const visible = new Set<number>()
for (let column = 0; column < columnCount; column += 1) {
for (let index = cells.length - 1; index >= 0; index -= 1) {
const cell = cells[index]
if (cell.column === column && cell.hasSeries) {
visible.add(cell.slotIndex)
break
}
}
}
return visible
}

View File

@@ -0,0 +1,5 @@
export * from './constants'
export * from './grid'
export * from './layout'
export * from './types'
export * from './useWaveformData'

View File

@@ -0,0 +1,95 @@
import { line, scaleLinear, zoomIdentity, type ZoomTransform } from 'd3'
import { selectRenderablePoints, type ResolvedWaveformRenderingOptions } from '../../core'
import type { WaveformDisplayMode, WaveformPoint } from '../../types'
import { buildMinorTicks, formatEndpointTime } from '../../utils'
import {
getBottomRowCellIndexes,
type GridCellGeometry,
type NormalizedWaveformGridOptions,
} from './grid'
import type { DisplaySeries, TrackLayout } from './types'
interface SeriesGridCell extends GridCellGeometry {
series?: DisplaySeries
}
export interface BuildTrackLayoutsOptions {
cells: SeriesGridCell[]
grid: NormalizedWaveformGridOptions
displayMode: WaveformDisplayMode
independentTransforms: ZoomTransform[]
sharedZoomDomain: [number, number]
timeUnit: 's' | 'ms'
rendering: ResolvedWaveformRenderingOptions
hideSecondaryLabels: boolean
yAxisLabelX: number
}
export function buildTrackLayouts(options: BuildTrackLayoutsOptions): TrackLayout[] {
const visibleCells = options.cells.map((cell) => ({ ...cell, hasSeries: Boolean(cell.series) }))
const bottomCells = getBottomRowCellIndexes(visibleCells, options.grid.columnCount)
return visibleCells.flatMap((cell, index) => {
const series = cell.series
if (!series) return []
const baseXScale =
options.displayMode === 'independent'
? scaleLinear(series.xDomain, [0, cell.width])
: scaleLinear(options.sharedZoomDomain, [0, cell.width])
const transform =
options.displayMode === 'independent'
? (options.independentTransforms[index] ?? zoomIdentity)
: zoomIdentity
const xScale = transform.rescaleX(baseXScale)
const yScale = scaleLinear(series.yDomain, [cell.plotHeight, 0]).nice()
const xMajorTicks = xScale.ticks(Math.max(2, Math.floor(cell.width / 100)))
const yMajorTicks = yScale.ticks(Math.max(2, Math.floor(cell.plotHeight / 55)))
const yAxisTickValues =
options.displayMode === 'compact' && cell.row < options.grid.rowCount - 1
? yMajorTicks.slice(1)
: yMajorTicks
const domain = xScale.domain() as [number, number]
const endpointLabels = {
start: formatEndpointTime(domain[0], domain, options.timeUnit),
end: formatEndpointTime(domain[1], domain, options.timeUnit),
}
const leftClearance = endpointLabels.start.length * 7 + 10
const rightClearance = endpointLabels.end.length * 7 + 10
const xAxisTickValues = xMajorTicks.filter((tick) => {
const position = xScale(tick)
return position > leftClearance && position < cell.width - rightClearance
})
const renderPoints = selectRenderablePoints(
series.points,
domain,
cell.width,
options.rendering,
)
return {
index,
series,
column: cell.column,
showYAxisLabel: !options.hideSecondaryLabels || cell.column === 0,
yAxisLabelX: options.yAxisLabelX,
left: cell.left,
top: cell.top,
width: cell.width,
height: cell.plotHeight,
xScale,
yScale,
xMajorTicks,
xMinorTicks: buildMinorTicks(xMajorTicks),
yMajorTicks,
yMinorTicks: buildMinorTicks(yMajorTicks),
yAxisTickValues,
xAxisTickValues,
endpointLabels,
path: line<WaveformPoint>()
.x((point) => xScale(point.x))
.y((point) => yScale(point.y))(renderPoints),
showXAxis: options.displayMode === 'independent' || bottomCells.has(cell.slotIndex),
}
})
}

View File

@@ -0,0 +1,52 @@
import type { ScaleLinear } from 'd3'
import type { WaveformPoint } from '../../types'
/**
* 显示系列
*/
export interface DisplaySeries {
id: string
name: string
unit?: string
color: string
points: WaveformPoint[]
xDomain: [number, number]
yDomain: [number, number]
}
/**
* 悬浮的系列点
*/
export interface HoveredSeriesPoint extends DisplaySeries {
trackIndex: number
point: WaveformPoint
}
/**
* 轨道布局
*/
export interface TrackLayout {
index: number
series: DisplaySeries
column: number
showYAxisLabel: boolean
yAxisLabelX: number
left: number
top: number
width: number
height: number
xScale: ScaleLinear<number, number>
yScale: ScaleLinear<number, number>
xMajorTicks: number[]
xMinorTicks: number[]
yMajorTicks: number[]
yMinorTicks: number[]
yAxisTickValues: number[]
xAxisTickValues: number[]
endpointLabels: { start: string; end: string }
path: string | null
showXAxis: boolean
}
// 重新导出 WaveformPoint 方便使用
export type { WaveformPoint }

View File

@@ -0,0 +1,46 @@
import { shallowRef, watch } from 'vue'
import { normalizeWaveformSeries } from '../../core'
import type { WaveformData, WaveformPoint } from '../../types'
import { paddedDomain } from '../../utils'
export interface PreparedWaveformSeries {
id: string
name: string
unit?: string
color?: string
points: WaveformPoint[]
xDomain: [number, number]
yDomain: [number, number]
}
function pointDomain(points: WaveformPoint[], key: 'x' | 'y'): [number, number] {
let minimum = Number.POSITIVE_INFINITY
let maximum = Number.NEGATIVE_INFINITY
points.forEach((point) => {
const value = point[key]
if (value < minimum) minimum = value
if (value > maximum) maximum = value
})
return paddedDomain(Number.isFinite(minimum) ? [minimum, maximum] : [])
}
export function prepareWaveformSeries(data: WaveformData): PreparedWaveformSeries[] {
return normalizeWaveformSeries(data).map((series) => ({
...series,
xDomain: pointDomain(series.points, 'x'),
yDomain: pointDomain(series.points, 'y'),
}))
}
export function usePreparedWaveformSeries(
data: () => WaveformData,
onDataChange: () => void,
) {
const preparedSeries = shallowRef<PreparedWaveformSeries[]>(prepareWaveformSeries(data()))
watch(data, (nextData) => {
preparedSeries.value = prepareWaveformSeries(nextData)
onDataChange()
})
return preparedSeries
}

View File

@@ -0,0 +1 @@
export * from './types'

View File

@@ -0,0 +1,23 @@
/**
* 数据系统类型定义
* 重新导出 src/types 中的类型,方便组件内部使用
*/
// 重新导出所有类型
export type {
WaveformPoint,
WaveformDisplayMode,
WaveformInteractionMode,
WaveformAnnotationStyle,
WaveformAnnotation,
WaveformRenderingOptions,
SingleWaveformData,
WaveformSeries,
WaveformData,
NormalizedWaveformSeries,
} from '../../types'
export type { WaveformGridOptions } from '../core/grid'
// 重新导出数据处理函数
export { normalizeWaveformData, normalizeWaveformSeries } from '../../core'

26
src/components/index.ts Normal file
View File

@@ -0,0 +1,26 @@
export { default as WaveformChart } from './WaveformChart.vue'
// 从新的系统目录导出类型,保持向后兼容
export type {
SingleWaveformData,
WaveformData,
WaveformDisplayMode,
WaveformInteractionMode,
WaveformAnnotationStyle,
WaveformAnnotation,
WaveformRenderingOptions,
WaveformPoint,
WaveformSeries,
WaveformGridOptions,
} from './data/types'
export type { WaveformGridOptions as WaveformGridConfig } from './core/grid'
// 可选:导出各系统的组件(供高级用户使用)
export { WaveformTooltip } from './interaction'
export { WaveformTrack } from './rendering'
export {
WaveformAnnotationLayer,
WaveformAnnotationToolbar,
WaveformAnnotationContextMenu,
} from './annotation'

View File

@@ -0,0 +1,114 @@
<script setup lang="ts">
import { computed } from 'vue'
import { formatTooltipNumber, formatTooltipTime } from '../../utils'
import type { WaveformPoint } from '../data/types'
interface SeriesPoint {
trackIndex: number
name: string
color: string
unit?: string
point: WaveformPoint
}
interface Props {
/** 是否显示 */
visible: boolean
/** 鼠标位置 */
position: { x: number; y: number }
/** 时间单位 */
timeUnit: 's' | 'ms'
/** 悬浮的点 */
hoveredPoint: WaveformPoint | null
/** 所有系列的悬浮点 */
seriesPoints: SeriesPoint[]
/** 容器宽度 */
containerWidth: number
/** 容器高度 */
containerHeight: number
}
const props = defineProps<Props>()
const tooltipStyle = computed(() => {
if (!props.visible || !props.hoveredPoint) return { display: 'none' }
const estimatedHeight = 44 + props.seriesPoints.length * 22
return {
left: `${Math.min(props.position.x + 12, Math.max(8, props.containerWidth - 250))}px`,
top: `${Math.max(8, Math.min(props.position.y - 18, props.containerHeight - estimatedHeight - 8))}px`,
}
})
</script>
<template>
<div
v-if="visible && hoveredPoint"
class="waveform-tooltip waveform-chart__tooltip"
:style="tooltipStyle"
>
<span class="waveform-tooltip__time waveform-chart__tooltip-time">
{{ timeUnit }}: {{ formatTooltipTime(hoveredPoint.x, timeUnit) }}
</span>
<span
v-for="seriesPoint in seriesPoints"
:key="`${seriesPoint.trackIndex}-${seriesPoint.name}`"
class="waveform-tooltip__series waveform-chart__tooltip-series"
>
<i :style="{ backgroundColor: seriesPoint.color }" />
<strong v-if="seriesPoint.name">{{ seriesPoint.name }}:</strong>
<span>
{{ formatTooltipNumber(seriesPoint.point.y)
}}{{ seriesPoint.unit ? ` ${seriesPoint.unit}` : '' }}
</span>
</span>
</div>
</template>
<style scoped>
.waveform-tooltip {
position: absolute;
z-index: 2;
display: grid;
gap: 3px;
min-width: 180px;
max-width: 238px;
padding: 8px 10px;
color: #333;
font:
12px/1.45 ui-monospace,
SFMono-Regular,
Consolas,
monospace;
pointer-events: none;
background: #fff;
border: 1px solid #d9d9d9;
border-radius: 2px;
box-shadow: 0 4px 12px rgb(16 24 40 / 12%);
}
.waveform-tooltip__time {
padding-bottom: 4px;
border-bottom: 1px solid #f0f0f0;
}
.waveform-tooltip__series {
display: grid;
grid-template-columns: 8px auto minmax(0, 1fr);
gap: 6px;
align-items: center;
}
.waveform-tooltip__series i {
width: 8px;
height: 8px;
border-radius: 50%;
}
.waveform-tooltip__series strong {
overflow: hidden;
font-weight: 600;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>

View File

@@ -0,0 +1 @@
export { default as WaveformTooltip } from './WaveformTooltip.vue'

View File

@@ -0,0 +1,429 @@
<script setup lang="ts">
import { nextTick, onMounted, ref, watch } from 'vue'
import { axisBottom, axisLeft, select } from 'd3'
import { formatAxisTime, formatScientificYAxisLabel } from '../../utils'
import type { WaveformDisplayMode, WaveformInteractionMode } from '../data/types'
import type { DisplaySeries, HoveredSeriesPoint, TrackLayout } from '../core/types'
interface Props {
/** 轨道布局信息 */
track: TrackLayout
/** clipPath ID */
clipPathId: string
/** 内部宽度 */
innerWidth: number
/** 是否显示 tooltip */
showTooltip: boolean
/** 是否可缩放 */
zoomable: boolean
/** 显示模式 */
displayMode: WaveformDisplayMode
/** 当前工具模式 */
interactionMode?: WaveformInteractionMode
/** 帧编号 */
frameNumber?: string | number
/** 时间单位 */
timeUnit: 's' | 'ms'
/** 悬浮点(用于显示十字线) */
hoveredPoint?: HoveredSeriesPoint
/** Y 轴标签回退值 */
yLabel?: string
}
interface Emits {
(e: 'pointer-move', event: PointerEvent): void
(e: 'pointer-leave'): void
(e: 'click', event: MouseEvent): void
(e: 'contextmenu', event: MouseEvent): void
}
const props = withDefaults(defineProps<Props>(), {
interactionMode: 'zoom',
})
const emit = defineEmits<Emits>()
const xAxisElement = ref<SVGGElement>()
const yAxisElement = ref<SVGGElement>()
function resolveYAxisLabel(series: DisplaySeries): string {
return series.name.trim() || props.yLabel || ''
}
/**
* 判断是否应该显示 Y 轴标签
* 在紧凑模式下,当轨道高度太小时隐藏标签避免重叠
*/
function shouldShowYAxisLabel(trackHeight: number, trackIndex: number): boolean {
const MIN_HEIGHT_FOR_LABEL = 80
if (trackHeight >= MIN_HEIGHT_FOR_LABEL) {
return true
}
const labelSpacing = Math.ceil(MIN_HEIGHT_FOR_LABEL / trackHeight)
return trackIndex % labelSpacing === 0
}
function crosshairX(): number {
return props.hoveredPoint && props.hoveredPoint.trackIndex === props.track.index
? props.track.xScale(props.hoveredPoint.point.x)
: 0
}
function crosshairY(): number {
return props.hoveredPoint && props.hoveredPoint.trackIndex === props.track.index
? props.track.yScale(props.hoveredPoint.point.y)
: 0
}
function hasCrosshair(): boolean {
return (
props.showTooltip &&
props.hoveredPoint !== undefined &&
props.hoveredPoint.trackIndex === props.track.index
)
}
function renderAxes() {
if (yAxisElement.value) {
const [axisMin, axisMax] = props.track.yScale.domain()
const visibleTicks = props.track.yAxisTickValues ?? props.track.yMajorTicks
const topTickValue = visibleTicks.reduce<number | undefined>((closestTick, tickValue) => {
if (closestTick === undefined) return tickValue
return Math.abs(tickValue - axisMax) < Math.abs(closestTick - axisMax)
? tickValue
: closestTick
}, undefined)
const yAxis = axisLeft(props.track.yScale)
.tickFormat((value) =>
formatScientificYAxisLabel(Number(value), { axisMin, axisMax, topTickValue }),
)
.tickSize(-4)
.tickPadding(7)
.tickSizeOuter(0)
if (props.track.yAxisTickValues) {
yAxis.tickValues(props.track.yAxisTickValues)
}
select(yAxisElement.value).call(yAxis)
}
if (xAxisElement.value) {
select(xAxisElement.value).call(
axisBottom(props.track.xScale)
.tickValues(props.track.xAxisTickValues)
.tickFormat((value) => formatAxisTime(Number(value), props.timeUnit))
.tickSize(-4)
.tickPadding(7)
.tickSizeOuter(0),
)
}
}
onMounted(async () => {
await nextTick()
renderAxes()
})
watch(
[
() => props.track.xScale,
() => props.track.yScale,
() => props.track.xAxisTickValues,
() => props.track.yAxisTickValues,
() => props.timeUnit,
],
async () => {
await nextTick()
renderAxes()
},
{ flush: 'post' },
)
</script>
<template>
<g
class="waveform-track waveform-chart__track"
:data-track-index="track.index"
:data-track-left="track.left"
:data-track-width="track.width"
:data-y-axis-label-x="track.yAxisLabelX"
:data-track-top="track.top"
:data-track-height="track.height"
:transform="`translate(${track.left ?? 0}, ${track.top})`"
>
<!-- 网格和背景 -->
<g :clip-path="`url(#${clipPathId}-${track.index})`" aria-hidden="true">
<g
class="waveform-track__grid waveform-track__grid--minor waveform-chart__grid waveform-chart__grid--minor"
>
<line
v-for="tick in track.xMinorTicks"
:key="`x-minor-${track.index}-${tick}`"
:x1="track.xScale(tick)"
:x2="track.xScale(tick)"
y1="0"
:y2="track.height"
/>
<line
v-for="tick in track.yMinorTicks"
:key="`y-minor-${track.index}-${tick}`"
x1="0"
:x2="track.width ?? innerWidth"
:y1="track.yScale(tick)"
:y2="track.yScale(tick)"
/>
</g>
<g
class="waveform-track__grid waveform-track__grid--major waveform-chart__grid waveform-chart__grid--major"
>
<line
v-for="tick in track.xMajorTicks"
:key="`x-major-${track.index}-${tick}`"
:x1="track.xScale(tick)"
:x2="track.xScale(tick)"
y1="0"
:y2="track.height"
/>
<line
v-for="tick in track.yMajorTicks"
:key="`y-major-${track.index}-${tick}`"
x1="0"
:x2="track.width ?? innerWidth"
:y1="track.yScale(tick)"
:y2="track.yScale(tick)"
/>
</g>
</g>
<!-- 帧编号水印 -->
<text
v-if="frameNumber !== undefined"
class="waveform-track__watermark waveform-chart__watermark"
:x="(track.width ?? innerWidth) / 2"
:y="track.height / 2"
:style="{ fontSize: `${Math.min(120, track.height * 0.65)}px` }"
text-anchor="middle"
dominant-baseline="central"
aria-hidden="true"
>
{{ frameNumber }}
</text>
<!-- X -->
<g
v-if="track.showXAxis"
ref="xAxisElement"
class="waveform-track__axis waveform-track__axis--x waveform-chart__axis waveform-chart__axis--x"
:transform="`translate(0, ${track.height})`"
/>
<g
v-if="track.showXAxis"
class="waveform-track__axis-endpoints waveform-chart__axis-endpoints"
:transform="`translate(0, ${track.height})`"
font-family="sans-serif"
font-size="10"
aria-hidden="true"
>
<text
class="waveform-track__axis-endpoint waveform-track__axis-endpoint--start waveform-chart__axis-endpoint waveform-chart__axis-endpoint--start"
x="0"
y="7"
dy="0.71em"
text-anchor="start"
>
{{ track.endpointLabels.start }}
</text>
<text
class="waveform-track__axis-endpoint waveform-track__axis-endpoint--end waveform-chart__axis-endpoint waveform-chart__axis-endpoint--end"
:x="track.width ?? innerWidth"
y="7"
dy="0.71em"
text-anchor="end"
>
{{ track.endpointLabels.end }}
</text>
</g>
<!-- Y -->
<g
ref="yAxisElement"
class="waveform-track__axis waveform-track__axis--y waveform-chart__axis waveform-chart__axis--y"
/>
<!-- Y 轴标签 -->
<g
v-if="
track.showYAxisLabel &&
resolveYAxisLabel(track.series) &&
shouldShowYAxisLabel(track.height, track.index)
"
>
<rect
class="waveform-track__y-axis-label-bg waveform-chart__y-axis-label-bg"
:x="track.yAxisLabelX - 12"
:y="track.height / 2 - 40"
width="24"
height="80"
rx="2"
/>
<text
class="waveform-track__y-axis-label waveform-chart__y-axis-label"
:fill="track.series.color"
:transform="`translate(${track.yAxisLabelX}, ${track.height / 2}) rotate(-90)`"
text-anchor="middle"
dominant-baseline="central"
>
{{ resolveYAxisLabel(track.series) }}
</text>
</g>
<!-- 轨道边框 -->
<rect
class="waveform-track__plot-frame waveform-chart__plot-frame"
:width="track.width ?? innerWidth"
:height="track.height"
aria-hidden="true"
/>
<!-- 波形线 -->
<path
class="waveform-track__line waveform-chart__line"
:data-series-id="track.series.id"
:data-series-name="track.series.name || undefined"
:d="track.path ?? undefined"
:stroke="track.series.color"
:clip-path="`url(#${clipPathId}-${track.index})`"
/>
<!-- 十字线 -->
<g
v-if="hasCrosshair()"
class="waveform-track__crosshair waveform-chart__crosshair"
:clip-path="`url(#${clipPathId}-${track.index})`"
>
<line :x1="crosshairX()" :x2="crosshairX()" y1="0" :y2="track.height" />
<line x1="0" :x2="track.width ?? innerWidth" :y1="crosshairY()" :y2="crosshairY()" />
<circle :cx="crosshairX()" :cy="crosshairY()" r="4" :fill="track.series.color" />
</g>
<!-- 交互覆盖层(仅在独立模式下) -->
<rect
v-if="displayMode === 'independent'"
class="waveform-track__overlay waveform-track__overlay--independent waveform-chart__overlay waveform-chart__overlay--independent"
:class="{
'is-zoomable': zoomable && interactionMode === 'zoom',
'is-annotating': interactionMode === 'annotation',
}"
:data-independent-overlay-index="track.index"
:width="track.width ?? innerWidth"
:height="track.height"
@pointermove="emit('pointer-move', $event)"
@pointerleave="emit('pointer-leave')"
@click="emit('click', $event)"
@contextmenu="emit('contextmenu', $event)"
/>
</g>
</template>
<style scoped>
.waveform-track {
isolation: isolate;
}
.waveform-track__line {
fill: none;
stroke-width: 1.5;
stroke-linejoin: round;
stroke-linecap: round;
}
.waveform-track__y-axis-label-bg {
fill: white;
opacity: 0.9;
pointer-events: none;
}
.waveform-track__y-axis-label {
font-size: 12px;
font-weight: 500;
pointer-events: none;
}
.waveform-track__grid {
pointer-events: none;
}
.waveform-track__grid--major line {
stroke: #dfe5ef;
stroke-width: 1;
}
.waveform-track__grid--minor line {
stroke: #f2f5fa;
stroke-width: 1;
}
.waveform-track__plot-frame {
fill: none;
stroke: #1f2937;
stroke-width: 1;
pointer-events: none;
}
.waveform-track__watermark {
fill: rgb(22 119 255 / 10%);
font-family: Consolas, Monaco, 'Courier New', monospace;
pointer-events: none;
}
.waveform-track__overlay {
fill: transparent;
cursor: crosshair;
touch-action: none;
}
.waveform-track__overlay.is-zoomable {
cursor: grab;
}
.waveform-track__overlay.is-zoomable:active {
cursor: grabbing;
}
.waveform-track__overlay.is-annotating {
cursor: crosshair;
}
.waveform-track__crosshair {
pointer-events: none;
}
.waveform-track__crosshair line {
stroke: #57617b;
stroke-width: 1;
stroke-dasharray: 4 3;
}
.waveform-track__crosshair circle {
stroke: #fff;
stroke-width: 2;
}
.waveform-track__axis-endpoint {
fill: #667085;
font-size: 11px;
pointer-events: none;
}
:deep(.waveform-track__axis path),
:deep(.waveform-track__axis line) {
stroke: #1f2937;
}
:deep(.waveform-track__axis text) {
fill: #667085;
font-size: 11px;
}
</style>

View File

@@ -0,0 +1 @@
export { default as WaveformTrack } from './WaveformTrack.vue'

View File

@@ -0,0 +1,21 @@
/**
* 向后兼容的导出文件
* 保留原有导入路径,内部从新的模块结构导出
*/
// 类型定义
export type {
WaveformPoint,
WaveformDisplayMode,
WaveformInteractionMode,
WaveformAnnotationStyle,
WaveformAnnotation,
WaveformRenderingOptions,
SingleWaveformData,
WaveformSeries,
WaveformData,
NormalizedWaveformSeries,
} from '../types'
// 数据处理函数
export { normalizeWaveformData, normalizeWaveformSeries } from '../core'

59
src/core/data.ts Normal file
View File

@@ -0,0 +1,59 @@
import type { SingleWaveformData, WaveformData, WaveformPoint, NormalizedWaveformSeries } from '../types'
/**
* 规范化单波形数据
* @param data 输入数据samples 或 points 格式)
* @returns 规范化后的点数组
*/
export function normalizeWaveformData(data: SingleWaveformData): WaveformPoint[] {
if (data.kind === 'samples') {
if (!Number.isFinite(data.sampleRate) || data.sampleRate <= 0) return []
const startTime = Number.isFinite(data.startTime) ? (data.startTime ?? 0) : 0
return data.values.flatMap((value, index) =>
Number.isFinite(value) ? [{ x: startTime + index / data.sampleRate, y: value }] : [],
)
}
return data.points
.filter((point) => Number.isFinite(point.x) && Number.isFinite(point.y))
.map((point) => ({ ...point }))
.sort((left, right) => left.x - right.x)
}
/**
* 规范化波形系列数据
* @param data 输入数据(单波形或多通道)
* @returns 规范化后的系列数组
*/
export function normalizeWaveformSeries(data: WaveformData): NormalizedWaveformSeries[] {
if (data.kind !== 'series') {
const points = normalizeWaveformData(data)
return points.length > 0 ? [{ id: 'series-0', name: '', points }] : []
}
const usedIds = new Set<string>()
return data.series
.map((series, index) => {
const id = series.id?.trim() || `series-${index}`
// 确保 ID 唯一,如果重复则添加后缀
let uniqueId = id
let suffix = 1
while (usedIds.has(uniqueId)) {
uniqueId = `${id}-${suffix}`
suffix++
}
usedIds.add(uniqueId)
return {
id: uniqueId,
name: series.name,
unit: series.unit,
color: series.color,
points: normalizeWaveformData(series.data),
}
})
.filter((series) => series.points.length > 0)
}

12
src/core/index.ts Normal file
View File

@@ -0,0 +1,12 @@
/**
* 核心引擎模块统一导出
*/
// 数据处理
export { normalizeWaveformData, normalizeWaveformSeries } from './data'
export {
DEFAULT_WAVEFORM_RENDERING_OPTIONS,
resolveWaveformRenderingOptions,
selectRenderablePoints,
type ResolvedWaveformRenderingOptions,
} from './rendering'

View File

@@ -0,0 +1,43 @@
import { describe, expect, it } from 'vitest'
import type { WaveformPoint } from '../types'
import { resolveWaveformRenderingOptions, selectRenderablePoints } from './rendering'
describe('waveform rendering selection', () => {
const points = Array.from({ length: 10_000 }, (_, index): WaveformPoint => ({
x: index,
y: index === 5_001 ? 10_000 : Math.sin(index / 20),
}))
it('clips to the visible domain and retains one continuity point on each side', () => {
const selected = selectRenderablePoints(
points,
[4_000, 4_100],
500,
resolveWaveformRenderingOptions({ downsample: false }),
)
expect(selected[0].x).toBe(3_999)
expect(selected.at(-1)?.x).toBe(4_101)
})
it('bounds path density while preserving narrow extrema', () => {
const selected = selectRenderablePoints(
points,
[0, 9_999],
100,
resolveWaveformRenderingOptions({ downsampleThreshold: 100, maxPointsPerPixel: 4 }),
)
expect(selected.length).toBeLessThanOrEqual(402)
expect(selected).toContain(points[5_001])
expect(selected[0]).toBe(points[0])
expect(selected.at(-1)).toBe(points.at(-1))
})
it('normalizes invalid rendering options to stable defaults', () => {
expect(
resolveWaveformRenderingOptions({ downsampleThreshold: -1, maxPointsPerPixel: 0 }),
).toEqual({ downsample: true, downsampleThreshold: 2_000, maxPointsPerPixel: 4 })
})
})

108
src/core/rendering.ts Normal file
View File

@@ -0,0 +1,108 @@
import { bisector } from 'd3'
import type { WaveformPoint, WaveformRenderingOptions } from '../types'
export interface ResolvedWaveformRenderingOptions {
downsample: boolean
downsampleThreshold: number
maxPointsPerPixel: number
}
export const DEFAULT_WAVEFORM_RENDERING_OPTIONS: ResolvedWaveformRenderingOptions = {
downsample: true,
downsampleThreshold: 2_000,
maxPointsPerPixel: 4,
}
const pointBisector = bisector((point: WaveformPoint) => point.x)
export function resolveWaveformRenderingOptions(
options?: WaveformRenderingOptions,
): ResolvedWaveformRenderingOptions {
const threshold = Number(options?.downsampleThreshold)
const pointsPerPixel = Number(options?.maxPointsPerPixel)
return {
downsample: options?.downsample ?? DEFAULT_WAVEFORM_RENDERING_OPTIONS.downsample,
downsampleThreshold:
Number.isFinite(threshold) && threshold >= 2
? Math.floor(threshold)
: DEFAULT_WAVEFORM_RENDERING_OPTIONS.downsampleThreshold,
maxPointsPerPixel:
Number.isFinite(pointsPerPixel) && pointsPerPixel > 0
? pointsPerPixel
: DEFAULT_WAVEFORM_RENDERING_OPTIONS.maxPointsPerPixel,
}
}
function pushUniquePoint(target: WaveformPoint[], point: WaveformPoint | undefined) {
if (point && target[target.length - 1] !== point) target.push(point)
}
/**
* Select the visible source range and preserve first/min/max/last values in each X bucket.
* Source points must be sorted by X.
*/
export function selectRenderablePoints(
points: WaveformPoint[],
domain: [number, number],
width: number,
options: ResolvedWaveformRenderingOptions,
): WaveformPoint[] {
if (!points.length || width <= 0) return []
const domainStart = Math.min(domain[0], domain[1])
const domainEnd = Math.max(domain[0], domain[1])
const visibleStart = pointBisector.left(points, domainStart)
const visibleEnd = pointBisector.right(points, domainEnd)
const start = Math.max(0, visibleStart - 1)
const end = Math.min(points.length, visibleEnd + 1)
const visibleCount = end - start
if (visibleCount <= 0) return []
if (!options.downsample || visibleCount <= options.downsampleThreshold) {
return points.slice(start, end)
}
const maximumPointCount = Math.max(4, Math.floor(width * options.maxPointsPerPixel))
const bucketCount = Math.max(1, Math.floor(maximumPointCount / 4))
if (visibleCount <= maximumPointCount) return points.slice(start, end)
const result: WaveformPoint[] = []
const span = domainEnd - domainStart || 1
let activeBucket = -1
let firstIndex = -1
let lastIndex = -1
let minimumIndex = -1
let maximumIndex = -1
const flushBucket = () => {
if (firstIndex < 0) return
const indexes = [firstIndex, minimumIndex, maximumIndex, lastIndex]
.filter((index, position, source) => index >= 0 && source.indexOf(index) === position)
.sort((left, right) => left - right)
indexes.forEach((index) => pushUniquePoint(result, points[index]))
}
pushUniquePoint(result, points[start])
for (let index = Math.max(start, visibleStart); index < Math.min(end, visibleEnd); index += 1) {
const point = points[index]
const bucket = Math.min(
bucketCount - 1,
Math.max(0, Math.floor(((point.x - domainStart) / span) * bucketCount)),
)
if (bucket !== activeBucket) {
flushBucket()
activeBucket = bucket
firstIndex = index
lastIndex = index
minimumIndex = index
maximumIndex = index
continue
}
lastIndex = index
if (point.y < points[minimumIndex].y) minimumIndex = index
if (point.y > points[maximumIndex].y) maximumIndex = index
}
flushBucket()
pushUniquePoint(result, points[end - 1])
return result
}

813
src/data/wData.json Normal file
View File

@@ -0,0 +1,813 @@
[
{
"chnl": "BT2_2M",
"chnl_id": 4742,
"dat_unit": "T",
"data": [
0.00037805046304129064, -0.0007567321881651878, -0.00037805046304129064,
-0.00037805046304129064, -6.31265379524848e-7, -6.31265379524848e-7, -6.31265379524848e-7,
-6.31265379524848e-7, -6.31265379524848e-7, -6.31265379524848e-7, -6.31265379524848e-7,
-6.31265379524848e-7, -6.31265379524848e-7, -6.31265379524848e-7, -6.31265379524848e-7,
-6.31265379524848e-7, -0.00037805046304129064, -6.31265379524848e-7, -6.31265379524848e-7,
-0.00037931298720650375, -0.00037805046304129064, -6.31265379524848e-7,
-0.00037805046304129064, -0.00037805046304129064, -0.00037805046304129064,
-0.00037805046304129064, -0.0007567321881651878, -6.31265379524848e-7,
-0.00037805046304129064, -0.00037805046304129064, -6.31265379524848e-7, -6.31265379524848e-7,
-0.00037805046304129064, -0.00037805046304129064, -0.00037805046304129064,
-0.0007567321881651878, -6.31265379524848e-7, -6.31265379524848e-7, -6.31265379524848e-7,
-0.00037805046304129064, -0.00037931298720650375, -0.0007567321881651878,
-0.00037931298720650375, -0.00037931298720650375, -0.00037805046304129064,
-0.00037931298720650375, -6.31265379524848e-7, -0.00037805046304129064,
-0.00037805046304129064, -6.31265379524848e-7, -0.0007567321881651878,
-0.00037805046304129064, -0.00037805046304129064, -0.00037805046304129064,
-0.00037805046304129064, -0.00037805046304129064, -0.00037805046304129064,
-0.00037805046304129064, -0.00037805046304129064, -0.00037931298720650375,
-6.31265379524848e-7, -6.31265379524848e-7, -0.00037805046304129064, -0.0007567321881651878,
-0.0007567321881651878, -0.00037805046304129064, -0.00037931298720650375,
-0.0007567321881651878, -0.0007567321881651878, -0.00037805046304129064,
-0.0007567321881651878, -0.00037805046304129064, -0.00037805046304129064,
-0.0007567321881651878, -0.0007567321881651878, -0.0007567321881651878,
-0.00037931298720650375, -0.00037805046304129064, -0.00037931298720650375,
-0.00037805046304129064, -0.0007567321881651878, -0.0007567321881651878, -6.31265379524848e-7,
-0.0007567321881651878, -0.0007567321881651878, -0.00037805046304129064,
-0.0007567321881651878, -0.0007567321881651878, -0.00037931298720650375,
-0.00037931298720650375, -6.31265379524848e-7, -0.0007567321881651878, -0.0007567321881651878,
-6.31265379524848e-7, -0.00037931298720650375, -0.0007567321881651878, -0.0007567321881651878,
-6.31265379524848e-7, -0.00037931298720650375, -0.0007567321881651878, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.00037805046304129064,
-0.00037805046304129064, -0.00037931298720650375, -0.0007567321881651878,
-6.31265379524848e-7, -0.0007567321881651878, -0.00037805046304129064, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.0007567321881651878,
-0.00037931298720650375, -0.00037931298720650375, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.00037805046304129064, -6.31265379524848e-7,
-0.0007567321881651878, -0.0011354138841852546, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.00037805046304129064,
-0.0011354138841852546, -0.00037931298720650375, -0.00037931298720650375,
-0.0007567321881651878, -0.0007567321881651878, -6.31265379524848e-7, -0.0011354138841852546,
-0.0011354138841852546, -0.00037931298720650375, -0.0007567321881651878,
-0.00037931298720650375, -0.00037931298720650375, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.00037805046304129064,
-0.0007567321881651878, -0.0007567321881651878, -0.0007567321881651878,
-0.0007567321881651878, -0.0007554696639999747, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.0007567321881651878,
-0.0007567321881651878, -0.0011354138841852546, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.0011354138841852546,
-0.0007567321881651878, -0.0007567321881651878, -0.0011354138841852546,
-0.0011354138841852546, -0.0007567321881651878, -0.0011341513600200415,
-0.0007567321881651878, -0.0007567321881651878, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.0007567321881651878,
-0.0011354138841852546, -0.0007567321881651878, -0.0011354138841852546,
-0.0007567321881651878, -0.0011354138841852546, -0.00037931298720650375,
-0.0007567321881651878, -0.00151283317245543, -0.0011354138841852546, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.0011354138841852546,
-0.0011354138841852546, -0.0007567321881651878, -0.0007567321881651878,
-0.0007567321881651878, -0.0011354138841852546, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.0007567321881651878,
-0.0007567321881651878, -0.0007567321881651878, -0.0011354138841852546,
-0.0007567321881651878, -0.0007567321881651878, -0.0011341513600200415,
-0.0007567321881651878, -0.0007567321881651878, -0.0011341513600200415,
-0.0011354138841852546, -0.00151283317245543, -0.0011354138841852546, -0.0007567321881651878,
-0.0007567321881651878, -0.0011354138841852546, -0.0007567321881651878,
-0.0011354138841852546, -0.0011354138841852546, -0.0011354138841852546,
-0.0011354138841852546, -0.0011354138841852546, -0.0007567321881651878,
-0.0007567321881651878, -0.00151283317245543, -0.0011354138841852546, -0.0011354138841852546,
-0.0011354138841852546, -0.0007567321881651878, -0.0007567321881651878,
-0.0011354138841852546, -0.0011354138841852546, -0.0011354138841852546,
-0.0011341513600200415, -0.0011354138841852546, -0.0011354138841852546,
-0.0007567321881651878, -0.0007567321881651878, -0.0011354138841852546,
-0.0011354138841852546, -0.0011354138841852546, -0.0007567321881651878, -0.00151283317245543,
-0.0011354138841852546, -0.0011341513600200415, -0.0007567321881651878, -0.00151283317245543,
-0.00151283317245543, -0.00151283317245543, -0.0011354138841852546, -0.0007567321881651878,
-0.00151283317245543, -0.0011354138841852546, -0.0011354138841852546, -0.0011354138841852546,
-0.00151283317245543, -0.0011341513600200415, -0.0011341513600200415, -0.0011354138841852546,
-0.0011354138841852546, -0.0011354138841852546, -0.0011354138841852546,
-0.0007567321881651878, -0.00151283317245543, -0.00151283317245543, -0.0011354138841852546,
-0.00151283317245543, -0.00151283317245543, -0.0015140956966206431, -0.00151283317245543,
-0.0011354138841852546, -0.0011354138841852546, -0.0011354138841852546,
-0.0011354138841852546, -0.0011354138841852546, -0.0011341513600200415,
-0.0011354138841852546, -0.0011341513600200415, -0.0011354138841852546,
-0.0011354138841852546, -0.0011354138841852546, -0.0011354138841852546,
-0.0011354138841852546, -0.0011354138841852546, -0.0011354138841852546,
-0.0007567321881651878, -0.0015140956966206431, -0.0011354138841852546, -0.00151283317245543,
-0.00151283317245543, -0.0011354138841852546, -0.0011354138841852546, -0.00151283317245543,
-0.0007567321881651878, -0.0011354138841852546, -0.0011354138841852546,
-0.0007567321881651878, -0.00037931298720650375, -6.31265379524848e-7, 0.00037678793887607753,
0.0011328888358548284, 0.0022676715161651373, 0.0030237725004553795, 0.004535974469035864,
0.00566949462518096, 0.007181696128100157, 0.00831521674990654, 0.009828681126236916,
0.010962201282382011, 0.012474402785301208, 0.013986604288220406, 0.015876226127147675,
0.018144529312849045, 0.019656730815768242, 0.021925034001469612, 0.024193335324525833,
0.026839058846235275, 0.028729941695928574, 0.030998244881629944, 0.03591226786375046,
0.0385579913854599, 0.041582394391298294, 0.043850697576999664, 0.04725378379225731,
0.04989950358867645, 0.05292264744639397, 0.05594705045223236, 0.058972716331481934,
0.0623745396733284, 0.06577636301517487, 0.06917944550514221, 0.07258126884698868,
0.07598309218883514, 0.07976359874010086, 0.08354410529136658, 0.0873246043920517,
0.09110511094331741, 0.09488435089588165, 0.09904354065656662, 0.10358014702796936,
0.10736065357923508, 0.11113989353179932, 0.11529907584190369, 0.11983442306518555,
0.12437102943658829, 0.12853021919727325, 0.1330668181180954, 0.13722474873065948,
0.14251744747161865, 0.14743147790431976, 0.15158939361572266, 0.15688210725784302,
0.16141870617866516, 0.16671141982078552, 0.17162543535232544, 0.17653946578502655,
0.1818321794271469, 0.18712487816810608, 0.1920389086008072, 0.19733160734176636,
0.20338042080402374, 0.2086731195449829, 0.21358714997768402, 0.2196359634399414,
0.22492866218090057, 0.23097620904445648, 0.23626892268657684, 0.24193903803825378,
0.24836653470993042, 0.25403666496276855, 0.25932934880256653, 0.2653781771659851,
0.271425724029541, 0.27785319089889526, 0.28390201926231384, 0.289572149515152,
0.29599836468696594, 0.3024258613586426, 0.3084734082221985, 0.31490087509155273,
0.3220832049846649, 0.32850944995880127, 0.33493566513061523, 0.3413618803024292,
0.34778937697410583, 0.35459303855895996, 0.3610205054283142, 0.36782416701316833,
0.3742503821849823, 0.38143399357795715, 0.38861632347106934, 0.3950425386428833,
0.40260353684425354, 0.40940719842910767, 0.41659078001976013, 0.4230169951915741,
0.4305780231952667, 0.4377603530883789, 0.4449426829814911, 0.45250368118286133,
0.46006467938423157, 0.4668683409690857, 0.47442933917045593, 0.4816129505634308,
0.48917269706726074, 0.496733695268631, 0.5042946934700012, 0.5114770531654358,
0.5190380215644836, 0.526976466178894, 0.5341587662696838, 0.5424758791923523,
0.5496582388877869, 0.5579753518104553, 0.565536379814148, 0.5734747648239136,
0.581413209438324, 0.5889742374420166, 0.5969126224517822, 0.6048510670661926,
0.6131681799888611, 0.6207292079925537, 0.6290450692176819, 0.6366060376167297,
0.645300567150116, 0.6536176800727844, 0.660800039768219, 0.6698732376098633,
0.6774329543113708, 0.6857500672340393, 0.7020056247711182, 0.7099440693855286,
0.7186398506164551, 0.7265782952308655, 0.7345166802406311, 0.7428337931632996,
0.7515283226966858, 0.7598454356193542, 0.7677838802337646, 0.7768570780754089,
0.7847955226898193, 0.7934900522232056, 0.801428496837616, 0.8101230263710022,
0.8188175559043884, 0.8263785243034363, 0.8346956372261047, 0.843390166759491,
0.8513286113739014, 0.8600231409072876, 0.868340253829956, 0.8759012818336487,
0.8845958113670349, 0.8929129242897034, 0.9012300372123718, 0.9087897539138794,
0.9178629517555237, 0.9258013963699341, 0.9329850077629089, 0.9416795372962952,
0.9496179223060608, 0.9568015336990356, 0.9651173949241638, 0.9722996950149536,
0.9802393913269043, 0.9878004193305969, 0.9949827194213867, 1.0021663904190063,
1.0097260475158691, 1.0169097185134888, 1.0237133502960205, 1.0308955907821655,
1.037321925163269, 1.0433707237243652, 1.0497969388961792, 1.0558457374572754,
1.0615158081054688, 1.0679420232772827, 1.0732347965240479, 1.079283595085144,
1.0845762491226196, 1.0898690223693848, 1.094783067703247, 1.0996969938278198,
1.1053683757781982, 1.1102824211120605, 1.1151964664459229, 1.1193556785583496,
1.124269723892212, 1.1284288167953491, 1.1325868368148804, 1.1375008821487427,
1.1420373916625977, 1.1458178758621216, 1.1503545045852661, 1.15413498878479,
1.1582930088043213, 1.1620746850967407, 1.1666101217269897, 1.1707680225372314,
1.1749272346496582, 1.1790851354599, 1.1832430362701416, 1.1870235204696655,
1.1908040046691895, 1.1949632167816162, 1.199121117591858, 1.2032791376113892,
1.207059621810913, 1.210840106010437, 1.214620590209961, 1.2187784910202026,
1.2221803665161133, 1.226338267326355, 1.2304974794387817, 1.2338992357254028,
1.237302303314209, 1.2414603233337402, 1.2452408075332642, 1.249021291732788,
1.2524243593215942, 1.2562048435211182, 1.2599841356277466, 1.2633872032165527,
1.2671676874160767, 1.2713255882263184, 1.2743500471115112, 1.2777519226074219,
1.281153678894043, 1.2845567464828491, 1.2879586219787598, 1.2917391061782837,
1.2947635650634766, 1.2985440492630005, 1.3019458055496216, 1.3049702644348145,
1.3083733320236206, 1.3117750883102417, 1.3147995471954346, 1.3178240060806274,
1.3219819068908691, 1.3276519775390625, 1.3306764364242554, 1.3337007761001587,
1.3371026515960693, 1.3401269912719727, 1.3431514501571655, 1.3461757898330688,
1.3488215208053589, 1.3522247076034546, 1.354870319366455, 1.3575160503387451,
1.360540509223938, 1.363186240196228, 1.3658331632614136, 1.369613766670227,
1.371504545211792, 1.3745276927947998, 1.377174735069275, 1.3794430494308472,
1.3820887804031372, 1.3847345113754272, 1.3870028257369995, 1.3900271654129028,
1.392674207687378, 1.395319938659668, 1.3975881338119507, 1.4002338647842407,
1.4021247625350952, 1.4047704935073853, 1.4070388078689575, 1.4093071222305298,
1.411575436592102, 1.4138437509536743, 1.4164894819259644, 1.4183803796768188,
1.4206485748291016, 1.4225382804870605, 1.4248065948486328, 1.4266961812973022,
1.4297205209732056, 1.4312328100204468, 1.4331237077713013, 1.4350132942199707,
1.4365254640579224, 1.4387937784194946, 1.441062092781067, 1.4425742626190186,
1.4444639682769775, 1.4459761381149292, 1.4482444524765015, 1.450135350227356,
1.4516475200653076, 1.453537106513977, 1.4550492763519287, 1.45656156539917,
1.4584511518478394, 1.459963321685791, 1.4614756107330322, 1.4629877805709839,
1.4648773670196533, 1.4660121202468872, 1.4671469926834106, 1.4690377712249756,
1.4705500602722168, 1.4716835021972656, 1.4735743999481201, 1.4747079610824585,
1.475464105606079, 1.4773536920547485, 1.4781097173690796, 1.4796220064163208,
1.4803780317306519, 1.4815115928649902, 1.4826463460922241, 1.4841586351394653,
1.4849146604537964, 1.485670804977417, 1.4868042469024658, 1.4879378080368042,
1.488316535949707, 1.489451289176941, 1.4902074337005615, 1.4909634590148926,
1.4913408756256104, 1.4924744367599487, 1.4932305812835693, 1.4939866065979004,
1.4947439432144165, 1.495498776435852, 1.4958775043487549, 1.4966336488723755,
1.4973896741867065, 1.4977670907974243, 1.498523235321045, 1.4992793798446655,
1.4989006519317627, 1.4992793798446655, 1.5004128217697144, 1.5004128217697144,
1.5007915496826172, 1.5015476942062378, 1.5023037195205688, 1.5015476942062378,
1.5023037195205688, 1.5026824474334717, 1.5023037195205688, 1.503061056137085,
1.5034384727478027, 1.5034372806549072, 1.5030598640441895, 1.5030598640441895,
1.5038158893585205, 1.5038158893585205, 1.5038158893585205, 1.5045720338821411,
1.5034384727478027, 1.5041946172714233, 1.5038158893585205, 1.5038158893585205,
1.5038158893585205, 1.5038158893585205, 1.5034372806549072, 1.5034384727478027,
1.5030598640441895, 1.5030598640441895, 1.5026824474334717, 1.5026824474334717,
1.5023037195205688, 1.5023037195205688, 1.5015476942062378, 1.50117027759552,
1.5015476942062378, 1.5007915496826172, 1.5004141330718994, 1.5000367164611816,
1.4996579885482788, 1.4989019632339478, 1.498523235321045, 1.4981458187103271,
1.4977684020996094, 1.4973896741867065, 1.4966336488723755, 1.4958775043487549,
1.4958775043487549, 1.4951213598251343, 1.4951213598251343, 1.4939879179000854,
1.4939879179000854, 1.4932317733764648, 1.492097020149231, 1.4917196035385132,
1.4909634590148926, 1.4905848503112793, 1.4898287057876587, 1.4890738725662231,
1.488316535949707, 1.4871829748153687, 1.4871829748153687, 1.486426830291748,
1.4860494136810303, 1.4849146604537964, 1.4841586351394653, 1.4837812185287476,
1.4826463460922241, 1.481890320777893, 1.4815129041671753, 1.480000615119934,
1.479244589805603, 1.4788658618927002, 1.4777323007583618, 1.4769762754440308,
1.4762201309204102, 1.475464105606079, 1.4747079610824585, 1.473951816558838,
1.4731957912445068, 1.4724396467208862, 1.4709274768829346, 1.4705500602722168,
1.4697939157485962, 1.4686591625213623, 1.467525601387024, 1.4667695760726929,
1.4656360149383545, 1.4648798704147339, 1.4648798704147339, 1.4633677005767822,
1.4626115560531616, 1.4626115560531616, 1.46109938621521, 1.4607206583023071,
1.4595859050750732, 1.4588298797607422, 1.4580737352371216, 1.4569401741027832,
1.4558054208755493, 1.454671859741211, 1.453537106513977, 1.4524036645889282,
1.4520249366760254, 1.4508901834487915, 1.450135350227356, 1.4493792057037354,
1.4482444524765015, 1.4474883079528809, 1.4463547468185425, 1.4459773302078247,
1.4448425769805908, 1.4440877437591553, 1.4429529905319214, 1.4421968460083008,
1.441063404083252, 1.4399298429489136, 1.4395511150360107, 1.438417673110962,
1.4376615285873413, 1.4369053840637207, 1.435393214225769, 1.4342596530914307,
1.4338810443878174, 1.4327462911605835, 1.432747483253479, 1.4301005601882935,
1.4293444156646729, 1.4278322458267212, 1.4266986846923828, 1.4259425401687622,
1.4244303703308105, 1.4229182004928589, 1.4206498861312866, 1.419137716293335,
1.4176255464553833, 1.415357232093811, 1.413467526435852, 1.4111992120742798,
1.4081748723983765, 1.4055278301239014, 1.403638243675232, 1.4006139039993286,
1.3975894451141357, 1.3949437141418457, 1.3919193744659424, 1.3892723321914673,
1.3866266012191772, 1.383602261543274, 1.381712555885315, 1.3783107995986938,
1.3756637573242188, 1.3730180263519287, 1.3707497119903564, 1.3677253723144531,
1.365078330039978, 1.362432599067688, 1.3597856760025024, 1.3571399450302124,
1.3541154861450195, 1.3518472909927368, 1.3492015600204468, 1.346177101135254,
1.3439087867736816, 1.3416404724121094, 1.338616132736206, 1.3363478183746338,
1.3337020874023438, 1.3310550451278687, 1.3284093141555786, 1.3257637023925781,
1.3234953880310059, 1.3208483457565308, 1.3182026147842407, 1.3159343004226685,
1.3129099607467651, 1.3106416463851929, 1.3083733320236206, 1.3061050176620483,
1.3034592866897583, 1.3008123636245728, 1.2981666326522827, 1.2958983182907104,
1.2936300039291382, 1.2906055450439453, 1.2887159585952759, 1.2868250608444214,
1.2841793298721313, 1.281154990196228, 1.2788866758346558, 1.2766183614730835,
1.2739713191986084, 1.2717043161392212, 1.2690573930740356, 1.2671676874160767,
1.2645207643508911, 1.261875033378601, 1.2596067190170288, 1.2573384046554565,
1.2546913623809814, 1.252801775932312, 1.250156044960022, 1.2478877305984497,
1.2459968328475952, 1.2433512210845947, 1.2410829067230225, 1.2388145923614502,
1.2361688613891602, 1.233900547027588, 1.2316322326660156, 1.2293639183044434,
1.2267169952392578, 1.224449872970581, 1.2221815586090088, 1.2202907800674438,
1.2176450490951538, 1.2157541513442993, 1.2138644456863403, 1.2112187147140503,
1.2093279361724854, 1.2066822052001953, 1.2040351629257202, 1.2021455764770508,
1.2002546787261963, 1.1972302198410034, 1.195340633392334, 1.1930723190307617,
1.1908040046691895, 1.1885356903076172, 1.1862674951553345, 1.1839991807937622,
1.18173086643219, 1.179841160774231, 1.1779515743255615, 1.1756820678710938,
1.1730363368988037, 1.1707680225372314, 1.1666101217269897, 1.1647192239761353,
1.1620734930038452, 1.159805178642273, 1.1579155921936035, 1.1564033031463623,
1.1537563800811768, 1.1518667936325073, 1.149598479270935, 1.14695143699646,
1.1450618505477905, 1.1427935361862183, 1.1412813663482666, 1.1390130519866943,
1.136744737625122, 1.134099006652832, 1.1322081089019775, 1.130318522453308,
1.1280502080917358, 1.1265380382537842, 1.1238923072814941, 1.1216239929199219,
1.1201118230819702, 1.1182209253311157, 1.1159526109695435, 1.1140629053115845,
1.1117947101593018, 1.1099050045013428, 1.107635498046875, 1.105745792388916,
1.1034775972366333, 1.1015878915786743, 1.099319577217102, 1.0978074073791504,
1.0951604843139648, 1.0932707786560059, 1.0917586088180542, 1.089490294456482,
1.0872219800949097, 1.0853310823440552, 1.083064079284668, 1.0815519094467163,
1.0789048671722412, 1.0777714252471924, 1.0755031108856201, 1.0732347965240479,
1.0709664821624756, 1.069454312324524, 1.0671859979629517, 1.0656737089157104,
1.0634055137634277, 1.0607597827911377, 1.0592474937438965, 1.0577353239059448,
1.0554670095443726, 1.053954839706421, 1.0516865253448486, 1.0494182109832764,
1.048284649848938, 1.0452589988708496, 1.043748140335083, 1.0422358512878418,
1.0403449535369873, 1.0380767583847046, 1.0365644693374634, 1.0342961549758911,
1.0320279598236084, 1.0301382541656494, 1.0286260843276978, 1.0263577699661255,
1.0248456001281738, 1.0229547023773193, 1.02106511592865, 1.019175410270691,
1.0172845125198364, 1.0153937339782715, 1.0135040283203125, 1.0119918584823608,
1.0097248554229736, 1.0078339576721191, 1.0063217878341675, 1.0040534734725952,
1.0021637678146362, 1.0006515979766846, 0.9983832836151123, 0.9968711137771606,
0.9949802160263062, 0.9930905699729919, 0.9911997318267822, 0.9900661706924438,
0.9874204993247986, 0.9855296015739441, 0.9840173721313477, 0.9817490577697754,
0.9802368879318237, 0.9783472418785095, 0.9768350720405579, 0.9745667576789856,
0.9730545282363892, 0.9715423583984375, 0.9692740440368652, 0.9681405425071716,
0.9658722281455994, 0.9647374153137207, 0.9620917439460754, 0.960579514503479,
0.9590673446655273, 0.9567990303039551, 0.9549093842506409, 0.9533972144126892,
0.9515063166618347
],
"dev": 4,
"shot": 4712,
"time": [
-8000, -7987.099999999999, -7974.2, -7961.299999999999, -7948.400000000001, -7935.5, -7922.6,
-7909.7, -7896.8, -7883.9, -7871, -7858.1, -7845.2, -7832.3, -7819.4, -7806.5,
-7793.599999999999, -7780.700000000001, -7767.8, -7754.900000000001, -7742,
-7729.099999999999, -7716.2, -7703.299999999999, -7690.400000000001, -7677.5, -7664.6,
-7651.7, -7638.8, -7625.9, -7613, -7600.1, -7587.2, -7574.3, -7561.4, -7548.5,
-7535.599999999999, -7522.700000000001, -7509.8, -7496.900000000001, -7484,
-7471.099999999999, -7458.2, -7445.299999999999, -7432.400000000001, -7419.5, -7406.6,
-7393.7, -7380.8, -7367.9, -7355, -7342.1, -7329.2, -7316.3, -7303.4, -7290.5,
-7277.599999999999, -7264.700000000001, -7251.8, -7238.900000000001, -7226,
-7213.099999999999, -7200.2, -7187.299999999999, -7174.400000000001, -7161.5, -7148.6,
-7135.7, -7122.8, -7109.9, -7097, -7084.1, -7071.2, -7058.3, -7045.4, -7032.5,
-7019.599999999999, -7006.700000000001, -6993.8, -6980.900000000001, -6968,
-6955.099999999999, -6942.2, -6929.299999999999, -6916.400000000001, -6903.5, -6890.6,
-6877.7, -6864.8, -6851.9, -6839, -6826.1, -6813.2, -6800.3, -6787.4, -6774.5,
-6761.599999999999, -6748.700000000001, -6735.8, -6722.900000000001, -6710,
-6697.099999999999, -6684.2, -6671.299999999999, -6658.400000000001, -6645.5, -6632.6,
-6619.7, -6606.8, -6593.9, -6581, -6568.1, -6542.3, -6529.4, -6516.5, -6503.599999999999,
-6490.700000000001, -6477.8, -6464.9, -6452, -6439.099999999999, -6426.2, -6413.299999999999,
-6400.400000000001, -6387.5, -6374.6, -6361.7, -6348.8, -6335.9, -6323, -6310.1, -6297.2,
-6284.3, -6271.4, -6258.5, -6245.599999999999, -6232.700000000001, -6219.8, -6206.9, -6194,
-6181.099999999999, -6168.2, -6155.3, -6142.400000000001, -6129.5, -6116.6, -6103.7, -6090.8,
-6077.9, -6065, -6052.1, -6039.2, -6026.3, -6013.4, -6000.5, -5987.599999999999,
-5974.700000000001, -5961.8, -5948.9, -5936, -5923.099999999999, -5910.2, -5897.3,
-5884.400000000001, -5871.5, -5858.6, -5845.7, -5832.8, -5819.9, -5807, -5794.1, -5781.2,
-5768.3, -5755.4, -5742.5, -5729.599999999999, -5716.700000000001, -5703.8, -5690.9, -5678,
-5665.099999999999, -5652.2, -5639.3, -5626.400000000001, -5613.5, -5600.6, -5587.7, -5574.8,
-5561.9, -5549, -5536.1, -5523.2, -5510.3, -5497.4, -5484.5, -5471.599999999999,
-5458.700000000001, -5445.8, -5432.9, -5420, -5407.099999999999, -5394.2, -5381.3,
-5368.400000000001, -5355.5, -5342.6, -5329.7, -5316.8, -5303.9, -5291, -5278.1, -5265.2,
-5252.3, -5239.4, -5226.5, -5213.599999999999, -5200.700000000001, -5187.8, -5174.9, -5162,
-5149.099999999999, -5136.2, -5123.3, -5097.5, -5084.6, -5071.7, -5058.8, -5045.9, -5033,
-5020.1, -5007.2, -4994.3, -4981.4, -4968.5, -4955.599999999999, -4942.700000000001, -4929.8,
-4916.9, -4904, -4891.099999999999, -4878.2, -4865.3, -4852.400000000001, -4839.5, -4826.6,
-4813.7, -4800.8, -4787.9, -4775, -4762.1, -4749.2, -4736.3, -4723.4, -4710.5, -4697.6,
-4684.700000000001, -4671.8, -4658.9, -4646, -4633.099999999999, -4620.2, -4607.3,
-4594.400000000001, -4581.5, -4568.6, -4555.7, -4542.799999999999, -4529.9, -4517, -4504.1,
-4491.2, -4478.3, -4465.4, -4452.5, -4439.6, -4426.700000000001, -4413.8, -4400.9, -4388,
-4375.099999999999, -4362.2, -4349.3, -4336.400000000001, -4323.5, -4310.6, -4297.7,
-4284.799999999999, -4271.9, -4259, -4246.1, -4233.2, -4220.3, -4207.4, -4194.5, -4181.6,
-4168.700000000001, -4155.8, -4142.9, -4130, -4117.099999999999, -4104.2, -4091.3, -4078.4,
-4065.5, -4052.6, -4039.7, -4026.7999999999997, -4013.8999999999996, -4001.0000000000005,
-3988.1000000000004, -3975.2000000000003, -3962.2999999999997, -3949.3999999999996, -3936.5,
-3923.6, -3910.7, -3897.8, -3884.9, -3872, -3859.1000000000004, -3846.2000000000003,
-3833.2999999999997, -3820.3999999999996, -3807.5, -3794.6, -3781.7, -3768.8, -3755.9, -3743,
-3730.1000000000004, -3717.2000000000003, -3704.2999999999997, -3691.3999999999996, -3678.5,
-3652.7, -3639.8, -3626.9, -3614, -3601.1000000000004, -3588.2000000000003,
-3575.2999999999997, -3562.3999999999996, -3549.5, -3536.6, -3523.7, -3510.8, -3497.9, -3485,
-3472.1000000000004, -3459.2000000000003, -3446.2999999999997, -3433.3999999999996, -3420.5,
-3407.6, -3394.7, -3381.8, -3368.9, -3356, -3343.1000000000004, -3330.2000000000003,
-3317.2999999999997, -3304.3999999999996, -3291.5, -3278.6, -3265.7, -3252.8, -3239.9, -3227,
-3214.1000000000004, -3201.2, -3188.2999999999997, -3175.3999999999996, -3162.5, -3149.6,
-3136.7, -3123.8, -3110.9, -3098, -3085.1000000000004, -3072.2, -3059.2999999999997, -3046.4,
-3033.5, -3020.6, -3007.7, -2994.8, -2981.9, -2969, -2956.1000000000004, -2943.2,
-2930.2999999999997, -2917.4, -2904.5, -2891.6, -2878.7, -2865.8, -2852.9, -2840,
-2827.1000000000004, -2814.2, -2801.2999999999997, -2788.4, -2775.5, -2762.6, -2749.7,
-2736.8, -2723.9, -2711, -2698.1000000000004, -2685.2, -2672.2999999999997, -2659.4, -2646.5,
-2633.6, -2620.7, -2607.8, -2594.9, -2582, -2569.1000000000004, -2556.2, -2543.2999999999997,
-2530.4, -2517.5, -2504.6, -2491.7, -2478.8, -2465.9, -2453, -2440.1000000000004, -2427.2,
-2414.2999999999997, -2401.4, -2388.5, -2375.6, -2362.7, -2349.8, -2336.9, -2324,
-2311.1000000000004, -2298.2, -2285.2999999999997, -2272.4, -2259.5, -2246.6, -2233.7,
-2207.9, -2195, -2182.1000000000004, -2169.2, -2156.2999999999997, -2143.4, -2130.5, -2117.6,
-2104.7, -2091.8, -2078.9, -2066, -2053.1000000000004, -2040.2, -2027.3, -2014.4, -2001.5,
-1988.6, -1975.7, -1962.8000000000002, -1949.8999999999999, -1937, -1924.1, -1911.2,
-1898.3000000000002, -1885.3999999999999, -1872.5, -1859.6, -1846.7, -1833.8000000000002,
-1820.8999999999999, -1808, -1795.1, -1782.2, -1769.3000000000002, -1756.3999999999999,
-1743.5, -1730.6, -1717.7, -1704.8000000000002, -1691.8999999999999, -1679, -1666.1, -1653.2,
-1640.3000000000002, -1627.3999999999999, -1614.5, -1601.6, -1588.7, -1575.8000000000002,
-1562.8999999999999, -1550, -1537.1, -1524.2, -1511.3000000000002, -1498.3999999999999,
-1485.5, -1472.6, -1459.7, -1446.8000000000002, -1433.8999999999999, -1421, -1408.1, -1395.2,
-1382.3000000000002, -1369.3999999999999, -1356.5, -1343.6, -1330.7, -1317.8000000000002,
-1304.8999999999999, -1292, -1279.1, -1266.2, -1253.3000000000002, -1240.3999999999999,
-1227.5, -1214.6, -1201.7, -1188.8000000000002, -1175.8999999999999, -1163, -1150.1, -1137.2,
-1124.3000000000002, -1111.3999999999999, -1098.5, -1085.6, -1072.7, -1059.8000000000002,
-1046.8999999999999, -1034, -1021.0999999999999, -1008.1999999999999, -995.3,
-982.4000000000001, -969.5, -956.6, -943.6999999999999, -930.8, -917.9000000000001, -905,
-892.1, -879.1999999999999, -866.3, -853.4000000000001, -840.5, -827.6, -814.6999999999999,
-801.8, -788.9000000000001, -763.1, -750.1999999999999, -737.3, -724.4000000000001, -711.5,
-698.6, -685.6999999999999, -672.8, -659.9000000000001, -647, -634.1, -621.1999999999999,
-608.3, -595.4000000000001, -582.5, -569.6, -556.6999999999999, -543.8, -530.9000000000001,
-518, -505.09999999999997, -492.20000000000005, -479.3, -466.4, -453.5, -440.59999999999997,
-427.70000000000005, -414.8, -401.9, -389, -376.09999999999997, -363.20000000000005, -350.3,
-337.4, -324.5, -311.59999999999997, -298.70000000000005, -285.8, -272.9, -260, -247.1,
-234.2, -221.29999999999998, -208.4, -195.5, -182.60000000000002, -169.7, -156.79999999999998,
-143.9, -131, -118.1, -105.2, -92.3, -79.39999999999999, -66.5, -53.6, -40.7,
-27.799999999999997, -14.9, -2, 10.9, 23.8, 36.7, 49.6, 62.5, 75.39999999999999, 88.3, 101.2,
114.1, 127, 139.9, 152.79999999999998, 165.7, 178.60000000000002, 191.5, 204.4,
217.29999999999998, 230.2, 243.10000000000002, 256, 268.9, 281.8, 294.70000000000005,
307.59999999999997, 320.5, 333.4, 346.3, 359.20000000000005, 372.09999999999997, 385, 397.9,
410.8, 423.70000000000005, 436.59999999999997, 449.5, 462.4, 475.3, 488.20000000000005,
501.09999999999997, 514, 526.9000000000001, 539.8, 552.6999999999999, 565.6, 578.5,
591.4000000000001, 604.3, 617.1999999999999, 630.1, 643, 655.9000000000001, 681.6999999999999,
694.6, 707.5, 720.4000000000001, 733.3, 746.1999999999999, 759.1, 772, 784.9000000000001,
797.8, 810.6999999999999, 823.6, 836.5, 849.4000000000001, 862.3, 875.1999999999999, 888.1,
901, 913.9000000000001, 926.8, 939.6999999999999, 952.6, 965.5, 978.4000000000001, 991.3,
1004.1999999999999, 1017.0999999999999, 1030, 1042.8999999999999, 1055.8000000000002, 1068.7,
1081.6, 1094.5, 1107.3999999999999, 1120.3000000000002, 1133.2, 1146.1, 1159,
1171.8999999999999, 1184.8000000000002, 1197.7, 1210.6, 1223.5, 1236.3999999999999,
1249.3000000000002, 1262.2, 1275.1, 1288, 1300.8999999999999, 1313.8000000000002, 1326.7,
1339.6, 1352.5, 1365.3999999999999, 1378.3000000000002, 1391.2, 1404.1, 1417,
1429.8999999999999, 1442.8000000000002, 1455.7, 1468.6, 1481.5, 1494.3999999999999,
1507.3000000000002, 1520.2, 1533.1, 1546, 1558.8999999999999, 1571.8000000000002, 1584.7,
1597.6, 1610.5, 1623.3999999999999, 1636.3000000000002, 1649.2, 1662.1, 1675,
1687.8999999999999, 1700.8000000000002, 1713.7, 1726.6, 1739.5, 1752.3999999999999,
1765.3000000000002, 1778.2, 1791.1, 1804, 1816.8999999999999, 1829.8000000000002, 1842.7,
1855.6, 1868.5, 1881.3999999999999, 1894.3000000000002, 1907.2, 1920.1, 1933,
1945.8999999999999, 1958.8000000000002, 1971.7, 1984.6, 1997.5, 2010.4, 2023.3, 2036.2,
2049.1000000000004, 2062, 2074.9, 2087.8, 2100.7, 2126.5, 2139.4, 2152.2999999999997, 2165.2,
2178.1000000000004, 2191, 2203.9, 2216.8, 2229.7, 2242.6, 2255.5, 2268.4, 2281.2999999999997,
2294.2, 2307.1000000000004, 2320, 2332.9, 2345.8, 2358.7, 2371.6, 2384.5, 2397.4,
2410.2999999999997, 2423.2, 2436.1000000000004, 2449, 2461.9, 2474.8, 2487.7, 2500.6, 2513.5,
2526.4, 2539.2999999999997, 2552.2, 2565.1000000000004, 2578, 2590.9, 2603.8, 2616.7, 2629.6,
2642.5, 2655.4, 2668.2999999999997, 2681.2, 2694.1000000000004, 2707, 2719.9, 2732.8, 2745.7,
2758.6, 2771.5, 2784.4, 2797.2999999999997, 2810.2, 2823.1000000000004, 2836, 2848.9, 2861.8,
2874.7, 2887.6, 2900.5, 2913.4, 2926.2999999999997, 2939.2, 2952.1000000000004, 2965, 2977.9,
2990.8, 3003.7, 3016.6, 3029.5, 3042.4, 3055.2999999999997, 3068.2, 3081.1000000000004, 3094,
3106.9, 3119.8, 3132.7, 3145.6, 3158.5, 3171.4, 3184.2999999999997, 3197.2,
3210.1000000000004, 3223, 3235.9, 3248.8, 3261.7, 3274.6, 3287.5, 3300.3999999999996,
3313.2999999999997, 3326.2, 3339.1000000000004, 3352, 3364.9, 3377.8, 3390.7, 3403.6, 3416.5,
3429.3999999999996, 3442.2999999999997, 3455.2000000000003, 3468.1000000000004, 3481, 3493.9,
3506.8, 3519.7, 3532.6, 3545.5, 3571.2999999999997, 3584.2000000000003, 3597.1000000000004,
3610, 3622.9, 3635.8, 3648.7, 3661.6, 3674.5, 3687.3999999999996, 3700.2999999999997,
3713.2000000000003, 3726.1000000000004, 3739, 3751.9, 3764.8, 3777.7, 3790.6, 3803.5,
3816.3999999999996, 3829.2999999999997, 3842.2000000000003, 3855.1000000000004, 3868, 3880.9,
3893.8, 3906.7, 3919.6, 3932.5, 3945.3999999999996, 3958.2999999999997, 3971.2000000000003,
3984.1000000000004, 3997, 4009.9, 4022.8, 4035.7000000000003, 4048.6000000000004,
4061.4999999999995, 4074.3999999999996, 4087.2999999999997, 4100.2, 4113.1, 4126, 4138.9,
4151.799999999999, 4164.7, 4177.6, 4190.5, 4203.400000000001, 4216.3, 4229.2,
4242.099999999999, 4255, 4267.9, 4280.8, 4293.700000000001, 4306.6, 4319.5, 4332.4, 4345.3,
4358.2, 4371.1, 4384, 4396.9, 4409.799999999999, 4422.7, 4435.6, 4448.5, 4461.400000000001,
4474.3, 4487.2, 4500.099999999999, 4513, 4525.9, 4538.8, 4551.700000000001, 4564.6, 4577.5,
4590.4, 4603.3, 4616.2, 4629.1, 4642, 4654.9, 4667.799999999999, 4680.7, 4693.6, 4706.5,
4719.400000000001, 4732.3, 4745.2, 4758.099999999999, 4771, 4783.9, 4796.8, 4809.700000000001,
4822.6, 4835.5, 4848.4, 4861.3, 4874.2, 4887.1, 4900, 4912.9, 4925.8, 4938.7, 4951.6, 4964.5,
4977.400000000001, 4990.3
],
"time_unit": "ms"
},
{
"chnl": "BT1_2M",
"chnl_id": 4741,
"dat_unit": "T",
"data": [
0.0003748245071619749, -0.00037091693957336247, 9.768938298293506e-7, -0.0003728707379195839,
-0.00037091693957336247, 9.768938298293506e-7, 9.768938298293506e-7, 9.768938298293506e-7,
9.768938298293506e-7, 9.768938298293506e-7, -0.00037091693957336247, -0.00037091693957336247,
-0.00037091693957336247, 9.768938298293506e-7, 9.768938298293506e-7, 9.768938298293506e-7,
9.768938298293506e-7, 9.768938298293506e-7, -0.00037091693957336247, 9.768938298293506e-7,
9.768938298293506e-7, -0.0003728707379195839, -0.00037091693957336247,
-0.00037091693957336247, 9.768938298293506e-7, 9.768938298293506e-7, 9.768938298293506e-7,
9.768938298293506e-7, 9.768938298293506e-7, 9.768938298293506e-7, -0.0003728707379195839,
9.768938298293506e-7, 9.768938298293506e-7, 9.768938298293506e-7, 9.768938298293506e-7,
9.768938298293506e-7, 9.768938298293506e-7, 9.768938298293506e-7, 9.768938298293506e-7,
-0.00037091693957336247, 9.768938298293506e-7, -0.0003728707379195839,
-0.00037091693957336247, 9.768938298293506e-7, 9.768938298293506e-7, 9.768938298293506e-7,
0.000002930681375801214, 0.0003748245071619749, 9.768938298293506e-7, 9.768938298293506e-7,
9.768938298293506e-7, 0.0003748245071619749, -0.00037091693957336247, 9.768938298293506e-7,
9.768938298293506e-7, 9.768938298293506e-7, 9.768938298293506e-7, 0.0003728707379195839,
9.768938298293506e-7, -0.0003728707379195839, 9.768938298293506e-7, 9.768938298293506e-7,
0.0003748245071619749, 9.768938298293506e-7, 9.768938298293506e-7, 9.768938298293506e-7,
9.768938298293506e-7, 0.0003748245071619749, 9.768938298293506e-7, 9.768938298293506e-7,
-0.00037091693957336247, 0.0003748245071619749, 0.0003728707379195839,
-0.00037091693957336247, 9.768938298293506e-7, 0.0003748245071619749, 0.0003748245071619749,
0.0003748245071619749, 0.0003728707379195839, 0.0003748245071619749, 0.0003748245071619749,
0.0003748245071619749, 0.0003748245071619749, 9.768938298293506e-7, 0.0003748245071619749,
0.0003728707379195839, 9.768938298293506e-7, 9.768938298293506e-7, 9.768938298293506e-7,
9.768938298293506e-7, 0.0003728707379195839, 9.768938298293506e-7, 9.768938298293506e-7,
0.0003748245071619749, 9.768938298293506e-7, 0.0003748245071619749, 0.0003748245071619749,
0.0003748245071619749, 9.768938298293506e-7, 0.0003748245071619749, 9.768938298293506e-7,
0.0007467183750122786, 0.0003748245071619749, 0.0003728707379195839, 0.0007467183750122786,
9.768938298293506e-7, 0.0007467183750122786, 9.768938298293506e-7, 0.0007467183750122786,
9.768938298293506e-7, 0.0007467183750122786, 9.768938298293506e-7, 0.0007467183750122786,
0.0003748245071619749, 0.0007467183750122786, 0.0007467183750122786, 9.768938298293506e-7,
0.0003728707379195839, 0.0011205659247934818, 9.768938298293506e-7, 0.0003748245071619749,
0.0007467183750122786, 0.0003748245071619749, 0.0011205659247934818, 0.0007467183750122786,
0.0007467183750122786, 0.0003748245071619749, 0.0007467183750122786, 9.768938298293506e-7,
0.0003748245071619749, 9.768938298293506e-7, 9.768938298293506e-7, 0.0003748245071619749,
0.0003748245071619749, 0.0007467183750122786, 0.0007467183750122786, 0.0003748245071619749,
9.768938298293506e-7, 0.0003748245071619749, 0.0007467183750122786, 0.0007467183750122786,
0.0003748245071619749, 0.0003748245071619749, 0.0003748245071619749, 9.768938298293506e-7,
0.0003748245071619749, 0.0007467183750122786, 0.0007467183750122786, 0.0007467183750122786,
0.0003748245071619749, 0.0003728707379195839, 0.0003748245071619749, 0.0003748245071619749,
0.0007467183750122786, 0.0011205659247934818, 0.0007467183750122786, 0.0007467183750122786,
0.0007467183750122786, 0.0007467183750122786, 0.0007467183750122786, 0.0007467183750122786,
0.0007467183750122786, 0.0007467183750122786, 0.0007467183750122786, 0.0003748245071619749,
0.0007467183750122786, 0.0003748245071619749, 0.0003748245071619749, 0.0007467183750122786,
0.0007467183750122786, 0.0007467183750122786, 0.0007467183750122786, 0.0003748245071619749,
0.0007467183750122786, 0.0007467183750122786, 0.0007467183750122786, 0.0003748245071619749,
0.0003748245071619749, 0.0007467183750122786, 0.0007467183750122786, 0.0003748245071619749,
0.0007467183750122786, 0.0003748245071619749, 0.0003748245071619749, 0.0007467183750122786,
0.0011205659247934818, 0.0003748245071619749, 0.0011205659247934818, 0.0007467183750122786,
0.0007467183750122786, 0.0011205659247934818, 0.0011205659247934818, 0.0007467183750122786,
0.0007467183750122786, 0.0011205659247934818, 0.0003748245071619749, 0.0007467183750122786,
0.0007486721151508391, 0.0007467183750122786, 0.0007467183750122786, 0.0011205659247934818,
0.0003748245071619749, 0.0007467183750122786, 0.0003748245071619749, 0.0007486721151508391,
0.0003748245071619749, 0.0007467183750122786, 0.0007467183750122786, 0.0003748245071619749,
0.0007467183750122786, 0.0007467183750122786, 0.0007467183750122786, 0.0007467183750122786,
0.0007467183750122786, 0.0007467183750122786, 0.0007467183750122786, 0.0014924597926437855,
0.0011186121264472604, 0.0007467183750122786, 0.0007467183750122786, 0.0007467183750122786,
0.0011205659247934818, 0.0007467183750122786, 0.0011205659247934818, 0.0007467183750122786,
0.0007467183750122786, 0.0007467183750122786, 0.0007467183750122786, 0.0007467183750122786,
0.0007467183750122786, 0.0007467183750122786, 0.0011205659247934818, 0.0011205659247934818,
0.0007467183750122786, 0.0007467183750122786, 0.0014924597926437855, 0.0011205659247934818,
0.0007467183750122786, 0.0007467183750122786, 0.0014924597926437855, 0.0007467183750122786,
0.0007467183750122786, 0.0007467183750122786, 0.0011205659247934818, 0.0007467183750122786,
0.0007467183750122786, 0.0014924597926437855, 0.0011205659247934818, 0.0007467183750122786,
0.0007467183750122786, 0.0011205659247934818, 0.0011205659247934818, 0.0014924597926437855,
0.0007467183750122786, 0.0007467183750122786, 0.0007467183750122786, 0.0011186121264472604,
0.0011186121264472604, 0.0011186121264472604, 0.0014924597926437855, 0.0011205659247934818,
0.0011205659247934818, 0.0007467183750122786, 0.0011205659247934818, 0.0011186121264472604,
0.0007467183750122786, 0.0011205659247934818, 0.0014924597926437855, 0.0011205659247934818,
0.0011186121264472604, 0.0007467183750122786, 0.0011205659247934818, 0.0011186121264472604,
0.0011205659247934818, 0.0011205659247934818, 0.0011205659247934818, 0.0011186121264472604,
0.0007467183750122786, 0.0011186121264472604, 0.0014924597926437855, 0.0014924597926437855,
0.0007467183750122786, 0.0007467183750122786, 0.0011205659247934818, 0.0014924597926437855,
0.0011205659247934818, 0.0014924597926437855, 0.0011205659247934818, 0.0007467183750122786,
0.0011186121264472604, 0.0014924597926437855, 0.0007467183750122786, 0.0011186121264472604,
0.0011205659247934818, 0.0018663074588403106, 0.0007467183750122786, 0.0014924597926437855,
0.0011186121264472604, 0.0011186121264472604, 0.0014924597926437855, 0.0011205659247934818,
0.0014924597926437855, 0.0014924597926437855, 0.0007467183750122786, 0.0014924597926437855,
0.0011205659247934818, 0.0011186121264472604, 0.0014924597926437855, 0.0011186121264472604,
0.0014924597926437855, 0.0018663074588403106, 0.0022382012102752924, 0.0022382012102752924,
0.0029839426279067993, 0.00372968427836895, 0.0041015781462192535, 0.005221167113631964,
0.005966908764094114, 0.0070864977315068245, 0.008204133249819279, 0.009695615619421005,
0.010815205052495003, 0.01230668742209673, 0.01379817072302103, 0.01566154696047306,
0.01752687804400921, 0.01901836134493351, 0.02050984464585781, 0.022747067734599113,
0.024984292685985565, 0.026849623769521713, 0.029086846858263016, 0.03132406994700432,
0.03356129676103592, 0.03915337845683098, 0.04139255732297897, 0.044375523924827576,
0.04735849052667618, 0.05034145712852478, 0.05295252799987793, 0.05593549460172653,
0.05929035320878029, 0.06190142408013344, 0.06563013046979904, 0.06935884058475494,
0.0727156549692154, 0.075698621571064, 0.0794273242354393, 0.08278413861989975,
0.08651284873485565, 0.0906153991818428, 0.0943441092967987, 0.09844470769166946,
0.10217536985874176, 0.10590407997369766, 0.11037852615118027, 0.11485297977924347,
0.11858168244361877, 0.12268424034118652, 0.12790443003177643, 0.13200698792934418,
0.13648143410682678, 0.1409558802843094, 0.14580418169498444, 0.15027862787246704,
0.15549881756305695, 0.160347118973732, 0.1648215651512146, 0.1700417548418045,
0.17489004135131836, 0.18011023104190826, 0.18533042073249817, 0.19092446565628052,
0.19539891183376312, 0.20099295675754547, 0.20695888996124268, 0.21217907965183258,
0.21777310967445374, 0.22336715459823608, 0.22896118462085724, 0.2345532774925232,
0.2397734671831131, 0.24536749720573425, 0.25133344531059265, 0.2576732039451599,
0.2636391520500183, 0.2696050703525543, 0.27594485878944397, 0.2815389037132263,
0.28750482201576233, 0.29421648383140564, 0.30018436908721924, 0.3065222203731537,
0.3124881386756897, 0.31957367062568665, 0.3259134292602539, 0.3326251208782196,
0.3385910391807556, 0.3453027307987213, 0.3516424894332886, 0.3591018617153168,
0.36506780982017517, 0.3725252151489258, 0.3792368769645691, 0.38557666540145874,
0.39228832721710205, 0.39974576234817505, 0.40645939111709595, 0.4135448932647705,
0.42062845826148987, 0.4277139902114868, 0.4347994923591614, 0.4422569274902344,
0.4497162997722626, 0.45679986476898193, 0.4638834297657013, 0.47097089886665344,
0.4788002073764801, 0.4862595796585083, 0.49334314465522766, 0.5011743903160095,
0.5086318254470825, 0.5164631009101868, 0.5235486030578613, 0.5317517518997192,
0.5392091870307922, 0.5470404624938965, 0.5544978380203247, 0.562329113483429,
0.569786548614502, 0.5779896974563599, 0.5861948132514954, 0.5936521887779236,
0.6014834642410278, 0.6096866130828857, 0.6178917288780212, 0.6253491640090942,
0.6335523128509521, 0.6413835883140564, 0.6495867371559143, 0.6577898859977722,
0.6659930348396301, 0.673826277256012, 0.6824012994766235, 0.690606415271759,
0.7066388726234436, 0.7152158617973328, 0.723047137260437, 0.7316241264343262,
0.7394554018974304, 0.748404324054718, 0.7562355399131775, 0.7648125886917114,
0.7730157375335693, 0.7815927267074585, 0.7897958755493164, 0.7983728647232056,
0.8065779805183411, 0.814781129360199, 0.8233581781387329, 0.8315613269805908,
0.8397644758224487, 0.8490872383117676, 0.856918454170227, 0.865495502948761,
0.8733248114585876, 0.8819018006324768, 0.889733076095581, 0.8983080983161926,
0.9065132141113281, 0.9143444895744324, 0.9225456714630127, 0.9307507872581482,
0.9378362894058228, 0.9467852115631104, 0.9546164870262146, 0.9620738625526428,
0.9702770113945007, 0.978108286857605, 0.985565721988678, 0.9933969974517822,
1.0008543729782104, 1.0079379081726074, 1.0150234699249268, 1.0221070051193237,
1.029192566871643, 1.0355323553085327, 1.0422459840774536, 1.0489577054977417,
1.0549235343933105, 1.0612633228302002, 1.0672292709350586, 1.0731971263885498,
1.0791630744934082, 1.084383249282837, 1.0907230377197266, 1.095569372177124,
1.1004177331924438, 1.1056379079818726, 1.1112319231033325, 1.115706443786621,
1.1205546855926514, 1.1250290870666504, 1.129503607749939, 1.133978009223938,
1.1384525299072266, 1.1429269313812256, 1.1466556787490845, 1.1515039205551147,
1.1556065082550049, 1.160080909729004, 1.1638096570968628, 1.1682840585708618,
1.1720128059387207, 1.1761153936386108, 1.1809617280960083, 1.1843185424804688,
1.1884210109710693, 1.192895531654358, 1.1966242790222168, 1.2007248401641846,
1.2044554948806763, 1.208556056022644, 1.2126586437225342, 1.2167612314224243,
1.2204898595809937, 1.224590539932251, 1.2286930084228516, 1.2320479154586792,
1.2365243434906006, 1.2398791313171387, 1.2436078786849976, 1.2477104663848877,
1.2510672807693481, 1.255167841911316, 1.2585246562957764, 1.2626252174377441,
1.2656102180480957, 1.2697107791900635, 1.2726937532424927, 1.2767963409423828,
1.2801531553268433, 1.2838817834854126, 1.2876105308532715, 1.290967345237732,
1.2946960926055908, 1.298050880432129, 1.301033854484558, 1.3043906688690186,
1.3081194162368774, 1.3107304573059082, 1.3148311376571655, 1.3178139925003052,
1.3207969665527344, 1.324527621269226, 1.3275105953216553, 1.3342223167419434,
1.3372052907943726, 1.3398163318634033, 1.3431731462478638, 1.3465280532836914,
1.3491390943527222, 1.3521220684051514, 1.3554788827896118, 1.3580880165100098,
1.3606990575790405, 1.3636820316314697, 1.3674107789993286, 1.3692760467529297,
1.3722590208053589, 1.375241994857788, 1.3774791955947876, 1.3804621696472168,
1.383445143699646, 1.3860561847686768, 1.3882935047149658, 1.391276478767395,
1.3938875198364258, 1.3964966535568237, 1.3987338542938232, 1.4009710550308228,
1.4039559364318848, 1.4061912298202515, 1.4088022708892822, 1.4110395908355713,
1.413650631904602, 1.4155139923095703, 1.418125033378601, 1.420734167098999,
1.4225995540618896, 1.4248367547988892, 1.4270739555358887, 1.4289393424987793,
1.4311745166778564, 1.4334137439727783, 1.4352771043777466, 1.437514305114746,
1.4393796920776367, 1.4416168928146362, 1.4434822797775269, 1.4457194805145264,
1.4475828409194946, 1.4494481086730957, 1.450939655303955, 1.4531768560409546,
1.454668402671814, 1.456533670425415, 1.4583970308303833, 1.460262417793274,
1.4613800048828125, 1.4628715515136719, 1.4651087522506714, 1.4666022062301636,
1.4680936336517334, 1.4695851802825928, 1.471448540687561, 1.4721941947937012,
1.4736857414245605, 1.4755491018295288, 1.4766687154769897, 1.4777863025665283,
1.479651689529419, 1.4807692766189575, 1.4818888902664185, 1.4833803176879883,
1.4844999313354492, 1.4859914779663086, 1.4867371320724487, 1.4878548383712769,
1.4893462657928467, 1.4900920391082764, 1.490837812423706, 1.4923292398452759,
1.4930750131607056, 1.4941946268081665, 1.4949404001235962, 1.4956860542297363,
1.4968056678771973, 1.4975494146347046, 1.4982951879501343, 1.4986690282821655,
1.500160574913025, 1.500160574913025, 1.5012800693511963, 1.502025842666626,
1.5027716159820557, 1.503143548965454, 1.5038892030715942, 1.5042630434036255,
1.5046368837356567, 1.5053826570510864, 1.5057545900344849, 1.5065003633499146,
1.5065003633499146, 1.5072460174560547, 1.5072460174560547, 1.5079917907714844,
1.5079917907714844, 1.5079917907714844, 1.508737564086914, 1.5091114044189453,
1.5094833374023438, 1.5094833374023438, 1.5094833374023438, 1.509857177734375,
1.5102289915084839, 1.5106009244918823, 1.5102289915084839, 1.5106009244918823,
1.5102289915084839, 1.5106009244918823, 1.5106028318405151, 1.5106009244918823,
1.5106009244918823, 1.5106009244918823, 1.5102289915084839, 1.5102289915084839,
1.5102289915084839, 1.5102289915084839, 1.5098551511764526, 1.5094833374023438,
1.5094833374023438, 1.5094833374023438, 1.509109377861023, 1.5083637237548828,
1.5079917907714844, 1.5079917907714844, 1.507619857788086, 1.5072460174560547,
1.5068721771240234, 1.5068721771240234, 1.5065003633499146, 1.5061265230178833,
1.5050069093704224, 1.5046368837356567, 1.5038892030715942, 1.5042630434036255,
1.5035173892974854, 1.5027716159820557, 1.5023977756500244, 1.5016520023345947,
1.5012800693511963, 1.5005344152450562, 1.4997867345809937, 1.4994148015975952,
1.4990428686141968, 1.4982951879501343, 1.4979232549667358, 1.4971776008605957,
1.4960579872131348, 1.4960579872131348, 1.4949404001235962, 1.4941946268081665,
1.4938207864761353, 1.4927011728286743, 1.4923292398452759, 1.4915835857391357,
1.490837812423706, 1.4900920391082764, 1.4893462657928467, 1.488228678703308,
1.4878548383712769, 1.4863632917404175, 1.4859914779663086, 1.4856176376342773,
1.4848718643188477, 1.4833803176879883, 1.4833803176879883, 1.482260823249817,
1.4811431169509888, 1.4803974628448486, 1.4792778491973877, 1.4789040088653564,
1.4777863025665283, 1.4770406484603882, 1.4762948751449585, 1.4755491018295288,
1.4744294881820679, 1.474057674407959, 1.4725642204284668, 1.47182035446167,
1.4714465141296387, 1.4699550867080688, 1.4692093133926392, 1.4695812463760376,
1.4680917263031006, 1.4669721126556396, 1.4666001796722412, 1.4654825925827026,
1.4643629789352417, 1.463617205619812, 1.4624996185302734, 1.4621257781982422,
1.4606342315673828, 1.4595166444778442, 1.459142804145813, 1.458023190498352,
1.4569056034088135, 1.4569056034088135, 1.455414056777954, 1.4542945623397827,
1.4531749486923218, 1.4520572423934937, 1.4513115882873535, 1.4505658149719238,
1.4501919746398926, 1.4490723609924316, 1.4475809335708618, 1.4468351602554321,
1.4464632272720337, 1.4449697732925415, 1.4442260265350342, 1.4434783458709717,
1.4423606395721436, 1.4416149854660034, 1.4412411451339722, 1.4393776655197144,
1.439003825187683, 1.4371404647827148, 1.4363948106765747, 1.4349013566970825,
1.4337836503982544, 1.4326660633087158, 1.4315464496612549, 1.4293092489242554,
1.427817702293396, 1.425952434539795, 1.4240890741348267, 1.422223687171936,
1.4203603267669678, 1.417749285697937, 1.4155120849609375, 1.4125291109085083,
1.409917950630188, 1.4069350957870483, 1.4046977758407593, 1.4013429880142212,
1.3987318277359009, 1.3961207866668701, 1.3935116529464722, 1.390528678894043,
1.3879176378250122, 1.3853065967559814, 1.382325530052185, 1.3797144889831543,
1.3774772882461548, 1.3741204738616943, 1.3715113401412964, 1.3692741394042969,
1.3662911653518677, 1.363680124282837, 1.3614428043365479, 1.3580859899520874,
1.355848789215088, 1.35323965549469, 1.3506286144256592, 1.3483914136886597,
1.3457822799682617, 1.343171238899231, 1.3405601978302002, 1.337577223777771,
1.335339903831482, 1.3331027030944824, 1.3301197290420532, 1.3278825283050537,
1.325271487236023, 1.3222885131835938, 1.3204251527786255, 1.3178139925003052,
1.3152029514312744, 1.312965750694275, 1.310356616973877, 1.3077455759048462,
1.3055083751678467, 1.3025254011154175, 1.3006620407104492, 1.298050880432129,
1.2954398393630981, 1.2928307056427002, 1.2909654378890991, 1.2883563041687012,
1.2857471704483032, 1.28313410282135, 1.2805249691009521, 1.2782877683639526,
1.2760505676269531, 1.2738133668899536, 1.2708303928375244, 1.268593192100525,
1.2663559913635254, 1.263744831085205, 1.2615076303482056, 1.259270429611206,
1.2574050426483154, 1.2547959089279175, 1.2518130540847778, 1.2499476671218872,
1.2477104663848877, 1.2454732656478882, 1.2428621053695679, 1.2406249046325684,
1.2387615442276, 1.2365243434906006, 1.2339133024215698, 1.2316759824752808, 1.22906494140625,
1.2272015810012817, 1.2249643802642822, 1.2223533391952515, 1.2201160192489624,
1.217878818511963, 1.2156416177749634, 1.2134044170379639, 1.2111672163009644,
1.2089298963546753, 1.2066926956176758, 1.2044554948806763, 1.2022182941436768,
1.1996071338653564, 1.1981157064437866, 1.194760799407959, 1.192895531654358,
1.1914039850234985, 1.1884210109710693, 1.1865557432174683, 1.1843185424804688,
1.1817094087600708, 1.1798440217971802, 1.1776068210601807, 1.1731324195861816,
1.171267032623291, 1.1697756052017212, 1.1667945384979248, 1.1645554304122925,
1.163063883781433, 1.1608266830444336, 1.158589482307434, 1.1563522815704346,
1.1541149616241455, 1.1522496938705444, 1.1503863334655762, 1.147403359413147,
1.1459099054336548, 1.1433007717132568, 1.1410635709762573, 1.139200210571289,
1.1373348236083984, 1.135097622871399, 1.133606195449829, 1.13136887550354,
1.1287578344345093, 1.1265206336975098, 1.1246552467346191, 1.1220461130142212,
1.1209285259246826, 1.1186892986297607, 1.115706443786621, 1.114588737487793,
1.1123496294021606, 1.1104861497879028, 1.1082489490509033, 1.1060117483139038,
1.104520320892334, 1.101911187171936, 1.099673867225647, 1.0985543727874756,
1.0959432125091553, 1.0944517850875854, 1.092214584350586, 1.0903512239456177,
1.0877400636672974, 1.0858747959136963, 1.084011435508728, 1.0821460485458374,
1.0802826881408691, 1.0780454874038696, 1.0758082866668701, 1.0739428997039795,
1.0720795392990112, 1.0702141523361206, 1.067976951599121, 1.0664855241775513,
1.064622163772583, 1.062384843826294, 1.0605195760726929, 1.0586562156677246,
1.056790828704834, 1.0545536279678345, 1.0526883602142334, 1.0508248805999756,
1.0489596128463745, 1.046722412109375, 1.0448590517044067, 1.0429936647415161,
1.0411303043365479, 1.0392649173736572, 1.0373996496200562, 1.035536289215088,
1.0332990884780884, 1.0314356088638306, 1.0295703411102295, 1.0280787944793701,
1.026213526725769, 1.0243501663208008, 1.0221129655838013, 1.0202475786209106,
1.0187561511993408, 1.0165188312530518, 1.015027403831482, 1.0127902030944824,
1.011298656463623, 1.0090614557266235, 1.006824254989624, 1.0053327083587646,
1.0038412809371948, 1.0016040802001953, 1.000112533569336, 0.9978753328323364,
0.9956381320953369, 0.994518518447876, 0.9922813177108765, 0.9900440573692322,
0.9885525703430176, 0.987061083316803, 0.9851957559585571, 0.9833323955535889,
0.981467068195343, 0.9799755811691284, 0.9777383804321289, 0.9762468934059143,
0.9743815660476685, 0.9728900790214539, 0.9710266590118408, 0.969535231590271,
0.9672979712486267, 0.9654326438903809, 0.9635692834854126, 0.9617039561271667,
0.9602124691009521, 0.9583491086959839
],
"dev": 4,
"shot": 4712,
"time": [
-8000, -7987.099999999999, -7974.2, -7961.299999999999, -7948.400000000001, -7935.5, -7922.6,
-7909.7, -7896.8, -7883.9, -7871, -7858.1, -7845.2, -7832.3, -7819.4, -7806.5,
-7793.599999999999, -7780.700000000001, -7767.8, -7754.900000000001, -7742,
-7729.099999999999, -7716.2, -7703.299999999999, -7690.400000000001, -7677.5, -7664.6,
-7651.7, -7638.8, -7625.9, -7613, -7600.1, -7587.2, -7574.3, -7561.4, -7548.5,
-7535.599999999999, -7522.700000000001, -7509.8, -7496.900000000001, -7484,
-7471.099999999999, -7458.2, -7445.299999999999, -7432.400000000001, -7419.5, -7406.6,
-7393.7, -7380.8, -7367.9, -7355, -7342.1, -7329.2, -7316.3, -7303.4, -7290.5,
-7277.599999999999, -7264.700000000001, -7251.8, -7238.900000000001, -7226,
-7213.099999999999, -7200.2, -7187.299999999999, -7174.400000000001, -7161.5, -7148.6,
-7135.7, -7122.8, -7109.9, -7097, -7084.1, -7071.2, -7058.3, -7045.4, -7032.5,
-7019.599999999999, -7006.700000000001, -6993.8, -6980.900000000001, -6968,
-6955.099999999999, -6942.2, -6929.299999999999, -6916.400000000001, -6903.5, -6890.6,
-6877.7, -6864.8, -6851.9, -6839, -6826.1, -6813.2, -6800.3, -6787.4, -6774.5,
-6761.599999999999, -6748.700000000001, -6735.8, -6722.900000000001, -6710,
-6697.099999999999, -6684.2, -6671.299999999999, -6658.400000000001, -6645.5, -6632.6,
-6619.7, -6606.8, -6593.9, -6581, -6568.1, -6542.3, -6529.4, -6516.5, -6503.599999999999,
-6490.700000000001, -6477.8, -6464.9, -6452, -6439.099999999999, -6426.2, -6413.299999999999,
-6400.400000000001, -6387.5, -6374.6, -6361.7, -6348.8, -6335.9, -6323, -6310.1, -6297.2,
-6284.3, -6271.4, -6258.5, -6245.599999999999, -6232.700000000001, -6219.8, -6206.9, -6194,
-6181.099999999999, -6168.2, -6155.3, -6142.400000000001, -6129.5, -6116.6, -6103.7, -6090.8,
-6077.9, -6065, -6052.1, -6039.2, -6026.3, -6013.4, -6000.5, -5987.599999999999,
-5974.700000000001, -5961.8, -5948.9, -5936, -5923.099999999999, -5910.2, -5897.3,
-5884.400000000001, -5871.5, -5858.6, -5845.7, -5832.8, -5819.9, -5807, -5794.1, -5781.2,
-5768.3, -5755.4, -5742.5, -5729.599999999999, -5716.700000000001, -5703.8, -5690.9, -5678,
-5665.099999999999, -5652.2, -5639.3, -5626.400000000001, -5613.5, -5600.6, -5587.7, -5574.8,
-5561.9, -5549, -5536.1, -5523.2, -5510.3, -5497.4, -5484.5, -5471.599999999999,
-5458.700000000001, -5445.8, -5432.9, -5420, -5407.099999999999, -5394.2, -5381.3,
-5368.400000000001, -5355.5, -5342.6, -5329.7, -5316.8, -5303.9, -5291, -5278.1, -5265.2,
-5252.3, -5239.4, -5226.5, -5213.599999999999, -5200.700000000001, -5187.8, -5174.9, -5162,
-5149.099999999999, -5136.2, -5123.3, -5097.5, -5084.6, -5071.7, -5058.8, -5045.9, -5033,
-5020.1, -5007.2, -4994.3, -4981.4, -4968.5, -4955.599999999999, -4942.700000000001, -4929.8,
-4916.9, -4904, -4891.099999999999, -4878.2, -4865.3, -4852.400000000001, -4839.5, -4826.6,
-4813.7, -4800.8, -4787.9, -4775, -4762.1, -4749.2, -4736.3, -4723.4, -4710.5, -4697.6,
-4684.700000000001, -4671.8, -4658.9, -4646, -4633.099999999999, -4620.2, -4607.3,
-4594.400000000001, -4581.5, -4568.6, -4555.7, -4542.799999999999, -4529.9, -4517, -4504.1,
-4491.2, -4478.3, -4465.4, -4452.5, -4439.6, -4426.700000000001, -4413.8, -4400.9, -4388,
-4375.099999999999, -4362.2, -4349.3, -4336.400000000001, -4323.5, -4310.6, -4297.7,
-4284.799999999999, -4271.9, -4259, -4246.1, -4233.2, -4220.3, -4207.4, -4194.5, -4181.6,
-4168.700000000001, -4155.8, -4142.9, -4130, -4117.099999999999, -4104.2, -4091.3, -4078.4,
-4065.5, -4052.6, -4039.7, -4026.7999999999997, -4013.8999999999996, -4001.0000000000005,
-3988.1000000000004, -3975.2000000000003, -3962.2999999999997, -3949.3999999999996, -3936.5,
-3923.6, -3910.7, -3897.8, -3884.9, -3872, -3859.1000000000004, -3846.2000000000003,
-3833.2999999999997, -3820.3999999999996, -3807.5, -3794.6, -3781.7, -3768.8, -3755.9, -3743,
-3730.1000000000004, -3717.2000000000003, -3704.2999999999997, -3691.3999999999996, -3678.5,
-3652.7, -3639.8, -3626.9, -3614, -3601.1000000000004, -3588.2000000000003,
-3575.2999999999997, -3562.3999999999996, -3549.5, -3536.6, -3523.7, -3510.8, -3497.9, -3485,
-3472.1000000000004, -3459.2000000000003, -3446.2999999999997, -3433.3999999999996, -3420.5,
-3407.6, -3394.7, -3381.8, -3368.9, -3356, -3343.1000000000004, -3330.2000000000003,
-3317.2999999999997, -3304.3999999999996, -3291.5, -3278.6, -3265.7, -3252.8, -3239.9, -3227,
-3214.1000000000004, -3201.2, -3188.2999999999997, -3175.3999999999996, -3162.5, -3149.6,
-3136.7, -3123.8, -3110.9, -3098, -3085.1000000000004, -3072.2, -3059.2999999999997, -3046.4,
-3033.5, -3020.6, -3007.7, -2994.8, -2981.9, -2969, -2956.1000000000004, -2943.2,
-2930.2999999999997, -2917.4, -2904.5, -2891.6, -2878.7, -2865.8, -2852.9, -2840,
-2827.1000000000004, -2814.2, -2801.2999999999997, -2788.4, -2775.5, -2762.6, -2749.7,
-2736.8, -2723.9, -2711, -2698.1000000000004, -2685.2, -2672.2999999999997, -2659.4, -2646.5,
-2633.6, -2620.7, -2607.8, -2594.9, -2582, -2569.1000000000004, -2556.2, -2543.2999999999997,
-2530.4, -2517.5, -2504.6, -2491.7, -2478.8, -2465.9, -2453, -2440.1000000000004, -2427.2,
-2414.2999999999997, -2401.4, -2388.5, -2375.6, -2362.7, -2349.8, -2336.9, -2324,
-2311.1000000000004, -2298.2, -2285.2999999999997, -2272.4, -2259.5, -2246.6, -2233.7,
-2207.9, -2195, -2182.1000000000004, -2169.2, -2156.2999999999997, -2143.4, -2130.5, -2117.6,
-2104.7, -2091.8, -2078.9, -2066, -2053.1000000000004, -2040.2, -2027.3, -2014.4, -2001.5,
-1988.6, -1975.7, -1962.8000000000002, -1949.8999999999999, -1937, -1924.1, -1911.2,
-1898.3000000000002, -1885.3999999999999, -1872.5, -1859.6, -1846.7, -1833.8000000000002,
-1820.8999999999999, -1808, -1795.1, -1782.2, -1769.3000000000002, -1756.3999999999999,
-1743.5, -1730.6, -1717.7, -1704.8000000000002, -1691.8999999999999, -1679, -1666.1, -1653.2,
-1640.3000000000002, -1627.3999999999999, -1614.5, -1601.6, -1588.7, -1575.8000000000002,
-1562.8999999999999, -1550, -1537.1, -1524.2, -1511.3000000000002, -1498.3999999999999,
-1485.5, -1472.6, -1459.7, -1446.8000000000002, -1433.8999999999999, -1421, -1408.1, -1395.2,
-1382.3000000000002, -1369.3999999999999, -1356.5, -1343.6, -1330.7, -1317.8000000000002,
-1304.8999999999999, -1292, -1279.1, -1266.2, -1253.3000000000002, -1240.3999999999999,
-1227.5, -1214.6, -1201.7, -1188.8000000000002, -1175.8999999999999, -1163, -1150.1, -1137.2,
-1124.3000000000002, -1111.3999999999999, -1098.5, -1085.6, -1072.7, -1059.8000000000002,
-1046.8999999999999, -1034, -1021.0999999999999, -1008.1999999999999, -995.3,
-982.4000000000001, -969.5, -956.6, -943.6999999999999, -930.8, -917.9000000000001, -905,
-892.1, -879.1999999999999, -866.3, -853.4000000000001, -840.5, -827.6, -814.6999999999999,
-801.8, -788.9000000000001, -763.1, -750.1999999999999, -737.3, -724.4000000000001, -711.5,
-698.6, -685.6999999999999, -672.8, -659.9000000000001, -647, -634.1, -621.1999999999999,
-608.3, -595.4000000000001, -582.5, -569.6, -556.6999999999999, -543.8, -530.9000000000001,
-518, -505.09999999999997, -492.20000000000005, -479.3, -466.4, -453.5, -440.59999999999997,
-427.70000000000005, -414.8, -401.9, -389, -376.09999999999997, -363.20000000000005, -350.3,
-337.4, -324.5, -311.59999999999997, -298.70000000000005, -285.8, -272.9, -260, -247.1,
-234.2, -221.29999999999998, -208.4, -195.5, -182.60000000000002, -169.7, -156.79999999999998,
-143.9, -131, -118.1, -105.2, -92.3, -79.39999999999999, -66.5, -53.6, -40.7,
-27.799999999999997, -14.9, -2, 10.9, 23.8, 36.7, 49.6, 62.5, 75.39999999999999, 88.3, 101.2,
114.1, 127, 139.9, 152.79999999999998, 165.7, 178.60000000000002, 191.5, 204.4,
217.29999999999998, 230.2, 243.10000000000002, 256, 268.9, 281.8, 294.70000000000005,
307.59999999999997, 320.5, 333.4, 346.3, 359.20000000000005, 372.09999999999997, 385, 397.9,
410.8, 423.70000000000005, 436.59999999999997, 449.5, 462.4, 475.3, 488.20000000000005,
501.09999999999997, 514, 526.9000000000001, 539.8, 552.6999999999999, 565.6, 578.5,
591.4000000000001, 604.3, 617.1999999999999, 630.1, 643, 655.9000000000001, 681.6999999999999,
694.6, 707.5, 720.4000000000001, 733.3, 746.1999999999999, 759.1, 772, 784.9000000000001,
797.8, 810.6999999999999, 823.6, 836.5, 849.4000000000001, 862.3, 875.1999999999999, 888.1,
901, 913.9000000000001, 926.8, 939.6999999999999, 952.6, 965.5, 978.4000000000001, 991.3,
1004.1999999999999, 1017.0999999999999, 1030, 1042.8999999999999, 1055.8000000000002, 1068.7,
1081.6, 1094.5, 1107.3999999999999, 1120.3000000000002, 1133.2, 1146.1, 1159,
1171.8999999999999, 1184.8000000000002, 1197.7, 1210.6, 1223.5, 1236.3999999999999,
1249.3000000000002, 1262.2, 1275.1, 1288, 1300.8999999999999, 1313.8000000000002, 1326.7,
1339.6, 1352.5, 1365.3999999999999, 1378.3000000000002, 1391.2, 1404.1, 1417,
1429.8999999999999, 1442.8000000000002, 1455.7, 1468.6, 1481.5, 1494.3999999999999,
1507.3000000000002, 1520.2, 1533.1, 1546, 1558.8999999999999, 1571.8000000000002, 1584.7,
1597.6, 1610.5, 1623.3999999999999, 1636.3000000000002, 1649.2, 1662.1, 1675,
1687.8999999999999, 1700.8000000000002, 1713.7, 1726.6, 1739.5, 1752.3999999999999,
1765.3000000000002, 1778.2, 1791.1, 1804, 1816.8999999999999, 1829.8000000000002, 1842.7,
1855.6, 1868.5, 1881.3999999999999, 1894.3000000000002, 1907.2, 1920.1, 1933,
1945.8999999999999, 1958.8000000000002, 1971.7, 1984.6, 1997.5, 2010.4, 2023.3, 2036.2,
2049.1000000000004, 2062, 2074.9, 2087.8, 2100.7, 2126.5, 2139.4, 2152.2999999999997, 2165.2,
2178.1000000000004, 2191, 2203.9, 2216.8, 2229.7, 2242.6, 2255.5, 2268.4, 2281.2999999999997,
2294.2, 2307.1000000000004, 2320, 2332.9, 2345.8, 2358.7, 2371.6, 2384.5, 2397.4,
2410.2999999999997, 2423.2, 2436.1000000000004, 2449, 2461.9, 2474.8, 2487.7, 2500.6, 2513.5,
2526.4, 2539.2999999999997, 2552.2, 2565.1000000000004, 2578, 2590.9, 2603.8, 2616.7, 2629.6,
2642.5, 2655.4, 2668.2999999999997, 2681.2, 2694.1000000000004, 2707, 2719.9, 2732.8, 2745.7,
2758.6, 2771.5, 2784.4, 2797.2999999999997, 2810.2, 2823.1000000000004, 2836, 2848.9, 2861.8,
2874.7, 2887.6, 2900.5, 2913.4, 2926.2999999999997, 2939.2, 2952.1000000000004, 2965, 2977.9,
2990.8, 3003.7, 3016.6, 3029.5, 3042.4, 3055.2999999999997, 3068.2, 3081.1000000000004, 3094,
3106.9, 3119.8, 3132.7, 3145.6, 3158.5, 3171.4, 3184.2999999999997, 3197.2,
3210.1000000000004, 3223, 3235.9, 3248.8, 3261.7, 3274.6, 3287.5, 3300.3999999999996,
3313.2999999999997, 3326.2, 3339.1000000000004, 3352, 3364.9, 3377.8, 3390.7, 3403.6, 3416.5,
3429.3999999999996, 3442.2999999999997, 3455.2000000000003, 3468.1000000000004, 3481, 3493.9,
3506.8, 3519.7, 3532.6, 3545.5, 3571.2999999999997, 3584.2000000000003, 3597.1000000000004,
3610, 3622.9, 3635.8, 3648.7, 3661.6, 3674.5, 3687.3999999999996, 3700.2999999999997,
3713.2000000000003, 3726.1000000000004, 3739, 3751.9, 3764.8, 3777.7, 3790.6, 3803.5,
3816.3999999999996, 3829.2999999999997, 3842.2000000000003, 3855.1000000000004, 3868, 3880.9,
3893.8, 3906.7, 3919.6, 3932.5, 3945.3999999999996, 3958.2999999999997, 3971.2000000000003,
3984.1000000000004, 3997, 4009.9, 4022.8, 4035.7000000000003, 4048.6000000000004,
4061.4999999999995, 4074.3999999999996, 4087.2999999999997, 4100.2, 4113.1, 4126, 4138.9,
4151.799999999999, 4164.7, 4177.6, 4190.5, 4203.400000000001, 4216.3, 4229.2,
4242.099999999999, 4255, 4267.9, 4280.8, 4293.700000000001, 4306.6, 4319.5, 4332.4, 4345.3,
4358.2, 4371.1, 4384, 4396.9, 4409.799999999999, 4422.7, 4435.6, 4448.5, 4461.400000000001,
4474.3, 4487.2, 4500.099999999999, 4513, 4525.9, 4538.8, 4551.700000000001, 4564.6, 4577.5,
4590.4, 4603.3, 4616.2, 4629.1, 4642, 4654.9, 4667.799999999999, 4680.7, 4693.6, 4706.5,
4719.400000000001, 4732.3, 4745.2, 4758.099999999999, 4771, 4783.9, 4796.8, 4809.700000000001,
4822.6, 4835.5, 4848.4, 4861.3, 4874.2, 4887.1, 4900, 4912.9, 4925.8, 4938.7, 4951.6, 4964.5,
4977.400000000001, 4990.3
],
"time_unit": "ms"
}
]

1
src/env.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="vite/client" />

49
src/index.ts Normal file
View File

@@ -0,0 +1,49 @@
/**
* 波形分析组件库主入口
* @packageDocumentation
*/
// Vue 组件
export { default as WaveformChart } from './components/WaveformChart.vue'
// 类型定义
export type {
// 图表类型
WaveformPoint,
WaveformDisplayMode,
WaveformInteractionMode,
WaveformAnnotationStyle,
WaveformAnnotation,
WaveformRenderingOptions,
// 数据类型
SingleWaveformData,
WaveformSeries,
WaveformData,
NormalizedWaveformSeries,
} from './types'
export type { WaveformGridOptions } from './components/core/grid'
// 核心功能
export { normalizeWaveformData, normalizeWaveformSeries } from './core'
// 工具函数
export {
paddedDomain,
buildMinorTicks,
displayTime,
formatEndpointTime,
formatAxisTime,
formatTooltipTime,
resolveTrackGeometry,
clamp,
type TimeUnit,
type TrackGeometry,
} from './utils'
export {
DEFAULT_WAVEFORM_RENDERING_OPTIONS,
resolveWaveformRenderingOptions,
selectRenderablePoints,
type ResolvedWaveformRenderingOptions,
} from './core'

7
src/main.ts Normal file
View File

@@ -0,0 +1,7 @@
import { createApp } from 'vue'
import 'ant-design-vue/dist/reset.css'
import App from './App.vue'
import './styles.css'
createApp(App).mount('#app')

130
src/styles.css Normal file
View File

@@ -0,0 +1,130 @@
:root {
color: #101828;
font-family:
Inter,
ui-sans-serif,
system-ui,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
sans-serif;
font-synthesis: none;
text-rendering: optimizeLegibility;
background: #f5f7fa;
}
* {
box-sizing: border-box;
}
body {
min-width: 320px;
min-height: 100vh;
margin: 0;
}
.workspace {
width: min(1440px, 100%);
margin: 0 auto;
padding: 28px clamp(16px, 4vw, 56px) 48px;
}
.workspace__header {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 24px;
margin-bottom: 24px;
}
.workspace__eyebrow {
margin: 0 0 6px;
color: #1677ff;
font-size: 12px;
font-weight: 700;
text-transform: uppercase;
}
h1,
p {
margin-top: 0;
}
h1 {
margin-bottom: 0;
font-size: 28px;
font-weight: 650;
}
.control-bar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
padding: 12px 16px;
background: #fff;
border: 1px solid #e4e7ec;
border-bottom: 0;
}
.control-bar__leading {
display: flex;
flex: 0 0 auto;
gap: 12px;
align-items: center;
}
.display-mode-control {
display: inline-flex;
white-space: nowrap;
}
.grid-size-control {
display: inline-flex;
align-items: center;
gap: 6px;
color: #475467;
font-size: 12px;
}
.grid-size-control .ant-input-number {
width: 54px;
}
.metrics {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px 18px;
color: #667085;
font-size: 12px;
font-variant-numeric: tabular-nums;
}
.chart-panel {
background: transparent;
}
@media (max-width: 700px) {
.workspace {
padding-top: 20px;
}
.workspace__header,
.control-bar {
align-items: stretch;
flex-direction: column;
}
.control-bar__leading {
flex-wrap: wrap;
}
.display-mode-control {
max-width: 100%;
}
.metrics {
justify-content: flex-start;
}
}

54
src/test/setup.ts Normal file
View File

@@ -0,0 +1,54 @@
import { beforeEach, vi } from 'vitest'
interface ResizeObserverEntryMock {
target: Element
contentRect: DOMRectReadOnly
}
type ResizeCallback = (entries: ResizeObserverEntryMock[]) => void
export const resizeObservers: ResizeObserverMock[] = []
export class ResizeObserverMock {
private target?: Element
constructor(private readonly callback: ResizeCallback) {
resizeObservers.push(this)
}
observe = vi.fn((target: Element) => {
this.target = target
})
unobserve = vi.fn()
disconnect = vi.fn()
resize(width: number, height = 400) {
if (!this.target) return
this.callback([
{
target: this.target,
contentRect: { width, height } as DOMRectReadOnly,
},
])
}
}
vi.stubGlobal('ResizeObserver', ResizeObserverMock)
vi.stubGlobal(
'matchMedia',
vi.fn((query: string): MediaQueryList => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(),
removeListener: vi.fn(),
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
})),
)
beforeEach(() => {
resizeObservers.length = 0
})

46
src/types/chart.ts Normal file
View File

@@ -0,0 +1,46 @@
/**
* 波形数据点
*/
export interface WaveformPoint {
x: number
y: number
}
/**
* 显示模式
* - independent: 每个波形独立 Y 轴和缩放
* - separated: 波形垂直堆叠,共享 X 轴
* - compact: 波形叠加显示
*/
export type WaveformDisplayMode = 'independent' | 'separated' | 'compact'
/** 标注工具模式 */
export type WaveformInteractionMode = 'zoom' | 'annotation'
/** 标注颜色样式 */
export interface WaveformAnnotationStyle {
borderColor?: string
textColor?: string
backgroundColor?: string
}
/** 绑定到波形数据坐标的文字标注 */
export interface WaveformAnnotation {
id: string
seriesId: string
x: number
y: number
text: string
style?: WaveformAnnotationStyle
createdAt?: string
}
/** Controls how many source points are included in the rendered SVG path. */
export interface WaveformRenderingOptions {
/** Disable only when every source point must be rendered. */
downsample?: boolean
/** Visible point count below which the complete range is rendered. */
downsampleThreshold?: number
/** Upper bound for rendered points per horizontal CSS pixel. */
maxPointsPerPixel?: number
}

48
src/types/data.ts Normal file
View File

@@ -0,0 +1,48 @@
import type { WaveformPoint } from './chart'
/**
* 单波形数据格式(采样点或显式坐标点)
*/
export type SingleWaveformData =
| {
kind: 'samples'
values: number[]
sampleRate: number
startTime?: number
}
| {
kind: 'points'
points: WaveformPoint[]
}
/**
* 波形系列
*/
export interface WaveformSeries {
id?: string
name: string
unit?: string
color?: string
data: SingleWaveformData
}
/**
* 波形数据(单波形或多通道)
*/
export type WaveformData =
| SingleWaveformData
| {
kind: 'series'
series: WaveformSeries[]
}
/**
* 规范化后的波形系列
*/
export interface NormalizedWaveformSeries {
id: string
name: string
unit?: string
color?: string
points: WaveformPoint[]
}

21
src/types/index.ts Normal file
View File

@@ -0,0 +1,21 @@
/**
* 类型定义统一导出
*/
// 图表类型
export type {
WaveformPoint,
WaveformDisplayMode,
WaveformInteractionMode,
WaveformAnnotationStyle,
WaveformAnnotation,
WaveformRenderingOptions,
} from './chart'
// 数据类型
export type {
SingleWaveformData,
WaveformSeries,
WaveformData,
NormalizedWaveformSeries,
} from './data'

29
src/utils/domain.ts Normal file
View File

@@ -0,0 +1,29 @@
import { extent } from 'd3'
/**
* 计算带边距的数据域
* @param values 数值数组
* @returns 数据域 [最小值, 最大值],如果数组为空返回 [0, 1]
*/
export function paddedDomain(values: number[]): [number, number] {
if (values.length === 0) return [0, 1]
const [minimum = 0, maximum = 1] = extent(values)
if (minimum !== maximum) return [minimum, maximum]
const padding = Math.abs(minimum) * 0.05 || 0.5
return [minimum - padding, maximum + padding]
}
/**
* 在主刻度之间生成次要刻度
* @param values 主刻度值数组
* @param subdivisions 细分数量,默认 5
* @returns 次要刻度值数组
*/
export function buildMinorTicks(values: number[], subdivisions = 5): number[] {
return values.flatMap((value, index) => {
const nextValue = values[index + 1]
if (nextValue === undefined) return []
const step = (nextValue - value) / subdivisions
return Array.from({ length: subdivisions - 1 }, (_, minorIndex) => value + step * (minorIndex + 1))
})
}

View File

@@ -0,0 +1,57 @@
import { describe, expect, it } from 'vitest'
import {
formatAnnotationTime,
formatPlainNumber,
formatScientificYAxisLabel,
formatTooltipNumber,
shouldUseScientificYAxisLabel,
} from './formatters'
describe('waveform number formatters', () => {
it('uses the reference Y-axis scientific notation boundaries', () => {
expect(shouldUseScientificYAxisLabel(0)).toBe(false)
expect(shouldUseScientificYAxisLabel(0.009)).toBe(true)
expect(shouldUseScientificYAxisLabel(0.01)).toBe(false)
expect(shouldUseScientificYAxisLabel(99.99)).toBe(false)
expect(shouldUseScientificYAxisLabel(100)).toBe(true)
})
it('shares one exponent and prefixes only the top visible tick', () => {
const positiveAxis = { axisMin: 0, axisMax: 254, topTickValue: 254 }
expect(formatScientificYAxisLabel(127, positiveAxis)).toBe('1.27')
expect(formatScientificYAxisLabel(254, positiveAxis)).toBe('E+02 2.54')
const tinyAxis = { axisMin: 0, axisMax: 0.0002, topTickValue: 0.0002 }
expect(formatScientificYAxisLabel(0.0001, tinyAxis)).toBe('1.00')
expect(formatScientificYAxisLabel(0.0002, tinyAxis)).toBe('E-04 2.00')
const negativeAxis = { axisMin: -254, axisMax: 0, topTickValue: 0 }
expect(formatScientificYAxisLabel(-254, negativeAxis)).toBe('-2.54')
expect(formatScientificYAxisLabel(0, negativeAxis)).toBe('E+02 0.00')
})
it('keeps plain axes at two decimals and removes negative zero', () => {
expect(formatScientificYAxisLabel(99.99, { axisMin: 0, axisMax: 99.99 })).toBe('99.99')
expect(formatScientificYAxisLabel(0.01, { axisMin: 0, axisMax: 0.01 })).toBe('0.01')
expect(formatScientificYAxisLabel(-0.001, { axisMin: -1, axisMax: 1 })).toBe('0.00')
expect(formatScientificYAxisLabel(Number.NaN)).toBe('NaN')
expect(formatScientificYAxisLabel(Number.POSITIVE_INFINITY)).toBe('Infinity')
})
it('formats tooltip and raw values for their display contexts', () => {
expect(formatTooltipNumber(12345.67891)).toBe('12,345.6789')
expect(formatTooltipNumber(-0)).toBe('0')
expect(formatTooltipNumber(Number.POSITIVE_INFINITY)).toBe('Infinity')
expect(formatPlainNumber(0.0000001)).toBe('0.0000001')
expect(formatPlainNumber(1e21)).toBe('1000000000000000000000')
expect(formatPlainNumber(-0)).toBe('0')
})
it('formats annotation time in the selected unit without changing source seconds', () => {
expect(formatAnnotationTime(1, 'ms')).toBe('1000.000')
expect(formatAnnotationTime(1, 's')).toBe('1.000')
expect(formatAnnotationTime(-0, 'ms')).toBe('0.000')
expect(formatAnnotationTime(Number.NaN, 's')).toBe('NaN')
})
})

179
src/utils/formatters.ts Normal file
View File

@@ -0,0 +1,179 @@
/**
* 时间单位类型
*/
export type TimeUnit = 'ms' | 's'
export interface ScientificYAxisLabelOptions {
precision?: number
axisMin?: number
axisMax?: number
topTickValue?: number
}
const DEFAULT_Y_AXIS_PRECISION = 2
const SCIENTIFIC_MIN_ABSOLUTE_VALUE = 0.01
const SCIENTIFIC_MAX_PLAIN_ABSOLUTE_VALUE = 100
const TOOLTIP_NUMBER_FORMATTER = new Intl.NumberFormat('zh-CN', {
maximumFractionDigits: 4,
})
function formatFixedNumber(value: number, precision: number): string {
const formatted = value.toFixed(Math.max(0, precision))
return /^-0(?:\.0+)?$/.test(formatted) ? formatted.slice(1) : formatted
}
/** Whether an axis magnitude should use one shared scientific exponent. */
export function shouldUseScientificYAxisLabel(maxAbsoluteValue: number): boolean {
return (
Number.isFinite(maxAbsoluteValue) &&
(maxAbsoluteValue >= SCIENTIFIC_MAX_PLAIN_ABSOLUTE_VALUE ||
(maxAbsoluteValue > 0 && maxAbsoluteValue < SCIENTIFIC_MIN_ABSOLUTE_VALUE))
)
}
function resolveScientificExponent(axisMin?: number, axisMax?: number): number | null {
if (typeof axisMin !== 'number' || typeof axisMax !== 'number') return null
const maxAbsoluteValue = Math.max(Math.abs(axisMin), Math.abs(axisMax))
return shouldUseScientificYAxisLabel(maxAbsoluteValue)
? Math.floor(Math.log10(maxAbsoluteValue))
: null
}
function formatExponent(exponent: number): string {
const sign = exponent >= 0 ? '+' : '-'
return `E${sign}${Math.abs(exponent).toString().padStart(2, '0')}`
}
/** Format a Y-axis tick, sharing one exponent derived from the complete axis domain. */
export function formatScientificYAxisLabel(
value: number,
options: ScientificYAxisLabelOptions = {},
): string {
if (!Number.isFinite(value)) return String(value)
const precision = options.precision ?? DEFAULT_Y_AXIS_PRECISION
const exponent = resolveScientificExponent(options.axisMin, options.axisMax)
const scaledValue = exponent === null ? value : value / 10 ** exponent
const formattedValue = formatFixedNumber(scaledValue, precision)
return exponent !== null && value === options.topTickValue
? `${formatExponent(exponent)} ${formattedValue}`
: formattedValue
}
/** Format tooltip values as localized plain numbers with at most four decimal places. */
export function formatTooltipNumber(value: number): string {
if (!Number.isFinite(value)) return String(value)
if (Object.is(value, -0)) return '0'
return TOOLTIP_NUMBER_FORMATTER.format(value)
}
/** Convert a number to complete plain decimal text without forcing exponential notation. */
export function formatPlainNumber(value: number): string {
if (!Number.isFinite(value)) return String(value)
if (Object.is(value, -0)) return '0'
const [mantissaPart, exponentPart] = value.toExponential().split('e')
const exponent = Number(exponentPart)
const isNegative = mantissaPart.startsWith('-')
const digits = mantissaPart.replace('-', '').replace('.', '')
const decimalIndex = exponent + 1
let plainText: string
if (decimalIndex <= 0) {
plainText = `0.${'0'.repeat(Math.abs(decimalIndex))}${digits}`
} else if (decimalIndex >= digits.length) {
plainText = `${digits}${'0'.repeat(decimalIndex - digits.length)}`
} else {
plainText = `${digits.slice(0, decimalIndex)}.${digits.slice(decimalIndex)}`
}
return `${isNegative ? '-' : ''}${plainText}`
}
/**
* 根据时间单位转换显示值
* @param value 原始时间值(秒)
* @param timeUnit 时间单位
* @returns 转换后的显示值
*/
export function displayTime(value: number, timeUnit: TimeUnit): number {
return timeUnit === 'ms' ? value * 1000 : value
}
/**
* 计算端点标签的小数位数
* @param domain 数据域 [最小值, 最大值]
* @param timeUnit 时间单位
* @returns 小数位数
*/
export function endpointFractionDigits(domain: [number, number], timeUnit: TimeUnit): number {
const displayedSpan = Math.abs(
displayTime(domain[1], timeUnit) - displayTime(domain[0], timeUnit),
)
if (!Number.isFinite(displayedSpan) || displayedSpan <= 0) return 0
return Math.min(4, Math.max(0, Math.ceil(-Math.log10(displayedSpan / 100))))
}
/**
* 格式化端点时间(动态精度,本地化格式)
* @param value 时间值(秒)
* @param domain 数据域
* @param timeUnit 时间单位
* @returns 格式化的时间字符串
*/
export function formatEndpointTime(
value: number,
domain: [number, number],
timeUnit: TimeUnit,
): string {
const displayValue = displayTime(value, timeUnit)
const digits = endpointFractionDigits(domain, timeUnit)
// 如果是整数值且计算出的小数位数会导致显示小数则强制为0
if (displayValue === Math.floor(displayValue) && digits > 0) {
return displayValue.toLocaleString('zh-CN', {
minimumFractionDigits: 0,
maximumFractionDigits: 0,
})
}
return displayValue.toLocaleString('zh-CN', {
minimumFractionDigits: digits,
maximumFractionDigits: digits,
})
}
/**
* 格式化坐标轴时间(整数,本地化格式)
* @param value 时间值(秒)
* @param timeUnit 时间单位
* @returns 格式化的时间字符串
*/
export function formatAxisTime(value: number, timeUnit: TimeUnit): string {
const displayValue = displayTime(value, timeUnit)
return displayValue.toLocaleString('zh-CN', {
maximumFractionDigits: 0,
})
}
/**
* 格式化悬浮提示时间4 位小数,本地化格式)
* @param value 时间值(秒)
* @param timeUnit 时间单位
* @returns 格式化的时间字符串
*/
export function formatTooltipTime(value: number, timeUnit: TimeUnit): string {
const displayValue = displayTime(value, timeUnit)
return displayValue.toLocaleString('zh-CN', {
minimumFractionDigits: 4,
maximumFractionDigits: 4,
})
}
/** Format an annotation X coordinate in the selected display time unit. */
export function formatAnnotationTime(value: number, timeUnit: TimeUnit): string {
if (!Number.isFinite(value)) return String(value)
return formatFixedNumber(displayTime(value, timeUnit), 3)
}

50
src/utils/geometry.ts Normal file
View File

@@ -0,0 +1,50 @@
import type { WaveformDisplayMode } from '@/types'
/**
* 轨道几何信息
*/
export interface TrackGeometry {
/** 轨道间距 */
gap: number
/** 坐标轴区域高度 */
axisBand: number
/** 单个轨道高度 */
height: number
}
/**
* 计算轨道布局几何信息
* @param trackCount 轨道数量
* @param displayMode 显示模式
* @param innerHeight 可用高度
* @returns 轨道几何信息
*/
export function resolveTrackGeometry(
trackCount: number,
displayMode: WaveformDisplayMode,
innerHeight: number,
): TrackGeometry {
if (trackCount <= 0) return { gap: 0, axisBand: 0, height: 0 }
const desiredGap = displayMode === 'compact' ? 0 : displayMode === 'separated' ? 16 : 14
const desiredAxisBand = displayMode === 'independent' ? 30 : 0
const desiredReserve = (trackCount - 1) * (desiredGap + desiredAxisBand)
const maximumReserve = innerHeight * 0.45
const reserveScale = desiredReserve > maximumReserve ? maximumReserve / desiredReserve : 1
const gap = desiredGap * reserveScale
const axisBand = desiredAxisBand * reserveScale
const height = Math.max(1, (innerHeight - (trackCount - 1) * (gap + axisBand)) / trackCount)
return { gap, axisBand, height }
}
/**
* 限制数值在指定范围内
* @param value 待限制的值
* @param min 最小值
* @param max 最大值
* @returns 限制后的值
*/
export function clamp(value: number, min: number, max: number): number {
return Math.min(Math.max(value, min), max)
}

25
src/utils/index.ts Normal file
View File

@@ -0,0 +1,25 @@
/**
* 工具函数模块统一导出
*/
// 域计算工具
export { paddedDomain, buildMinorTicks } from './domain'
// 格式化工具
export {
displayTime,
endpointFractionDigits,
formatEndpointTime,
formatAxisTime,
formatTooltipTime,
formatAnnotationTime,
formatPlainNumber,
formatScientificYAxisLabel,
formatTooltipNumber,
shouldUseScientificYAxisLabel,
type ScientificYAxisLabelOptions,
type TimeUnit,
} from './formatters'
// 几何计算工具
export { resolveTrackGeometry, clamp, type TrackGeometry } from './geometry'