caoziwu 1 неделя назад
Родитель
Сommit
fb0c08718a

+ 1 - 0
package.json

@@ -27,6 +27,7 @@
     "@vicons/fa": "^0.13.0",
     "@vicons/ionicons4": "^0.13.0",
     "dayjs": "^1.11.23",
+    "jsxgraph": "1",
     "less": "^4.9.1",
     "naive-ui": "^2.45.3",
     "vite-plugin-compression": "^0.5.1",

+ 9 - 0
pnpm-lock.yaml

@@ -23,6 +23,9 @@ importers:
       dayjs:
         specifier: ^1.11.23
         version: 1.11.23
+      jsxgraph:
+        specifier: '1'
+        version: 1.14.3
       less:
         specifier: ^4.9.1
         version: 4.9.1
@@ -2318,6 +2321,10 @@ packages:
   jsonfile@6.2.0:
     resolution: {integrity: sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==}
 
+  jsxgraph@1.14.3:
+    resolution: {integrity: sha512-0JMGdESQnIrOZ6rN+N2qzcjM/8DQdxVNXsvTLcMhG4GvqnM0PZTU6mrrA1TsdyAgRQXiIyrowQp/PIwB41Vkig==}
+    engines: {node: '>=20.19.0'}
+
   keyv@3.1.0:
     resolution: {integrity: sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==}
 
@@ -5625,6 +5632,8 @@ snapshots:
     optionalDependencies:
       graceful-fs: 4.2.11
 
+  jsxgraph@1.14.3: {}
+
   keyv@3.1.0:
     dependencies:
       json-buffer: 3.0.0

+ 79 - 18
src/renderer/src/components/simulator/DiagramPanel.vue

@@ -1,10 +1,9 @@
 <script setup lang="ts">
-import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
+import { computed, onBeforeUnmount, onMounted, ref, watch, nextTick } from 'vue'
 import { useI18n } from 'vue-i18n'
-import { echarts } from '../../lib/speaker/echarts/install'
-import type { EChartsCoreOption } from 'echarts/core'
+import { JSXGraph, type Board } from '../../lib/speaker/jsxgraph/install'
 import type { CalcResult, SpeakerParams } from '../../lib/speaker/types'
