增加折线

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