增加折线

This commit is contained in:
zhangyue 2026-07-25 18:59:32 +08:00
parent a42c3f5824
commit 06a4324b90
1 changed files with 12 additions and 15 deletions

View File

@ -70,6 +70,7 @@
<template #title> <template #title>
<div class="card-header"> <div class="card-header">
<span class="chart-title">{{ item.title || `图表 ${index + 1}` }}</span> <span class="chart-title">{{ item.title || `图表 ${index + 1}` }}</span>
<!-- 保持您原来的写法不做任何修改 -->
<a-tag color="blue" size="small">{{ item.data?.length || 0 }} </a-tag> <a-tag color="blue" size="small">{{ item.data?.length || 0 }} </a-tag>
</div> </div>
</template> </template>
@ -288,9 +289,6 @@ const loadCategories = async () => {
const loadChartData = async (deployId, summaryMode, startTime) => { const loadChartData = async (deployId, summaryMode, startTime) => {
if (!deployId) return; if (!deployId) return;
// tag 0
chartDataList.value = [];
loading.value = true; loading.value = true;
try { try {
// //
@ -398,7 +396,7 @@ const calculateYAxisRange = (data, markLines) => {
const range = allMax - allMin; const range = allMax - allMin;
const padding = range * 0.15 || 10; const padding = range * 0.15 || 10;
// //
return { return {
min: roundToTwo(allMin - padding), min: roundToTwo(allMin - padding),
max: roundToTwo(allMax + padding), max: roundToTwo(allMax + padding),
@ -476,7 +474,6 @@ const getChartOption = (item) => {
}, },
yAxis: { yAxis: {
type: 'value', type: 'value',
// y markLine
min: yAxisRange.min !== null ? yAxisRange.min : undefined, min: yAxisRange.min !== null ? yAxisRange.min : undefined,
max: yAxisRange.max !== null ? yAxisRange.max : undefined, max: yAxisRange.max !== null ? yAxisRange.max : undefined,
splitLine: { splitLine: {
@ -488,13 +485,13 @@ const getChartOption = (item) => {
axisLabel: { axisLabel: {
fontSize: 11, fontSize: 11,
color: '#888', color: '#888',
// y
formatter: (value) => { formatter: (value) => {
return roundToTwo(value); return roundToTwo(value);
}, },
}, },
}, },
series: [ series: [
// ========== ==========
{ {
name: item.title || '数据', name: item.title || '数据',
type: 'bar', type: 'bar',
@ -534,9 +531,9 @@ const getChartOption = (item) => {
}, },
}, },
}, },
// 线 // ========== 线 ==========
{ {
name: item.title || '趋势', name: `${item.title || '数据'}趋势`,
type: 'line', type: 'line',
data: item.data || [], data: item.data || [],
smooth: true, smooth: true,
@ -557,14 +554,11 @@ const getChartOption = (item) => {
x2: 0, x2: 0,
y2: 1, y2: 1,
colorStops: [ colorStops: [
{ offset: 0, color: 'rgba(255, 107, 107, 0.3)' }, { offset: 0, color: 'rgba(255, 107, 107, 0.25)' },
{ offset: 1, color: 'rgba(255, 107, 107, 0.05)' }, { offset: 1, color: 'rgba(255, 107, 107, 0.02)' },
], ],
}, },
}, },
emphasis: {
focus: 'series',
},
label: { label: {
show: true, show: true,
position: 'top', position: 'top',
@ -575,7 +569,9 @@ const getChartOption = (item) => {
return params.value; return params.value;
}, },
}, },
// 线 x emphasis: {
focus: 'series',
},
xAxisIndex: 0, xAxisIndex: 0,
yAxisIndex: 0, yAxisIndex: 0,
}, },
@ -592,8 +588,9 @@ const getChartOption = (item) => {
name: item.title || '数据', name: item.title || '数据',
icon: 'roundRect', icon: 'roundRect',
}, },
// 线
{ {
name: item.title || '趋势', name: `${item.title || '数据'}趋势`,
icon: 'line', icon: 'line',
itemStyle: { itemStyle: {
color: '#ff6b6b', color: '#ff6b6b',