-import { buildChartEmptyOption, buildDiagramOption } from '../../lib/speaker/echarts'
+import { drawDiagram } from '../../lib/speaker/jsxgraph/diagram'
 import { useChartPalette } from '../../theme/useChartPalette'
 
 const props = defineProps<{
@@ -16,11 +15,12 @@ const chartDom = ref<HTMLDivElement | null>(null)
 const { t, locale } = useI18n()
 const palette = useChartPalette()
 
-let chart: ReturnType<typeof echarts.init> | null = null
+let board: Board | null = null
 let resizeObserver: ResizeObserver | null = null
 
 const render = (): void => {
-  if (!chart) return
+  if (!board || !chartDom.value) return
+
   const labels = {
     empty: t('diagram.empty'),
     horizontalDistance: t('diagram.horizontalDistance'),
@@ -31,38 +31,99 @@ const render = (): void => {
     coverage: t('diagram.coverage'),
     vertical: t('diagram.vertical')
   }
+
   const pal = palette.value
-  const option: EChartsCoreOption = props.result
-    ? buildDiagramOption(props.params, labels, pal)
-    : buildChartEmptyOption(labels.empty, pal)
-  chart.setOption(option, true)
+  const { z, d1, d2, d3 } = props.params
+
+  // 1. 基础物理数据边界
+  const rawMaxD = Math.max(d1, d2, d3, 5) * 1.13
+  const rawMaxZ = Math.max(z * 1.15, 3.5)
+
+  // 2. 获取当前 DOM 容器的实际像素宽高比
+  const rect = chartDom.value.getBoundingClientRect()
+  const ratio = rect.width / Math.max(rect.height, 1)
+
+  // 3. 强制让数据的宽高比与屏幕像素的宽高比一致,防止变形
+  // 预留 15% 的左边距放文字,15% 的底部边距放刻度
+  let finalMaxD = rawMaxD
+  let finalMaxZ = rawMaxZ
+
+  if (finalMaxD / finalMaxZ < ratio) {
+    finalMaxD = finalMaxZ * ratio // 宽度不够,拉宽 X 轴
+  } else {
+    finalMaxZ = finalMaxD / ratio // 高度不够,拉高 Y 轴
+  }
+
+  // 4. 严格设定边界 [xMin, yMax, xMax, yMin]
+  const viewBox: [number, number, number, number] = [
+    -finalMaxD * 0.1,
+    finalMaxZ * 1.15,
+    finalMaxD * 1.05,
+    -finalMaxZ * 0.1
+  ]
+
+  board.setBoundingBox(viewBox, false)
+
+  // 5. 将修正后的最大边界传给绘制函数,保证画的网格和坐标轴填满屏幕
+  drawDiagram(
+    board,
+    { ...props.params, maxD: finalMaxD, maxZ: finalMaxZ } as SpeakerParams & {
+      maxD: number
+      maxZ: number
+    },
+    props.result,
+    labels,
+    pal
+  )
 }
 
-// 显式解构全部参数 + 结果:任何字段变化都会生成新快照 → 触发重绘
 const snapshot = computed(() => {
   const { splMax, z, hCov, vCov, dir, angle, d1, d2, d3 } = props.params
   return { splMax, z, hCov, vCov, dir, angle, d1, d2, d3, result: props.result }
 })
 watch(snapshot, render)
 watch(locale, render)
-// 主题切换后重绘(palette 来自 naive 主题变量,随 dark/light 变化)
 watch(palette, render)
 
-onMounted(() => {
+onMounted(async () => {
+  await nextTick()
   if (!chartDom.value) return
-  chart = echarts.init(chartDom.value)
+
+  board = JSXGraph.initBoard(chartDom.value, {
+    boundingbox: [0, 5, 5, 0],
+    keepAspectRatio: false, // 核心改动:彻底关闭,靠我们手算比例
+    axis: false,
+    grid: false,
+    renderer: 'svg',
+    showNavigation: false,
+    showCopyright: false,
+    showInfobox: false,
+    pan: { enabled: false },
+    zoom: false
+  })
+
   render()
-  resizeObserver = new ResizeObserver(() => chart?.resize())
+
+  resizeObserver = new ResizeObserver(() => {
+    // 窗口拉伸时,重新计算比例并重绘
+    render()
+  })
   resizeObserver.observe(chartDom.value)
 })
 
 onBeforeUnmount(() => {
   resizeObserver?.disconnect()
-  chart?.dispose()
-  chart = null
+  if (board) {
+    JSXGraph.freeBoard(board)
+    board = null
+  }
 })
 </script>
 
 <template>
-  <div ref="chartDom" class="chart-box chart-box--diagram"></div>
+  <div
+    ref="chartDom"
+    class="chart-box chart-box--diagram"
+    style="height: 100%; min-height: 350px; width: 100%"
+  ></div>
 </template>

+ 38 - 18
src/renderer/src/components/simulator/SPLChartPanel.vue

@@ -1,10 +1,9 @@
 <script setup lang="ts">
-import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
+import { computed, onBeforeUnmount, onMounted, ref, watch, nextTick } from 'vue'
 import { useI18n } from 'vue-i18n'
-import { echarts } from '../../lib/speaker/echarts/install'
-import type { EChartsOption } from 'echarts/core'
+import { JSXGraph, type Board } from '../../lib/speaker/jsxgraph/install'
 import type { CalcResult, SpeakerParams } from '../../lib/speaker/types'
-import { buildChartEmptyOption, buildSplChartOption } from '../../lib/speaker/echarts'
+import { drawSplDiagram } from '../../lib/speaker/jsxgraph/splDiagram'
 import { useChartPalette } from '../../theme/useChartPalette'
 
 const props = defineProps<{
@@ -16,49 +15,70 @@ const chartDom = ref<HTMLDivElement | null>(null)
 const { t, locale } = useI18n()
 const palette = useChartPalette()
 
-let chart: ReturnType<typeof echarts.init> | null = null
+let board: Board | null = null
 let resizeObserver: ResizeObserver | null = null
 
 const render = (): void => {
-  if (!chart) return
+  if (!board || !chartDom.value) return
+
   const labels = {
     empty: t('chart.empty'),
     distance: t('chart.distance'),
     spl: t('chart.spl'),
     title: t('chart.title')
   }
+
   const pal = palette.value
-  const option: EChartsOption = props.result
-    ? buildSplChartOption(props.params, props.result, labels, pal)
-    : buildChartEmptyOption(labels.empty, pal)
-  chart.setOption(option, true)
+  drawSplDiagram(board, props.params, props.result, labels, pal)
 }
 
-// 显式解构全部参数 + 结果:任何字段变化都会生成新快照 → 触发重绘
 const snapshot = computed(() => {
   const { splMax, z, hCov, vCov, dir, angle, d1, d2, d3 } = props.params
   return { splMax, z, hCov, vCov, dir, angle, d1, d2, d3, result: props.result }
 })
 watch(snapshot, render)
 watch(locale, render)
-// 主题切换后重绘(palette 来自 naive 主题变量,随 dark/light 变化)
 watch(palette, render)
 
-onMounted(() => {
+onMounted(async () => {
+  await nextTick()
   if (!chartDom.value) return
-  chart = echarts.init(chartDom.value)
+
+  board = JSXGraph.initBoard(chartDom.value, {
+    boundingbox: [0, 100, 20, 0], // 初始占位,绘制时会被覆盖
+    keepAspectRatio: false, // 允许拉伸以填满容器
+    axis: false,
+    grid: false,
+    renderer: 'svg',
+    showNavigation: false,
+    showCopyright: false,
+    showInfobox: false,
+    pan: { enabled: false },
+    zoom: false
+  })
+
   render()
-  resizeObserver = new ResizeObserver(() => chart?.resize())
+
+  resizeObserver = new ResizeObserver(() => {
+    // 窗口拉伸时,重新根据数据计算 BoundingBox 自适应
+    render()
+  })
   resizeObserver.observe(chartDom.value)
 })
 
 onBeforeUnmount(() => {
   resizeObserver?.disconnect()
-  chart?.dispose()
-  chart = null
+  if (board) {
+    JSXGraph.freeBoard(board)
+    board = null
+  }
 })
 </script>
 
 <template>
-  <div ref="chartDom" class="chart-box chart-box--spl"></div>
+  <div
+    ref="chartDom"
+    class="chart-box chart-box--spl"
+    style="height: 100%; min-height: 300px; width: 100%"
+  ></div>
 </template>

+ 47 - 56
src/renderer/src/components/simulator/TopDiagramPanel.vue

@@ -1,10 +1,9 @@
 <script setup lang="ts">
 import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
 import { useI18n } from 'vue-i18n'
-import { echarts } from '../../lib/speaker/echarts/install'
-import type { EChartsCoreOption } from 'echarts/core'
+import { JSXGraph, type Board } from '../../lib/speaker/jsxgraph/install'
 import type { CalcResult, SpeakerParams } from '../../lib/speaker/types'
-import { buildChartEmptyOption, buildTopDiagramOption } from '../../lib/speaker/echarts'
+import { drawTopDiagram } from '../../lib/speaker/jsxgraph/topDiagram'
 import { useChartPalette } from '../../theme/useChartPalette'
 
 const props = defineProps<{
@@ -14,87 +13,79 @@ const props = defineProps<{
 }>()
 
 const chartDom = ref<HTMLDivElement | null>(null)
-const { t, locale } = useI18n()
+const { locale } = useI18n()
 const palette = useChartPalette()
 const covAngle = ref(180)
-const emit = defineEmits<{
-  (e: 'update-cov-angle', value: number): void
-}>()
 
-let chart: ReturnType<typeof echarts.init> | null = null
+let board: Board | null = null
 let resizeObserver: ResizeObserver | null = null
 
 const render = (): void => {
-  if (!chart) return
-  const labels = {
-    empty: t('diagram.empty'),
-    forwardDistance: t('diagram.forwardDistance'),
-    lateralDistance: t('diagram.lateralDistance'),
-    leftBound: t('diagram.leftBound'),
-    rightBound: t('diagram.rightBound'),
-    acousticAxis: t('diagram.acousticAxis'),
-    coverage: t('diagram.coverage'),
-    horizontal: t('diagram.coverage')
-  }
+  if (!board || !chartDom.value) return
   const pal = palette.value
-  const option: EChartsCoreOption = props.result
-    ? buildTopDiagramOption(snapshot.value, labels, pal)
-    : buildChartEmptyOption(labels.empty, pal)
-  chart.setOption(option, true)
+  // 修复:把滑块的值合并进参数再传给绘图函数
+  drawTopDiagram(board, { ...props.params, covAngle: covAngle.value }, pal)
 }
-const updateCovAngle = (value: number): void => {
-  covAngle.value = value
-  emit('update-cov-angle', value)
-}
-// 显式解构全部参数 + 结果:任何字段变化都会生成新快照 → 触发重绘
+
 const snapshot = computed(() => {
   const { splMax, z, vCov, dir, d1, d2, d3, hCov } = props.params
-  return {
-    splMax,
-    z,
-    vCov,
-    dir,
-    covAngle: covAngle.value,
-    d1,
-    hCov,
-    d2,
-    d3,
-    result: props.result
-  } as SpeakerParams & { result?: CalcResult }
+  return { splMax, z, vCov, dir, d1, hCov, d2, d3, result: props.result }
 })
+
 watch(snapshot, render)
 watch(locale, render)
-// 主题切换后重绘(palette 来自 naive 主题变量,随 dark/light 变化)
 watch(palette, render)
-const formatTooltip = (value: number): string => `${t('diagram.coverage')}:${value}°`
+
 onMounted(() => {
   covAngle.value = props.covAngleParams
   if (!chartDom.value) return
-  chart = echarts.init(chartDom.value)
+
+  const { d1, d2, d3 } = props.params
+  // 留出充足的边框和标签空间
+  const maxD = Math.max(d1, d2, d3, 5) * 1.2
+
+  board = JSXGraph.initBoard(chartDom.value, {
+    boundingbox: [-maxD, maxD, maxD, -maxD], // 正方形视口
+    keepAspectRatio: true,
+    axis: false, // 关闭原生轴,改由 TS 代码绘制
+    grid: false,
+    renderer: 'svg',
+    showNavigation: false,
+    showCopyright: false,
+    showInfobox: false,
+    zoom: false,
+    pan: { enabled: false }
+  })
+
   render()
-  resizeObserver = new ResizeObserver(() => chart?.resize())
+
+  resizeObserver = new ResizeObserver(() => {
+    board?.update()
+  })
   resizeObserver.observe(chartDom.value)
 })
 
 onBeforeUnmount(() => {
   resizeObserver?.disconnect()
-  chart?.dispose()
-  chart = null
+  if (board) {
+    JSXGraph.freeBoard(board)
+    board = null
+  }
 })
 </script>
 
 <template>
   <div class="diagram-panel">
     <div ref="chartDom" class="chart-box chart-box--top"></div>
-
-    <n-space style="height: 360px; justify-content: center">
-      <n-slider
-        v-model:value="covAngle"
-        :max="360"
-        vertical
-        :format-tooltip="formatTooltip"
-        @update:value="updateCovAngle"
-      />
-    </n-space>
   </div>
 </template>
+<style scoped>
+/* 强行去掉点击后产生的金黄色焦点框 */
+.chart-box,
+.chart-box *,
+.chart-box svg,
+.chart-box svg * {
+  outline: none !important;
+  box-shadow: none !important;
+}
+</style>

+ 0 - 298
src/renderer/src/lib/speaker/echarts/diagramOption.ts

@@ -1,298 +0,0 @@
-/**
- * 覆盖示意图(侧视图)ECharts option 工厂
- *
- * 说明:侧视图是垂直剖面图,覆盖扇形物理上应始终使用垂直指向角 V,而不是跟随
- * H/V 切换(原实现把水平角画进垂直剖面导致"不准确")。SPL 计算仍由 H/V 开关决定。
- */
-import type { DefaultLabelFormatterCallbackParams, EChartsOption, SeriesOption } from 'echarts'
-import type { SpeakerParams } from '../types'
-import { DEG, splAt } from '../calc'
-import type { ChartPalette } from './palette'
-import { fmtN } from './utils'
-
-export interface DiagramChartLabels {
-  empty: string
-  horizontalDistance: string
-  height: string
-  upperBound: string
-  lowerBound: string
-  acousticAxis: string
-  coverage: string
-  vertical: string
-}
-
-export function buildDiagramOption(
-  p: SpeakerParams,
-  labels: DiagramChartLabels,
-  pal: ChartPalette
-): EChartsOption {
-  const { z, d1, d2, d3, angle, vCov } = p
-  // 垂直剖面:覆盖角固定取 V(垂直指向角)
-  const cov = vCov
-  const t6 = cov / 2
-
-  const maxD = Math.max(d1, d2, d3, 5) * 1.13
-  const maxZ = Math.max(z * 1.45, 3.5)
-
-  const aRad = angle * DEG
-  const t6Rad = t6 * DEG
-  const upperAngle = aRad + t6Rad
-  const lowerAngle = aRad - t6Rad
-  const dFar = upperAngle < Math.PI / 2 - 0.01 ? z / Math.tan(upperAngle) : maxD * 3
-  const dNear = lowerAngle > 0.01 ? z / Math.tan(lowerAngle) : -1
-
-  const nearX = dNear >= 0 ? Math.min(maxD, Math.max(0, dNear)) : null
-  const farX = dFar > 0 ? Math.min(maxD, dFar) : null
-
-  const series: SeriesOption[] = []
-
-  // 覆盖区域阴影:[0, z] + 地面交点围成的三角形
-  if (nearX !== null && farX !== null) {
-    // 按 X 轴坐标从小到大排序,避免折线图渲染时产生折返导致的填充错乱
-    const leftX = Math.min(nearX, farX)
-    const rightX = Math.max(nearX, farX)
-
-    series.push({
-      name: labels.coverage,
-      type: 'line',
-      data: [
-        [0, z],
-        [leftX, 0],
-        [rightX, 0],
-        [0, z] // 显式闭合多边形,让 ECharts 准确填充内部
-      ],
-      showSymbol: false,
-      lineStyle: { opacity: 0 }, // 隐藏边框线,只要填充
-      areaStyle: { color: pal.accent, opacity: 0.1 },
-      silent: true,
-      z: 2
-    } as SeriesOption)
-  }
-
-  // 地面覆盖带(D 近场~远场之间的橙色条)
-  if (nearX !== null && farX !== null && farX > nearX) {
-    series.push({
-      name: labels.coverage,
-      type: 'line',
-      data: [
-        [nearX, 0],
-        [farX, 0]
-      ],
-      showSymbol: false,
-      lineStyle: { color: pal.accent, opacity: 0.35, width: 5 },
-      silent: true,
-      z: 2
-    } as SeriesOption)
-  }
-
-  // -6dB 上/下边界虚线
-  if (farX !== null) {
-    series.push({
-      type: 'line',
-      name: labels.upperBound,
-      data: [
-        [0, z],
-        [farX, 0]
-      ],
-      showSymbol: false,
-      lineStyle: { color: pal.accent, type: 'dashed', opacity: 0.6, width: 1.2 },
-      silent: true,
-      z: 3
-    } as SeriesOption)
-  }
-  if (nearX !== null) {
-    series.push({
-      type: 'line',
-      name: labels.lowerBound,
-      data: [
-        [0, z],
-        [nearX, 0]
-      ],
-      showSymbol: false,
-      lineStyle: { color: pal.accent, type: 'dashed', opacity: 0.6, width: 1.2 },
-      silent: true,
-      z: 3
-    } as SeriesOption)
-  }
-
-  // 声学中轴(橙色实线)
-  series.push({
-    type: 'line',
-    name: labels.acousticAxis,
-    data: [
-      [0, z],
-      [Math.min(maxD, d3), 0]
-    ],
-    showSymbol: false,
-    lineStyle: { color: pal.accent, type: 'dashed', width: 2 },
-    silent: true,
-    z: 3,
-    tooltip: { show: false }
-  } as SeriesOption)
-
-  // 垂直高度 Z 虚线
-  series.push({
-    type: 'line',
-    name: labels.height,
-    data: [
-      [0, z],
-      [0, 0]
-    ],
-    showSymbol: false,
-    lineStyle: { color: pal.dim, type: 'dashed', opacity: 0.5 },
-    silent: true,
-    z: 1,
-    tooltip: { show: false }
-  } as SeriesOption)
-
-  // 扬声器(SPK 矩形标记)
-  series.push({
-    type: 'scatter',
-    name: 'SPK',
-    data: [{ value: [0, z], name: 'SPK' }],
-    symbol: 'rect',
-    symbolSize: [26, 20],
-    itemStyle: { color: pal.accent, borderColor: '#ffffff', borderWidth: 1 },
-    label: { show: true, formatter: 'SPK', color: '#fff', fontSize: 10, fontWeight: 'bold' },
-    z: 5
-  } as SeriesOption)
-
-  // 听音点 D1 / D2 / D3
-  const pts = [
-    { d: d1, lbl: 'D1', c: pal.cyan },
-    { d: d2, lbl: 'D2', c: pal.cyan },
-    { d: d3, lbl: 'D3', c: pal.accent }
-  ]
-  pts.forEach((pt) => {
-    series.push({
-      type: 'scatter',
-      name: pt.lbl,
-      data: [{ value: [pt.d, 0, splAt(pt.d, p).toFixed(1)], name: pt.lbl }],
-      symbolSize: 9,
-      itemStyle: { color: pt.c, borderColor: pal.bg, borderWidth: 1.5 },
-      label: {
-        show: true,
-        position: 'right',
-        formatter: (params: DefaultLabelFormatterCallbackParams) => {
-          const v = (params.data as { value: [number, number, string] }).value
-          return `${v[2]} dB\n${(params.data as { name: string }).name} = ${v[0].toFixed(1)}m`
-        },
-        color: pal.text,
-        fontSize: 10.5,
-        lineHeight: 15
-      },
-      z: 4
-    } as SeriesOption)
-  })
-
-  // —— 覆盖角弧线(V 扇形弧)+ 角度标签 ——
-  if (dFar > 0.01) {
-    const arcR = Math.min(0.09 * maxD, 2.5)
-    const arcSteps = 24
-    const arcData: [number, number][] = []
-    for (let i = 0; i <= arcSteps; i++) {
-      const a = lowerAngle + ((upperAngle - lowerAngle) * i) / arcSteps
-      arcData.push([Math.cos(a) * arcR, z - Math.sin(a) * arcR])
-    }
-    series.push({
-      type: 'line',
-      name: labels.coverage,
-      data: arcData,
-      showSymbol: false,
-      lineStyle: { color: '#ffd54f', width: 1.6, opacity: 1 },
-      silent: true,
-      z: 4
-    } as SeriesOption)
-    const midA = (lowerAngle + upperAngle) / 2
-    const lblR = arcR + 0.055 * maxD
-    series.push({
-      type: 'scatter',
-      data: [{ value: [Math.cos(midA) * lblR, z - Math.sin(midA) * lblR] }],
-      symbolSize: 0,
-      label: {
-        show: true,
-        formatter: `${cov.toFixed(0)}°`,
-        color: '#ffd54f',
-        fontSize: 14,
-        fontWeight: 700
-      },
-      silent: true,
-      z: 4
-    } as SeriesOption)
-  }
-
-  // —— 安装倾斜角 A 弧线 + 标签 ——
-  if (angle > 0.01) {
-    const ar2 = Math.min(0.05 * maxD, 1.8)
-    const aSteps = 16
-    const aArcData: [number, number][] = []
-    for (let i = 0; i <= aSteps; i++) {
-      const a = (aRad * i) / aSteps
-      aArcData.push([Math.cos(a) * ar2, z - Math.sin(a) * ar2])
-    }
-    series.push({
-      type: 'line',
-      name: '安装倾斜角 A',
-      data: aArcData,
-      showSymbol: false,
-      lineStyle: { color: pal.text, width: 1, opacity: 0.85 },
-      silent: true,
-      z: 4,
-      tooltip: { show: false }
-    } as SeriesOption)
-    const aLblR = ar2 + 0.02 * maxD
-    series.push({
-      type: 'scatter',
-      data: [{ value: [Math.cos(aRad) * aLblR, z - Math.sin(aRad) * aLblR] }],
-      symbolSize: 0,
-      label: {
-        show: true,
-        formatter: `A= ${angle.toFixed(1)}°`,
-        color: pal.text,
-        fontSize: 12,
-        padding: [0, 0],
-        borderRadius: 3,
-        borderWidth: 1
-      },
-      silent: true,
-      z: 10
-    } as SeriesOption)
-  }
-
-  return {
-    animation: false,
-    backgroundColor: pal.bg,
-    grid: { left: 60, right: 36, top: 40, bottom: 52 },
-    title: {
-      left: 6,
-      top: 6,
-      text: `${labels.vertical} V = ${cov.toFixed(0)}° · θ₋₆ = ${t6.toFixed(0)}°`,
-      textStyle: { color: pal.dim, fontSize: 11, fontWeight: 'normal' }
-    },
-    xAxis: {
-      type: 'value',
-      min: 0,
-      max: maxD,
-      name: labels.horizontalDistance,
-      nameLocation: 'middle',
-      nameGap: 32,
-      nameTextStyle: { color: pal.dim, fontSize: 11 },
-      axisLine: { lineStyle: { color: pal.dim } },
-      axisLabel: { color: pal.dim, fontSize: 10, formatter: (v: number) => fmtN(v) },
-      splitLine: { show: false }
-    },
-    yAxis: {
-      type: 'value',
-      min: 0,
-      max: maxZ,
-      name: labels.height,
-      nameLocation: 'middle',
-      nameGap: 48,
-      nameTextStyle: { color: pal.dim, fontSize: 11 },
-      axisLine: { lineStyle: { color: pal.dim } },
-      axisLabel: { color: pal.dim, fontSize: 10, formatter: (v: number) => fmtN(v) },
-      splitLine: { lineStyle: { color: pal.border, type: 'dashed' } }
-    },
-    series
-  }
-}

+ 0 - 24
src/renderer/src/lib/speaker/echarts/index.ts

@@ -1,24 +0,0 @@
-/** ECharts 图表模块汇总导出 */
-import type { EChartsOption } from 'echarts'
-import type { ChartPalette } from './palette'
-
-export * from './palette'
-export * from './diagramOption'
-export * from './splChartOption'
-export * from './topDiagramOption'
-
-/** 空状态图表(居中提示文案) */
-export function buildChartEmptyOption(text: string, pal: ChartPalette): EChartsOption {
-  return {
-    animation: false,
-    backgroundColor: pal.bg,
-    title: {
-      text,
-      left: 'center',
-      top: 'middle',
-      textStyle: { color: pal.dim, fontSize: 14, fontWeight: 'normal' }
-    },
-    xAxis: { show: false },
-    yAxis: { show: false }
-  }
-}

+ 0 - 16
src/renderer/src/lib/speaker/echarts/install.ts

@@ -1,16 +0,0 @@
-/** ECharts 按需注册:只打包用到的图表与组件,大幅减小包体积 */
-import * as echarts from 'echarts/core'
-import { LineChart, ScatterChart } from 'echarts/charts'
-import { GridComponent, TooltipComponent, TitleComponent } from 'echarts/components'
-import { CanvasRenderer } from 'echarts/renderers'
-
-echarts.use([
-  LineChart,
-  ScatterChart,
-  GridComponent,
-  TooltipComponent,
-  TitleComponent,
-  CanvasRenderer
-])
-
-export { echarts }

+ 0 - 126
src/renderer/src/lib/speaker/echarts/splChartOption.ts

@@ -1,126 +0,0 @@
-/**
- * SPL 随距离曲线图 ECharts option 工厂
- * 曲线跟随 H/V 开关(dir 决定指向性模型),展示水平/垂直两种策略下的声压级分布
- */
-import type { DefaultLabelFormatterCallbackParams, EChartsOption, SeriesOption } from 'echarts'
-import type { CalcResult, SpeakerParams } from '../types'
-import { sampleSpl, splAt } from '../calc'
-import type { ChartPalette } from './palette'
-import { fmtN } from './utils'
-
-export interface SplChartLabels {
-  empty: string
-  distance: string
-  spl: string
-  title: string
-}
-
-export function buildSplChartOption(
-  p: SpeakerParams,
-  r: CalcResult,
-  labels: SplChartLabels,
-  pal: ChartPalette,
-  numPoints = 10
-): EChartsOption {
-  const { d1, d2, d3 } = p
-  const { s1, s2, s3 } = r
-
-  const points = sampleSpl(p, numPoints)
-  const splValues = points.map((pt) => pt.spl)
-  const minSPL = Math.min(...splValues) - 1
-  const maxSPL = Math.max(...splValues) + 1
-
-  const series: SeriesOption[] = []
-
-  // SPL 曲线
-  series.push({
-    name: labels.title,
-    type: 'line',
-    data: points.map((pt) => [pt.d, pt.spl]),
-    showSymbol: false,
-    lineStyle: { color: pal.accent, width: 2.5 },
-    tooltip: { trigger: 'item' },
-    z: 2
-  } as SeriesOption)
-
-  // 关键点:SPK / D1 / D3 / D2
-  const keyPoints = [
-    { d: 0, spl: splAt(0, p), lbl: 'SPK', c: pal.cyan },
-    { d: d1, spl: s1, lbl: 'D1', c: pal.cyan },
-    { d: d3, spl: s3, lbl: 'D3', c: pal.accent },
-    { d: d2, spl: s2, lbl: 'D2', c: pal.cyan }
-  ]
-  keyPoints.forEach((pt) => {
-    if (pt.d >= 0 && pt.d <= d2) {
-      series.push({
-        type: 'scatter',
-        name: pt.lbl,
-        data: [{ value: [pt.d, pt.spl, pt.spl.toFixed(1)], name: pt.lbl }],
-        symbolSize: 10,
-        itemStyle: { color: pt.c, borderColor: pal.bg, borderWidth: 2 },
-        label: {
-          show: true,
-          position: 'top',
-          formatter: (params: DefaultLabelFormatterCallbackParams) => {
-            const v = (params.data as { value: [number, number, string] }).value
-            return `${(params.data as { name: string }).name} · ${v[2]} dB`
-          },
-          color: pal.text,
-          fontSize: 10
-        },
-        z: 3
-      } as SeriesOption)
-    }
-  })
-
-  return {
-    animation: false,
-    backgroundColor: pal.bg,
-    grid: { left: 62, right: 36, top: 40, bottom: 50 },
-    title: {
-      left: 'center',
-      top: 8,
-      text: labels.title,
-      textStyle: { color: pal.text, fontSize: 12, fontWeight: 600 }
-    },
-    tooltip: {
-      trigger: 'axis',
-      confine: true,
-      formatter: (params: unknown) => {
-        const list = params as Array<{
-          axisValue: number
-          data: { value: [number, number] } | [number, number]
-        }>
-        const p0 = list[0]
-        if (!p0) return ''
-        const v = Array.isArray(p0.data) ? p0.data : p0.data.value
-        return `${fmtN(v[0])} m · ${v[1].toFixed(1)} dB SPL`
-      }
-    },
-    xAxis: {
-      type: 'value',
-      min: 0,
-      max: d2,
-      name: labels.distance,
-      nameLocation: 'middle',
-      nameGap: 32,
-      nameTextStyle: { color: pal.dim, fontSize: 11 },
-      axisLine: { lineStyle: { color: pal.dim } },
-      axisLabel: { color: pal.dim, fontSize: 10, formatter: (v: number) => fmtN(v) },
-      splitLine: { show: false }
-    },
-    yAxis: {
-      type: 'value',
-      min: minSPL,
-      max: maxSPL,
-      name: labels.spl,
-      nameLocation: 'middle',
-      nameGap: 48,
-      nameTextStyle: { color: pal.dim, fontSize: 11 },
-      axisLine: { lineStyle: { color: pal.dim } },
-      axisLabel: { color: pal.dim, fontSize: 10, formatter: (v: number) => fmtN(v) },
-      splitLine: { lineStyle: { color: pal.border, type: 'dashed' } }
-    },
-    series
-  }
-}

+ 0 - 278
src/renderer/src/lib/speaker/echarts/topDiagramOption.ts

@@ -1,278 +0,0 @@
-/**
- * 覆盖示意图(俯视图)ECharts option 工厂
- *
- * 说明:俯视图是水平平面图,覆盖扇形使用水平指向角 H。
- * - X/Y 轴采用相同数据范围([-maxD, maxD]),确保等比例,圆弧不变形
- * - 支持 0~360° 任意覆盖角(hCov > 180° 时为大扇形,绕过设备后方)
- * - 覆盖区域按声压级(SPL)分层渐变填充,SPL 越高颜色越深,越低越浅
- *   颜色从深橙色(高SPL)渐变到浅橙色(低SPL),色相和明度双重变化
- * - D1/D2/D3 以设备为圆心,画同心圆弧参考线
- */
-import type { DefaultLabelFormatterCallbackParams, EChartsOption, SeriesOption } from 'echarts'
-import type { SpeakerParams } from '../types'
-import { DEG, splAt } from '../calc'
-import type { ChartPalette } from './palette'
-import { fmtN } from './utils'
-
-export interface TopDiagramChartLabels {
-  empty: string
-  forwardDistance: string
-  lateralDistance: string
-  leftBound: string
-  rightBound: string
-  acousticAxis: string
-  coverage: string
-  horizontal: string
-}
-
-function ringPolygon(
-  cx: number,
-  cy: number,
-  rInner: number,
-  rOuter: number,
-  startAngle: number,
-  endAngle: number,
-  steps = 40
-): [number, number][] {
-  const pts: [number, number][] = []
-  for (let i = 0; i <= steps; i++) {
-    const a = startAngle + ((endAngle - startAngle) * i) / steps
-    pts.push([cx + Math.cos(a) * rOuter, cy + Math.sin(a) * rOuter])
-  }
-  for (let i = steps; i >= 0; i--) {
-    const a = startAngle + ((endAngle - startAngle) * i) / steps
-    pts.push([cx + Math.cos(a) * rInner, cy + Math.sin(a) * rInner])
-  }
-  pts.push(pts[0])
-
-  return pts
-}
-
-function arcPoints(
-  cx: number,
-  cy: number,
-  r: number,
-  startAngle: number,
-  endAngle: number,
-  steps = 40
-): [number, number][] {
-  const pts: [number, number][] = []
-  for (let i = 0; i <= steps; i++) {
-    const a = startAngle + ((endAngle - startAngle) * i) / steps
-    pts.push([cx + Math.cos(a) * r, cy + Math.sin(a) * r])
-  }
-  return pts
-}
-
-function parseHex(color: string): [number, number, number] {
-  const c = color.startsWith('#') ? color.slice(1) : color
-  if (c.length === 3) {
-    return [parseInt(c[0] + c[0], 16), parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16)]
-  }
-  return [
-    parseInt(c.substring(0, 2), 16),
-    parseInt(c.substring(2, 4), 16),
-    parseInt(c.substring(4, 6), 16)
-  ]
-}
-
-export function buildTopDiagramOption(
-  p: SpeakerParams,
-  labels: TopDiagramChartLabels,
-  pal: ChartPalette
-): EChartsOption {
-  const { splMax, d1, d2, d3, covAngle } = p
-
-  const cov = covAngle
-  const t6 = cov / 2
-  const t6Rad = t6 * DEG
-
-  const maxD = Math.max(d1, d2, d3, 5) * 1.13
-
-  const axisMin = -maxD
-  const axisMax = maxD
-
-  const series: SeriesOption[] = []
-
-  // ------------------------------------------------------------------
-  // 1. 覆盖区域按声压级(SPL)分层渐变填充
-  //    SPL 越高颜色越深;SPL 越低颜色越浅
-  //    颜色从深橙色渐变到浅橙色,色相和明度双重变化
-  // ------------------------------------------------------------------
-  const fullCircle = cov >= 360
-  const startAngle = fullCircle ? 0 : -t6Rad
-  const endAngle = fullCircle ? 2 * Math.PI : t6Rad
-
-  const layers = 32
-  const maxAlpha = 0.9
-  const minAlpha = 0.08
-
-  // 解析主题强调色的 RGB(palette 已按浅/深主题给好颜色,这里只取色相)
-  const [br, bg, bb] = parseHex(pal.accent)
-
-  const splAtMaxD = splAt(maxD, p)
-  const splRange = Math.max(splMax - splAtMaxD, 1)
-
-  for (let i = 0; i < layers; i++) {
-    const rInner = (maxD * i) / layers
-    const rOuter = (maxD * (i + 1)) / layers
-    const rMid = (rInner + rOuter) / 2
-
-    if (rOuter <= 0.01) continue
-
-    const spl = splAt(rMid, p)
-    const splRatio = Math.max(0, Math.min(1, (spl - splAtMaxD) / splRange))
-
-    const alpha = minAlpha + splRatio * (maxAlpha - minAlpha)
-    const color = `rgba(${br}, ${bg}, ${bb}, ${alpha.toFixed(3)})`
-
-    series.push({
-      type: 'line',
-      name: labels.coverage,
-      data: ringPolygon(0, 0, rInner, rOuter, startAngle, endAngle, 48),
-      showSymbol: false,
-      lineStyle: { opacity: 0 },
-      areaStyle: { color }, // ← 只给 color,不要再设 opacity
-      silent: true,
-      z: 2
-    } as SeriesOption)
-  }
-
-  // ------------------------------------------------------------------
-  // 2. 左右 -6dB 边界虚线(从圆心出发,用 sin/cos 计算端点,支持大角度)
-  // ------------------------------------------------------------------
-  if (!fullCircle) {
-    const farRight = [maxD * Math.cos(t6Rad), maxD * Math.sin(t6Rad)]
-    const farLeft = [maxD * Math.cos(-t6Rad), maxD * Math.sin(-t6Rad)]
-
-    series.push({
-      type: 'line',
-      name: labels.rightBound,
-      data: [[0, 0], farRight],
-      showSymbol: false,
-      lineStyle: { color: pal.accent, type: 'dashed', opacity: 0.6, width: 1.2 },
-      silent: true,
-      z: 3
-    } as SeriesOption)
-
-    series.push({
-      type: 'line',
-      name: labels.leftBound,
-      data: [[0, 0], farLeft],
-      showSymbol: false,
-      lineStyle: { color: pal.accent, type: 'dashed', opacity: 0.6, width: 1.2 },
-      silent: true,
-      z: 3
-    } as SeriesOption)
-  }
-
-  // ------------------------------------------------------------------
-  // 3. D1/D2/D3 同心圆弧参考线(以设备为圆心,仅在覆盖角范围内绘制)
-  // ------------------------------------------------------------------
-  const ringDefs = [
-    { r: d1, lbl: 'D1' },
-    { r: d2, lbl: 'D2' },
-    { r: d3, lbl: 'D3' }
-  ]
-  ringDefs.forEach((def) => {
-    if (def.r > 0 && def.r <= maxD) {
-      series.push({
-        type: 'line',
-        name: def.lbl,
-        data: arcPoints(0, 0, def.r, startAngle, endAngle, 36),
-        showSymbol: false,
-        lineStyle: { color: pal.text, type: 'dashed', width: 1, opacity: 0.35 },
-        silent: true,
-        z: 1,
-        tooltip: { show: false }
-      } as SeriesOption)
-    }
-  })
-
-  // ------------------------------------------------------------------
-  // 4. 声学中轴线(X 轴正方向,从圆心到 maxD)
-  // ------------------------------------------------------------------
-  series.push({
-    type: 'line',
-    name: labels.acousticAxis,
-    data: [
-      [0, 0],
-      [maxD, 0]
-    ],
-    showSymbol: false,
-    lineStyle: { color: pal.accent, type: 'solid', width: 2 },
-    silent: true,
-    z: 3
-  } as SeriesOption)
-
-  // ------------------------------------------------------------------
-  // 5. D1/D2/D3 点标记(在声轴上,即各圆弧与 X 正轴的交点)
-  // ------------------------------------------------------------------
-  const keyPoints = [
-    { d: d1, lbl: 'D1' },
-    { d: d2, lbl: 'D2' },
-    { d: d3, lbl: 'D3' }
-  ]
-  keyPoints
-    .sort((a, b) => a.d - b.d)
-    .forEach((pt, index) => {
-      if (pt.d >= 0 && pt.d <= maxD) {
-        series.push({
-          type: 'scatter',
-          name: pt.lbl,
-          // data: [{ value: [pt.d, 0], name: pt.lbl }],
-          data: [{ value: [pt.d, 0, splAt(pt.d, p).toFixed(1)], name: pt.lbl }],
-          symbolSize: 8,
-          itemStyle: { color: pal.accent, borderColor: pal.bg, borderWidth: 2 },
-          label: {
-            show: true,
-            position: (index + 2) % 2 === 0 ? 'top' : 'bottom',
-            color: pal.text,
-            formatter: (params: DefaultLabelFormatterCallbackParams) => {
-              const v = (params.data as { value: [number, number, string] }).value
-              return `${v[2]} dB\n${(params.data as { name: string }).name} = ${v[0].toFixed(1)}m`
-            },
-            fontSize: 10
-          },
-          z: 4
-        } as SeriesOption)
-      }
-    })
-  return {
-    animation: false,
-    backgroundColor: pal.bg,
-    grid: { left: 60, right: 10, top: 10, bottom: 20 },
-    title: {
-      right: 6,
-      top: 0,
-      text: `${labels.horizontal} H = ${cov.toFixed(0)}° · θ₋₆ = ${t6.toFixed(0)}°`,
-      textStyle: { color: pal.dim, fontSize: 11, fontWeight: 'normal' }
-    },
-    xAxis: {
-      type: 'value',
-      min: axisMin,
-      max: axisMax,
-      name: labels.forwardDistance,
-      nameLocation: 'end',
-      nameGap: 16,
-      nameRotate: 90,
-      nameTextStyle: { color: pal.dim, fontSize: 11 },
-      axisLine: { lineStyle: { color: pal.dim } },
-      axisLabel: { color: pal.dim, fontSize: 10, formatter: (v: number) => fmtN(Math.abs(v)) },
-      splitLine: { lineStyle: { color: pal.border, type: 'dashed' } }
-    },
-    yAxis: {
-      type: 'value',
-      min: axisMin,
-      max: axisMax,
-      name: labels.lateralDistance,
-      nameLocation: 'middle',
-      nameGap: 0,
-      nameTextStyle: { color: pal.dim, fontSize: 11 },
-      axisLine: { lineStyle: { color: pal.dim } },
-      axisLabel: { color: pal.dim, fontSize: 10, formatter: (v: number) => fmtN(Math.abs(v)) },
-      splitLine: { lineStyle: { color: pal.border, type: 'dashed' } }
-    },
-    series
-  }
-}

+ 0 - 14
src/renderer/src/lib/speaker/echarts/utils.ts

@@ -1,14 +0,0 @@
-/** 计算"美观"的网格间隔(1/2/5 × 10ⁿ) */
-export function nice(rough: number): number {
-  const p = Math.pow(10, Math.floor(Math.log10(Math.max(rough, 1e-9))))
-  const n = rough / p
-  if (n <= 1) return p
-  if (n <= 2) return 2 * p
-  if (n <= 5) return 5 * p
-  return 10 * p
-}
-
-/** 数值格式化:>=10 取整,否则保留 1 位小数 */
-export function fmtN(v: number): string {
-  return v >= 10 ? v.toFixed(0) : v.toFixed(1)
-}

+ 406 - 0
src/renderer/src/lib/speaker/jsxgraph/diagram.ts

@@ -0,0 +1,406 @@
+import type { Board } from 'jsxgraph'
+import type { SpeakerParams, CalcResult } from '../types'
+import type { ChartPalette } from './palette'
+import { DEG, splAt } from '../calc'
+
+export interface DiagramChartLabels {
+  empty: string
+  horizontalDistance: string
+  height: string
+  upperBound: string
+  lowerBound: string
+  acousticAxis: string
+  coverage: string
+  vertical: string
+}
+
+let currentObjects: any[] = []
+
+function nice(rough: number) {
+  const p = Math.pow(10, Math.floor(Math.log10(Math.max(rough, 1e-9))))
+  const n = rough / p
+  if (n <= 1) return p
+  if (n <= 2) return 2 * p
+  if (n <= 5) return 5 * p
+  return 10 * p
+}
+
+function drawEmpty(board: Board, text: string, pal: ChartPalette): void {
+  board.suspendUpdate()
+  try {
+    if (currentObjects.length > 0) {
+      board.removeObject(currentObjects)
+      currentObjects = []
+    }
+    const t = board.create('text', [0, 0, text], {
+      fontSize: 14,
+      color: pal.dim,
+      anchorX: 'center',
+      anchorY: 'middle',
+      fixed: true
+    })
+    currentObjects.push(t)
+  } finally {
+    board.unsuspendUpdate()
+  }
+}
+
+export function drawDiagram(
+  board: Board,
+  p: SpeakerParams & { maxD?: number; maxZ?: number },
+  result: CalcResult | null,
+  labels: DiagramChartLabels,
+  pal: ChartPalette
+): void {
+  const { z, d1, d2, d3, angle, vCov } = p
+  const cov = vCov
+  const t6 = cov / 2
+
+  const maxD = p.maxD || Math.max(d1, d2, d3, 5) * 1.13
+  const maxZ = p.maxZ || Math.max(z * 1.15, 3.5)
+
+  if (!result) {
+    drawEmpty(board, labels.empty, pal)
+    return
+  }
+
+  const aRad = angle * DEG
+  const t6Rad = t6 * DEG
+  const upperAngle = aRad + t6Rad
+  const lowerAngle = aRad - t6Rad
+
+  const dFar = upperAngle < Math.PI / 2 - 0.01 ? z / Math.tan(upperAngle) : maxD * 3
+  const dNear = lowerAngle > 0.01 ? z / Math.tan(lowerAngle) : -1
+
+  const nearX = dNear >= 0 ? Math.min(maxD, Math.max(0, dNear)) : null
+  const farX = dFar > 0 ? Math.min(maxD, dFar) : null
+
+  board.suspendUpdate()
+  try {
+    if (currentObjects.length > 0) {
+      board.removeObject(currentObjects)
+      currentObjects = []
+    }
+
+    const addObj = (type: string, args: any[], attrs: any = {}) => {
+      if (type === 'point') attrs.withLabel = false
+      const obj = board.create(type as any, args, attrs)
+      currentObjects.push(obj)
+      return obj
+    }
+
+    const pt = (x: number, y: number) => addObj('point', [x, y], { visible: false, fixed: true })
+
+    // ================= 一、网格和坐标轴 =================
+    const gD = nice(maxD / 6)
+    const gZ = nice(maxZ / 5)
+
+    for (let d = gD; d < maxD; d += gD) {
+      addObj(
+        'segment',
+        [
+          [d, 0],
+          [d, maxZ]
+        ],
+        { strokeColor: pal.border, strokeWidth: 1, dash: 2, strokeOpacity: 0.5, layer: 0 }
+      )
+    }
+    for (let h = gZ; h < maxZ; h += gZ) {
+      addObj(
+        'segment',
+        [
+          [0, h],
+          [maxD, h]
+        ],
+        { strokeColor: pal.border, strokeWidth: 1, dash: 2, strokeOpacity: 0.5, layer: 0 }
+      )
+    }
+
+    addObj(
+      'segment',
+      [
+        [0, 0],
+        [0, maxZ]
+      ],
+      { strokeColor: pal.dim, strokeWidth: 1.5, lastArrow: true, layer: 1 }
+    )
+    addObj(
+      'segment',
+      [
+        [0, 0],
+        [maxD, 0]
+      ],
+      { strokeColor: pal.dim, strokeWidth: 1.5, lastArrow: true, layer: 1 }
+    )
+
+    // X 轴刻度和数字
+    for (let d = gD; d < maxD; d += gD) {
+      addObj(
+        'segment',
+        [
+          [d, 0],
+          [d, -maxZ * 0.015]
+        ],
+        { strokeColor: pal.dim, strokeWidth: 1, layer: 1 }
+      )
+      addObj('text', [d, -maxZ * 0.03, d.toFixed(0)], {
+        fontSize: 9,
+        color: pal.dim,
+        anchorX: 'center',
+        anchorY: 'top',
+        layer: 1
+      })
+    }
+
+    // Y 轴刻度和数字
+    for (let h = gZ; h < maxZ; h += gZ) {
+      addObj(
+        'segment',
+        [
+          [0, h],
+          [-maxD * 0.015, h]
+        ],
+        { strokeColor: pal.dim, strokeWidth: 1, layer: 1 }
+      )
+      addObj('text', [-maxD * 0.025, h, h.toFixed(1)], {
+        fontSize: 9,
+        color: pal.dim,
+        anchorX: 'right',
+        anchorY: 'middle',
+        layer: 1
+      })
+    }
+
+    // 轴名称:精确防裁切
+    addObj('text', [maxD, -maxZ * 0.05, labels.horizontalDistance], {
+      fontSize: 10,
+      color: pal.dim,
+      anchorX: 'right',
+      anchorY: 'top',
+      layer: 1
+    })
+    addObj('text', [0, maxZ + maxZ * 0.02, labels.height], {
+      fontSize: 10,
+      color: pal.dim,
+      anchorX: 'middle',
+      anchorY: 'bottom',
+      layer: 1
+    })
+
+    // ================= 二、覆盖区域和声学线 =================
+    if (nearX !== null && farX !== null) {
+      const leftX = Math.min(nearX, farX)
+      const rightX = Math.max(nearX, farX)
+      addObj('polygon', [pt(0, z), pt(leftX, 0), pt(rightX, 0)], {
+        fillColor: pal.accent,
+        fillOpacity: 0.1,
+        strokeColor: 'none',
+        layer: 2
+      })
+    }
+
+    if (nearX !== null && farX !== null && farX > nearX) {
+      addObj(
+        'segment',
+        [
+          [nearX, 0],
+          [farX, 0]
+        ],
+        { strokeColor: pal.accent, strokeWidth: 4, strokeOpacity: 0.35, layer: 2 }
+      )
+    }
+
+    if (farX !== null) {
+      addObj(
+        'segment',
+        [
+          [0, z],
+          [farX, 0]
+        ],
+        { strokeColor: pal.accent, strokeWidth: 1.2, dash: 2, strokeOpacity: 0.6, layer: 3 }
+      )
+    }
+    if (nearX !== null) {
+      addObj(
+        'segment',
+        [
+          [0, z],
+          [nearX, 0]
+        ],
+        { strokeColor: pal.accent, strokeWidth: 1.2, dash: 2, strokeOpacity: 0.6, layer: 3 }
+      )
+    }
+
+    const d3Clamped = Math.min(maxD, d3)
+    addObj(
+      'segment',
+      [
+        [0, z],
+        [d3Clamped, 0]
+      ],
+      { strokeColor: pal.accent, strokeWidth: 1.5, dash: 2, layer: 3 }
+    )
+
+    // ================= 三、点与标签(防重叠、防溢出、强制拆行) =================
+    addObj('point', [0, z], {
+      face: '[]',
+      size: 6,
+      fillColor: pal.accent,
+      strokeColor: '#ffffff',
+      strokeWidth: 1,
+      layer: 5
+    })
+    addObj('text', [maxD * 0.02, z, 'SPK'], {
+      fontSize: 10,
+      color: pal.accent,
+      anchorX: 'left',
+      anchorY: 'bottom',
+      layer: 5
+    })
+
+    const pts = [
+      { d: d1, lbl: 'D1', c: pal.cyan },
+      { d: d2, lbl: 'D2', c: pal.cyan },
+      { d: d3, lbl: 'D3', c: pal.accent }
+    ]
+
+    const sortedPts = [...pts].sort((a, b) => a.d - b.d)
+    const textBaseY = maxZ * 0.03
+
+    let lastX = -999
+    let lastTier = -1
+    let currentTier = 0
+
+    sortedPts.forEach((ptDef) => {
+      const x = ptDef.d
+      const spl = splAt(x, p)
+
+      addObj('point', [x, 0], {
+        size: 4,
+        fillColor: ptDef.c,
+        strokeColor: pal.bg,
+        strokeWidth: 1,
+        layer: 4
+      })
+
+      const labelWidth = maxD * 0.15
+
+      if (lastTier === -1) {
+        currentTier = 0
+      } else if (x - lastX < labelWidth) {
+        currentTier = lastTier + 1
+        if (currentTier > 2) currentTier = 0
+      } else {
+        currentTier = 0
+      }
+
+      lastX = x
+      lastTier = currentTier
+
+      const textY = textBaseY + currentTier * (maxZ * 0.08)
+
+      // 靠右边界时,文字自动向左对齐防止切出屏幕
+      const isNearRightEdge = x > maxD * 0.85
+      const anchorX = isNearRightEdge ? 'right' : 'center'
+
+      // 强制拆成两个文本对象画,避免 \n 在某些环境下失效变成一行超长文本
+      addObj('text', [x, textY, `${ptDef.lbl} = ${x.toFixed(1)}m`], {
+        fontSize: 10,
+        color: ptDef.c,
+        anchorX: anchorX,
+        anchorY: 'bottom',
+        layer: 4
+      })
+      addObj('text', [x, textY + maxZ * 0.1, `${spl.toFixed(1)} dB`], {
+        fontSize: 10,
+        color: ptDef.c,
+        anchorX: anchorX,
+        anchorY: 'top',
+        layer: 4
+      })
+    })
+
+    // ================= 四、弧线与角度 =================
+
+    // 1. 水平向右的基准虚线,标定 A 角的参考系
+    const baseRefLineLength = maxD * 0.18
+    addObj(
+      'segment',
+      [
+        [0, z],
+        [baseRefLineLength, z]
+      ],
+      {
+        strokeColor: pal.dim,
+        strokeWidth: 1,
+        dash: 2,
+        strokeOpacity: 0.8,
+        layer: 3
+      }
+    )
+
+    // 2. 覆盖角 V 的圆弧(外圈)
+    if (dFar > 0.01) {
+      // 半径与 maxZ 挂钩,确保在不同拉伸比例下都足够清晰
+      const vRadius = maxZ * 0.3
+      addObj(
+        'curve',
+        [
+          (t: number) => Math.cos(t) * vRadius,
+          (t: number) => z - Math.sin(t) * vRadius,
+          lowerAngle, // 起始角(独立参数)
+          upperAngle // 终止角(独立参数)
+        ],
+        { strokeColor: '#eab308', strokeWidth: 2.5, layer: 4 } // 加粗让它更显眼
+      )
+
+      // V 标签放在外圈
+      const midA = (lowerAngle + upperAngle) / 2
+      const vLblR = vRadius + maxZ * 0.05
+      addObj(
+        'text',
+        [Math.cos(midA) * vLblR, z - Math.sin(midA) * vLblR, `V = ${cov.toFixed(0)}°`],
+        {
+          fontSize: 11,
+          color: '#ca8a04',
+          anchorX: 'left',
+          anchorY: 'middle',
+          layer: 4
+        }
+      )
+    }
+
+    // 3. 安装倾斜角 A 的圆弧(内圈)
+    if (angle > 0.01) {
+      const aRadius = maxZ * 0.16 // 内圈半径
+      addObj(
+        'curve',
+        [
+          (t: number) => Math.cos(t) * aRadius,
+          (t: number) => z - Math.sin(t) * aRadius,
+          0, // 起始角(独立参数)
+          aRad // 终止角(独立参数)
+        ],
+        { strokeColor: pal.text, strokeWidth: 1.5, strokeOpacity: 0.9, layer: 4 }
+      )
+
+      // A 标签放在内圈
+      const midA = aRad / 2
+      const aLblR = aRadius + maxZ * 0.04
+      addObj(
+        'text',
+        [Math.cos(midA) * aLblR, z - Math.sin(midA) * aLblR, `A = ${angle.toFixed(1)}°`],
+        {
+          fontSize: 11,
+          color: pal.text,
+          anchorX: 'left',
+          anchorY: 'bottom',
+          layer: 10
+        }
+      )
+    }
+  } finally {
+    board.unsuspendUpdate()
+    board.update()
+  }
+}

+ 5 - 0
src/renderer/src/lib/speaker/jsxgraph/index.ts

@@ -0,0 +1,5 @@
+/** jsxgraph 图表模块汇总导出 */
+export type { ChartPalette } from './palette'
+export { paletteFromThemeVars } from './palette'
+export * from './diagram'
+export * from './topDiagram'

+ 9 - 0
src/renderer/src/lib/speaker/jsxgraph/install.ts

@@ -0,0 +1,9 @@
+/** jsxgraph 初始化与按需导出
+ *
+ * 对齐现有 echarts/install.ts 的按需注册风格,只导出 Board 类型与 JSXGraph
+ * 入口(用于 initBoard 创建画布),避免在组件层直接依赖 jsxgraph 全局。
+ */
+import type { Board } from 'jsxgraph'
+
+export type { Board }
+export { JSXGraph } from 'jsxgraph'

+ 0 - 0
src/renderer/src/lib/speaker/echarts/palette.ts → src/renderer/src/lib/speaker/jsxgraph/palette.ts


+ 263 - 0
src/renderer/src/lib/speaker/jsxgraph/splDiagram.ts

@@ -0,0 +1,263 @@
+import type { Board } from 'jsxgraph'
+import type { CalcResult, SpeakerParams } from '../types'
+import type { ChartPalette } from './palette'
+import { sampleSpl, splAt } from '../calc'
+
+export interface SplDiagramChartLabels {
+  empty: string
+  distance: string
+  spl: string
+  title: string
+}
+
+let currentObjects: any[] = []
+
+function nice(rough: number) {
+  const p = Math.pow(10, Math.floor(Math.log10(Math.max(rough, 1e-9))))
+  const n = rough / p
+  if (n <= 1) return p
+  if (n <= 2) return 2 * p
+  if (n <= 5) return 5 * p
+  return 10 * p
+}
+
+function drawEmpty(board: Board, text: string, pal: ChartPalette): void {
+  board.suspendUpdate()
+  try {
+    if (currentObjects.length > 0) {
+      board.removeObject(currentObjects)
+      currentObjects = []
+    }
+    // 设置一个固定的空状态视口
+    board.setBoundingBox([-10, 10, 10, -10], false)
+    const t = board.create('text', [0, 0, text], {
+      fontSize: 14,
+      color: pal.dim,
+      anchorX: 'center',
+      anchorY: 'middle',
+      fixed: true
+    })
+    currentObjects.push(t)
+  } finally {
+    board.unsuspendUpdate()
+  }
+}
+
+export function drawSplDiagram(
+  board: Board,
+  p: SpeakerParams,
+  r: CalcResult | null,
+  labels: SplDiagramChartLabels,
+  pal: ChartPalette
+): void {
+  if (!r) {
+    drawEmpty(board, labels.empty, pal)
+    return
+  }
+
+  const { d2, d1, d3 } = p
+  const { s1, s2, s3 } = r
+
+  // 1. 采样计算数据范围
+  const numPoints = 15
+  const points = sampleSpl(p, numPoints)
+
+  if (points[0].d > 0) points.unshift({ d: 0, spl: splAt(0, p) })
+  if (points[points.length - 1].d < d2) points.push({ d: d2, spl: splAt(d2, p) })
+
+  const splValues = points.map((pt) => pt.spl).filter(Number.isFinite)
+
+  if (splValues.length === 0) {
+    drawEmpty(board, labels.empty, pal)
+    return
+  }
+
+  const dataMinY = Math.min(...splValues)
+  const dataMaxY = Math.max(...splValues)
+
+  // 留出上下边距
+  const paddingY = Math.max((dataMaxY - dataMinY) * 0.15, 2)
+  const yMin = dataMinY - paddingY
+  const yMax = dataMaxY + paddingY
+
+  const xMin = 0
+  const xMax = d2
+
+  // 2. 设置精确的自适应视口
+  // [xMin, yMax, xMax, yMin] 注意顺序
+  board.setBoundingBox(
+    [
+      -xMax * 0.08, // 左边距留给 Y 轴文字
+      yMax,
+      xMax * 1.05, // 右边距留给 X 轴箭头
+      yMin - (yMax - yMin) * 0.2 // 下边距留给 X 轴文字和标题
+    ],
+    false
+  )
+
+  board.suspendUpdate()
+  try {
+    if (currentObjects.length > 0) {
+      board.removeObject(currentObjects)
+      currentObjects = []
+    }
+
+    const addObj = (type: string, args: any[], attrs: any = {}) => {
+      if (type === 'point') attrs.withLabel = false
+      attrs.highlight = false
+      const obj = board.create(type as any, args, attrs)
+      currentObjects.push(obj)
+      return obj
+    }
+
+    // ================= 一、坐标轴与网格 =================
+    const gX = nice((xMax - xMin) / 6)
+    const gY = nice((yMax - yMin) / 4)
+
+    addObj(
+      'segment',
+      [
+        [xMin, yMin],
+        [xMax, yMin]
+      ],
+      { strokeColor: pal.dim, strokeWidth: 1.5, lastArrow: true, layer: 1 }
+    )
+    addObj(
+      'segment',
+      [
+        [xMin, yMin],
+        [xMin, yMax]
+      ],
+      { strokeColor: pal.dim, strokeWidth: 1.5, lastArrow: true, layer: 1 }
+    )
+
+    for (let x = xMin + gX; x < xMax; x += gX) {
+      addObj(
+        'segment',
+        [
+          [x, yMin],
+          [x, yMax]
+        ],
+        { strokeColor: pal.border, dash: 2, strokeWidth: 1, strokeOpacity: 0.5, layer: 0 }
+      )
+    }
+    for (let y = Math.ceil(yMin / gY) * gY; y < yMax; y += gY) {
+      addObj(
+        'segment',
+        [
+          [xMin, y],
+          [xMax, y]
+        ],
+        { strokeColor: pal.border, dash: 2, strokeWidth: 1, strokeOpacity: 0.5, layer: 0 }
+      )
+    }
+
+    // X 轴刻度和数字
+    for (let x = xMin + gX; x < xMax; x += gX) {
+      addObj(
+        'segment',
+        [
+          [x, yMin],
+          [x, yMin - (yMax - yMin) * 0.02]
+        ],
+        { strokeColor: pal.dim, strokeWidth: 1, layer: 1 }
+      )
+      addObj('text', [x, yMin - (yMax - yMin) * 0.04, x.toFixed(0)], {
+        fontSize: 9,
+        color: pal.dim,
+        anchorX: 'center',
+        anchorY: 'top',
+        layer: 1
+      })
+    }
+
+    // Y 轴刻度和数字
+    for (let y = Math.ceil(yMin / gY) * gY; y < yMax; y += gY) {
+      addObj(
+        'segment',
+        [
+          [xMin, y],
+          [xMin - (xMax - xMin) * 0.015, y]
+        ],
+        { strokeColor: pal.dim, strokeWidth: 1, layer: 1 }
+      )
+      addObj('text', [xMin - (xMax - xMin) * 0.025, y, y.toFixed(0)], {
+        fontSize: 9,
+        color: pal.dim,
+        anchorX: 'right',
+        anchorY: 'middle',
+        layer: 1
+      })
+    }
+
+    addObj('text', [xMax, yMin - (yMax - yMin) * 0.12, labels.distance], {
+      fontSize: 10,
+      color: pal.dim,
+      anchorX: 'right',
+      anchorY: 'top',
+      layer: 1
+    })
+    addObj('text', [xMin, yMax + (yMax - yMin) * 0.02, labels.spl], {
+      fontSize: 10,
+      color: pal.dim,
+      anchorX: 'middle',
+      anchorY: 'bottom',
+      layer: 1
+    })
+
+    // ================= 二、绘制 SPL 曲线 =================
+    const xArr: number[] = []
+    const yArr: number[] = []
+    points.forEach((pt) => {
+      xArr.push(pt.d)
+      yArr.push(pt.spl)
+    })
+    addObj('curve', [xArr, yArr], { strokeColor: pal.accent, strokeWidth: 2.5, layer: 3 })
+
+    // ================= 三、绘制关键点及标签 =================
+    const keyPoints = [
+      { d: 0, spl: splAt(0, p), lbl: 'SPK', c: pal.cyan },
+      { d: d1, spl: s1, lbl: 'D1', c: pal.cyan },
+      { d: d3, spl: s3, lbl: 'D3', c: pal.accent },
+      { d: d2, spl: s2, lbl: 'D2', c: pal.cyan }
+    ]
+
+    const validPts = keyPoints.filter((pt) => pt.d >= 0 && pt.d <= xMax).sort((a, b) => a.d - b.d)
+
+    let lastX = -999
+    let currentTier = 0
+
+    validPts.forEach((pt) => {
+      addObj('point', [pt.d, pt.spl], {
+        size: 5,
+        fillColor: pt.c,
+        strokeColor: pal.bg,
+        strokeWidth: 1.5,
+        layer: 4
+      })
+
+      if (pt.d - lastX < xMax * 0.15) {
+        currentTier = (currentTier + 1) % 2
+      } else {
+        currentTier = 0
+      }
+      lastX = pt.d
+
+      const isRightEdge = pt.d > xMax * 0.85
+      const anchorX = isRightEdge ? 'right' : 'left'
+      const textX = isRightEdge ? pt.d - xMax * 0.02 : pt.d + xMax * 0.02
+      const textY = pt.spl + (yMax - yMin) * (0.05 + currentTier * 0.08)
+
+      addObj('text', [textX, textY, `${pt.lbl} · ${pt.spl.toFixed(1)} dB`], {
+        fontSize: 10,
+        color: pal.text,
+        anchorX: anchorX,
+        anchorY: 'bottom',
+        layer: 10
+      })
+    })
+  } finally {
+    board.unsuspendUpdate()
+    board.update()
+  }
+}

+ 294 - 0
src/renderer/src/lib/speaker/jsxgraph/topDiagram.ts

@@ -0,0 +1,294 @@
+import type { Board } from 'jsxgraph'
+import type { SpeakerParams } from '../types'
+import type { ChartPalette } from './palette'
+import { DEG, splAt } from '../calc'
+
+export interface TopDiagramChartLabels {
+  empty: string
+  forwardDistance: string
+  lateralDistance: string
+  leftBound: string
+  rightBound: string
+  acousticAxis: string
+  coverage: string
+  horizontal: string
+}
+
+// 记录当前画布上的业务图元,避免误删
+let currentObjects: any[] = []
+
+function parseHex(color: string): [number, number, number] {
+  const c = color.startsWith('#') ? color.slice(1) : color
+  if (c.length === 3) {
+    return [parseInt(c[0] + c[0], 16), parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16)]
+  }
+  return [
+    parseInt(c.substring(0, 2), 16),
+    parseInt(c.substring(2, 4), 16),
+    parseInt(c.substring(4, 6), 16)
+  ]
+}
+
+export function drawTopDiagram(
+  board: Board,
+  p: SpeakerParams & { covAngle?: number },
+  pal: ChartPalette
+): void {
+  const { splMax, d1, d2, d3 } = p
+  console.log(p)
+
+  const cov = p.hCov ?? p.hCov ?? 180
+  const maxD = Math.max(d1, d2, d3, 5) * 1.2
+
+  // JSXGraph 中,0° 是向右(X轴正方向),逆时针为正。
+  // 为了对称,我们从 -cov/2 画到 +cov/2
+  const t6Rad = (cov / 2) * DEG
+  const startAngle = -t6Rad
+  const endAngle = t6Rad
+  const isFullCircle = cov >= 359.9
+
+  board.suspendUpdate()
+  try {
+    // 1. 安全清理旧图元
+    if (currentObjects.length > 0) {
+      board.removeObject(currentObjects)
+      currentObjects = []
+    }
+
+    const addObj = (type: string, args: any[], attrs: any = {}) => {
+      if (type === 'point') {
+        attrs.withLabel = false
+        attrs.showInfobox = false
+      }
+      // 核心修复:全局禁用图元的高亮和悬停变粗效果
+      attrs.highlight = false
+      const obj = board.create(type as any, args, attrs)
+      currentObjects.push(obj)
+      return obj
+    }
+    const pt = (x: number, y: number) => addObj('point', [x, y], { visible: false, fixed: true })
+
+    // 2. 画极坐标网格 (同心圆和射线)
+    const gD = maxD / 5
+    // 同心圆
+    for (let r = gD; r < maxD; r += gD) {
+      addObj('circle', [pt(0, 0), r], {
+        strokeColor: pal.border,
+        dash: 2,
+        strokeWidth: 1,
+        strokeOpacity: 0.5,
+        layer: 0
+      })
+    }
+    // 横向与纵向基准轴线
+    addObj(
+      'segment',
+      [
+        [-maxD * 0.1, 0],
+        [maxD * 1.1, 0]
+      ],
+      { strokeColor: pal.dim, strokeWidth: 1.5, lastArrow: true, layer: 1 }
+    )
+    addObj(
+      'segment',
+      [
+        [0, -maxD * 0.9],
+        [0, maxD]
+      ],
+      { strokeColor: pal.dim, strokeWidth: 1.5, lastArrow: true, layer: 1 }
+    )
+
+    // 轴刻度文字
+    for (let r = gD; r < maxD; r += gD) {
+      addObj('text', [r, -maxD * 0.05, r.toFixed(0)], {
+        fontSize: 9,
+        color: pal.dim,
+        anchorX: 'center',
+        anchorY: 'top',
+        layer: 1
+      })
+      addObj('text', [maxD * 0.02, r, r.toFixed(0)], {
+        fontSize: 9,
+        color: pal.dim,
+        anchorX: 'left',
+        anchorY: 'middle',
+        layer: 1
+      })
+    }
+    // 轴标题
+    addObj('text', [maxD * 0.95, -maxD * 0.08, '前方 (m)'], {
+      fontSize: 10,
+      color: pal.dim,
+      anchorX: 'right',
+      anchorY: 'top',
+      layer: 1
+    })
+    addObj('text', [-maxD * 0.05, maxD * 0.95, '左侧 (m)'], {
+      fontSize: 10,
+      color: pal.dim,
+      anchorX: 'right',
+      anchorY: 'middle',
+      rotate: 90,
+      layer: 1
+    })
+
+    // 3. 画 SPL 分层扇形背景(半透明雷达图效果)
+    const layers = 24
+    const [br, bg, bb] = parseHex(pal.accent)
+    const splAtMaxD = splAt(maxD, p)
+    const splRange = Math.max(splMax - splAtMaxD, 1)
+    const steps = isFullCircle ? 64 : 32
+
+    for (let i = 0; i < layers; i++) {
+      const rInner = (maxD * i) / layers
+      const rOuter = (maxD * (i + 1)) / layers
+      const rMid = (rInner + rOuter) / 2
+
+      const spl = splAt(rMid, p)
+      const splRatio = Math.max(0, Math.min(1, (spl - splAtMaxD) / splRange))
+      const alpha = 0.08 + splRatio * 0.82
+      const fillHex = `#${br.toString(16).padStart(2, '0')}${bg.toString(16).padStart(2, '0')}${bb.toString(16).padStart(2, '0')}`
+
+      const xCoords: number[] = []
+      const yCoords: number[] = []
+      for (let j = 0; j <= steps; j++) {
+        const a = startAngle + ((endAngle - startAngle) * j) / steps
+        xCoords.push(Math.cos(a) * rOuter)
+        yCoords.push(Math.sin(a) * rOuter)
+      }
+      for (let j = steps; j >= 0; j--) {
+        const a = startAngle + ((endAngle - startAngle) * j) / steps
+        xCoords.push(Math.cos(a) * rInner)
+        yCoords.push(Math.sin(a) * rInner)
+      }
+      xCoords.push(Math.cos(startAngle) * rOuter)
+      yCoords.push(Math.sin(startAngle) * rOuter)
+
+      addObj('curve', [xCoords, yCoords], {
+        fillColor: fillHex,
+        fillOpacity: alpha,
+        strokeColor: 'none',
+        layer: 2
+      })
+    }
+
+    // 4. -6dB 边界虚线
+    if (!isFullCircle) {
+      addObj(
+        'segment',
+        [
+          [0, 0],
+          [maxD * Math.cos(startAngle), maxD * Math.sin(startAngle)]
+        ],
+        { strokeColor: pal.accent, dash: 2, layer: 3 }
+      )
+      addObj(
+        'segment',
+        [
+          [0, 0],
+          [maxD * Math.cos(endAngle), maxD * Math.sin(endAngle)]
+        ],
+        { strokeColor: pal.accent, dash: 2, layer: 3 }
+      )
+    }
+
+    // 5. 中心声轴(橙色粗线)
+    addObj(
+      'segment',
+      [
+        [0, 0],
+        [maxD, 0]
+      ],
+      { strokeColor: pal.accent, strokeWidth: 2.5, layer: 4 }
+    )
+
+    // 6. D1/D2/D3 距离参考圆弧
+    const rings = [d1, d2, d3].sort((a, b) => a - b)
+    rings.forEach((r) => {
+      if (r > 0 && r <= maxD) {
+        const xCoords: number[] = []
+        const yCoords: number[] = []
+        for (let j = 0; j <= steps; j++) {
+          const a = startAngle + ((endAngle - startAngle) * j) / steps
+          xCoords.push(Math.cos(a) * r)
+          yCoords.push(Math.sin(a) * r)
+        }
+        addObj('curve', [xCoords, -yCoords], {
+          strokeColor: pal.text,
+          strokeWidth: 0.5,
+          dash: 2,
+          strokeOpacity: 0.3,
+          layer: 3
+        })
+      }
+    })
+
+    // 7. 画点与防重叠标签
+    const pts = [
+      { d: d1, lbl: 'D1', c: pal.cyan },
+      { d: d2, lbl: 'D2', c: pal.cyan },
+      { d: d3, lbl: 'D3', c: pal.accent }
+    ]
+    const sortedPts = [...pts].sort((a, b) => a.d - b.d)
+
+    sortedPts.forEach((ptDef, index) => {
+      const x = ptDef.d
+      if (x < 0 || x > maxD) return
+
+      const spl = splAt(x, p)
+
+      // 画点
+      addObj('point', [x, 0], {
+        size: 4,
+        fillColor: ptDef.c,
+        strokeColor: pal.bg,
+        strokeWidth: 1.5,
+        layer: 4
+      })
+
+      // 判断是否和前一个点靠得太近,如果近就强制往上错开一层
+      let currentTier = 0
+      if (index > 0) {
+        const prevX = sortedPts[index - 1].d
+        if (Math.abs(x - prevX) < maxD * 0.15) {
+          currentTier = 1
+        }
+      }
+
+      // 核心修改:textY 改为向上偏移(正数),层级错位也往上推
+      const textY = maxD * 0.06 + currentTier * (maxD * 0.12)
+
+      // 如果进行了层级错位,画一条辅助引线指上去
+      if (currentTier > 0) {
+        addObj(
+          'segment',
+          [
+            [x, 0],
+            [x, textY]
+          ],
+          { strokeColor: pal.dim, strokeWidth: 1, dash: 1, strokeOpacity: 0.5, layer: 3 }
+        )
+      }
+
+      // 第一行:距离(靠上)
+      addObj('text', [x, textY + maxD * 0.06, `${ptDef.lbl} = ${x.toFixed(1)}m`], {
+        fontSize: 10,
+        color: ptDef.c,
+        anchorX: 'center',
+        anchorY: 'bottom',
+        layer: 10
+      })
+      // 第二行:声压级(靠下,贴近点)
+      addObj('text', [x, textY, `${spl.toFixed(1)} dB`], {
+        fontSize: 10,
+        color: pal.text,
+        anchorX: 'center',
+        anchorY: 'bottom',
+        layer: 10
+      })
+    })
+  } finally {
+    board.unsuspendUpdate()
+    board.update()
+  }
+}

+ 2 - 2
src/renderer/src/theme/useChartPalette.ts

@@ -6,8 +6,8 @@
  */
 import { computed, type ComputedRef } from 'vue'
 import { useThemeVars } from 'naive-ui'
-import type { ChartPalette } from '../lib/speaker/echarts/palette'
-import { paletteFromThemeVars } from '../lib/speaker/echarts/palette'
+import type { ChartPalette } from '../lib/speaker/jsxgraph/palette'
+import { paletteFromThemeVars } from '../lib/speaker/jsxgraph/palette'
 import { isDark } from '.'
 
 export function useChartPalette(): ComputedRef<ChartPalette> {