This commit is contained in:
xiaozhiyong
2026-06-16 17:08:32 +08:00
parent 30be0af63b
commit bc13e4264e
2 changed files with 572 additions and 468 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -106,33 +106,43 @@ export const getAlarmPendingOption = () => ({
] ]
}) })
export const getAlertDistributionOption = (alertTypes) => ({ export const getAlertDistributionOption = (alertTypes) => {
series: [ const total = (alertTypes || []).reduce((sum, item) => sum + (item.count || 0), 0)
{ return {
type: 'pie', grid: {
radius: ['45%', '70%'], top: 0,
center: ['50%', '50%'], left: 0,
avoidLabelOverlap: false, right: 0,
itemStyle: pieItemStyle, bottom: 0,
label: { containLabel: false
show: true, },
position: 'center', series: [
formatter: '{total|15}\n{name|报警总数}', {
rich: createCenterLabelRich(28, 14) type: 'pie',
}, radius: ['42%', '68%'],
labelLine: { center: ['50%', '50%'],
show: false avoidLabelOverlap: false,
}, itemStyle: pieItemStyle,
data: alertTypes.map((item) => ({ label: {
value: item.count, show: true,
name: item.name, position: 'center',
itemStyle: { formatter: `{total|${total}}\n{name|报警总数}`,
color: item.color rich: createCenterLabelRich(16, 10)
} },
})) labelLine: {
} show: false
] },
}) data: (alertTypes || []).map((item, index) => ({
value: item.count || 0,
name: item.name || '未知',
itemStyle: {
color: item.color || techChartSeriesColors[index % techChartSeriesColors.length]
}
}))
}
]
}
}
export const getDeviceStatOption = (deviceTypes) => { export const getDeviceStatOption = (deviceTypes) => {
const total = deviceTypes.reduce((sum, item) => sum + (item.count || item.value || 0), 0) const total = deviceTypes.reduce((sum, item) => sum + (item.count || item.value || 0), 0)
@@ -222,106 +232,21 @@ export const getProjectBarOption = (projectData) => ({
] ]
}) })
export const getAlertTrendOption = () => ({ export const getAlertTrendOption = (payload = {}) => {
tooltip: { const dates = payload.dates || []
trigger: 'axis', const seriesList = (payload.series || []).map((item, index) => {
...techChartTooltip const color = techChartSeriesColors[index % techChartSeriesColors.length]
}, return {
legend: { name: item.category || `系列${index + 1}`,
data: ['二级报警', '报警', '预警'], data: item.data || [],
right: 10,
top: 0,
...techChartLegend,
textStyle: {
...techChartLegend.textStyle,
fontSize: 10
},
itemWidth: 10,
itemHeight: 10
},
grid: {
top: '15%',
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
data: ['01', '05', '10', '15', '20', '25', '30'],
axisLine: techChartAxisLine,
axisLabel: compactAxisLabel
},
yAxis: {
type: 'value',
name: '数量',
nameTextStyle: chartNameTextStyle,
splitLine: dashedSplitLine,
axisLine: techChartAxisLine,
axisLabel: compactAxisLabel
},
series: [
{
name: '二级报警',
data: [0, 1, 1, 2, 0, 0, 3],
type: 'line', type: 'line',
smooth: true, smooth: true,
lineStyle: { lineStyle: {
color: techChartSeriesColors[5], color,
width: 2 width: 2
}, },
itemStyle: { itemStyle: {
color: techChartSeriesColors[5] color
},
markPoint: {
data: [
{
type: 'max',
name: 'Max'
},
{
type: 'min',
name: 'Min'
}
]
}
},
{
name: '报警',
data: [1, 0, 0, 1, 1, 1, 0],
type: 'line',
smooth: true,
lineStyle: {
color: techChartSeriesColors[3],
width: 2
},
itemStyle: {
color: techChartSeriesColors[3]
},
markPoint: {
data: [
{
type: 'max',
name: 'Max'
},
{
type: 'min',
name: 'Min'
}
]
}
},
{
name: '预警',
data: [0, 1, 1, 0, 1, 1, 1],
type: 'line',
smooth: true,
lineStyle: {
color: techChartSeriesColors[2],
width: 2
},
itemStyle: {
color: techChartSeriesColors[2]
}, },
markPoint: { markPoint: {
data: [ data: [
@@ -336,5 +261,46 @@ export const getAlertTrendOption = () => ({
] ]
} }
} }
] })
})
return {
tooltip: {
trigger: 'axis',
...techChartTooltip
},
legend: {
data: seriesList.map((s) => s.name),
right: 10,
top: 0,
...techChartLegend,
textStyle: {
...techChartLegend.textStyle,
fontSize: 10
},
itemWidth: 10,
itemHeight: 10
},
grid: {
top: '15%',
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
data: dates,
axisLine: techChartAxisLine,
axisLabel: compactAxisLabel
},
yAxis: {
type: 'value',
name: '数量',
nameTextStyle: chartNameTextStyle,
splitLine: dashedSplitLine,
axisLine: techChartAxisLine,
axisLabel: compactAxisLabel
},
series: seriesList
}
}