feat: 修改debugger的波形显示

This commit is contained in:
SikongJueluo 2025-07-21 18:11:43 +08:00
parent e872f24936
commit e7c8d3fb9e
1 changed files with 89 additions and 41 deletions

View File

@ -95,15 +95,15 @@ const option = computed((): EChartsOption => {
.map((channel, index) => (channel.enabled ? index : -1))
.filter((index) => index !== -1);
//
const channelCount = enabledChannels.length;
const channelSpacing = 2; //
//
if (channelCount === 0) {
return {};
}
// 使
//
const grids: GridComponentOption[] = [
{
left: "5%",
@ -147,34 +147,84 @@ const option = computed((): EChartsOption => {
},
];
//
const series: LineSeriesOption[] = enabledChannelIndices.map(
(originalIndex: number, displayIndex: number) => ({
name: enabledChannels[displayIndex].name,
type: "line",
data: analyzer.logicData.value!.y[originalIndex].value.map(
(value: number) => value + displayIndex * channelSpacing + 0.2,
),
step: "end",
lineStyle: {
width: 2,
color: enabledChannels[displayIndex].color,
},
areaStyle: {
opacity: 0.3,
origin: displayIndex * channelSpacing,
color: enabledChannels[displayIndex].color,
},
symbol: "none",
//
sampling: "lttb",
//
animation: false,
}),
);
//
const series: LineSeriesOption[] = [];
enabledChannelIndices.forEach((originalIndex: number, displayIndex: number) => {
const channel = analyzer.logicData.value!.y[originalIndex];
if (channel.type === "logic") {
// logic
series.push({
name: channel.name,
type: "line",
data: channel.value.map(
(value: number) => value + displayIndex * channelSpacing + 0.2,
),
step: "end",
lineStyle: {
width: 2,
color: channel.color,
},
areaStyle: {
opacity: 0.3,
origin: displayIndex * channelSpacing,
color: channel.color,
},
symbol: "none",
sampling: "lttb",
animation: false,
});
} else if (channel.type === "number") {
// numberVCD仿线10areaStyle
const values = channel.value;
const xArr = analyzer.logicData.value!.x;
//
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;
points.push({x: xArr[i], y: v});
//
if (i < valArr.length - 1 && valArr[i] !== valArr[i+1]) {
// x+0.3y
const nextV = valArr[i+1] > 0 ? high : low;
points.push({x: xArr[i]+0.3, y: nextV});
}
}
// yxcategory
return points.map(p => p.y);
}
// 1线
series.push({
name: channel.name + "_1",
type: "line",
data: buildVcdLine(values, displayIndex * channelSpacing + 1, displayIndex * channelSpacing),
step: false, // step
lineStyle: {
width: 2,
color: channel.color,
},
symbol: "none",
sampling: "lttb",
animation: false,
});
// 0线
series.push({
name: channel.name + "_0",
type: "line",
data: buildVcdLine(values, displayIndex * channelSpacing, displayIndex * channelSpacing + 1),
step: false,
lineStyle: {
width: 2,
color: channel.color,
},
symbol: "none",
sampling: "lttb",
animation: false,
});
}
});
return {
//
animation: false,
tooltip: {
trigger: "axis",
@ -183,31 +233,29 @@ const option = computed((): EChartsOption => {
label: {
backgroundColor: "#6a7985",
},
// axisPointer
animation: false,
},
formatter: (params: any) => {
if (Array.isArray(params) && params.length > 0) {
const timeValue = analyzer.logicData.value!.x[params[0].dataIndex];
const dataIndex = params[0].dataIndex;
let tooltip = `Time: ${timeValue.toFixed(3)}${analyzer.logicData.value!.xUnit}<br/>`;
// 01
enabledChannelIndices.forEach(
(originalIndex: number, displayIndex: number) => {
const channelName = enabledChannels[displayIndex].name;
const originalValue =
analyzer.logicData.value!.y[originalIndex].value[dataIndex];
enabledChannelIndices.forEach((originalIndex: number, displayIndex: number) => {
const channel = analyzer.logicData.value!.y[originalIndex];
if (channel.type === "logic") {
const channelName = channel.name;
const originalValue = channel.value[dataIndex];
tooltip += `${channelName}: ${originalValue}<br/>`;
},
);
} else if (channel.type === "number") {
const channelName = channel.name;
const originalValue = channel.value[dataIndex];
tooltip += `${channelName}: ${originalValue}<br/>`;
}
});
return tooltip;
}
return "";
},
// tooltip
hideDelay: 100,
},
toolbox: {