diff --git a/src/components/WaveformDisplay/WaveformDisplay.vue b/src/components/WaveformDisplay/WaveformDisplay.vue index 730f4bc..e73f4c3 100644 --- a/src/components/WaveformDisplay/WaveformDisplay.vue +++ b/src/components/WaveformDisplay/WaveformDisplay.vue @@ -180,15 +180,12 @@ const option = computed((): EChartsOption => { // 构造带过渡的点序列 function buildVcdLine(valArr: number[], high: number, low: number) { const points: {x: number, y: number}[] = []; - for (let i = 0; i < valArr.length; i++) { - const v = valArr[i] > 0 ? high : low; + let lastValue = high; + points.push({x: xArr[0], y: lastValue}); + for (let i = 1; i < valArr.length; i++) { + const v = valArr[i] !== valArr[i-1] ? (lastValue === high ? low : high) : lastValue; points.push({x: xArr[i], y: v}); - // 检查下一个点是否变化,若变化则插入过渡点 - if (i < valArr.length - 1 && valArr[i] !== valArr[i+1]) { - // 过渡点,x略微偏移(如+0.3),y为下一个值 - const nextV = valArr[i+1] > 0 ? high : low; - points.push({x: xArr[i]+0.3, y: nextV}); - } + lastValue = v; } // 返回y数组,x由category轴控制 return points.map(p => p.y);