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) => {
const total = (alertTypes || []).reduce((sum, item) => sum + (item.count || 0), 0)
return {
grid: {
top: 0,
left: 0,
right: 0,
bottom: 0,
containLabel: false
},
series: [ series: [
{ {
type: 'pie', type: 'pie',
radius: ['45%', '70%'], radius: ['42%', '68%'],
center: ['50%', '50%'], center: ['50%', '50%'],
avoidLabelOverlap: false, avoidLabelOverlap: false,
itemStyle: pieItemStyle, itemStyle: pieItemStyle,
label: { label: {
show: true, show: true,
position: 'center', position: 'center',
formatter: '{total|15}\n{name|报警总数}', formatter: `{total|${total}}\n{name|报警总数}`,
rich: createCenterLabelRich(28, 14) rich: createCenterLabelRich(16, 10)
}, },
labelLine: { labelLine: {
show: false show: false
}, },
data: alertTypes.map((item) => ({ data: (alertTypes || []).map((item, index) => ({
value: item.count, value: item.count || 0,
name: item.name, name: item.name || '未知',
itemStyle: { itemStyle: {
color: item.color 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,13 +232,44 @@ export const getProjectBarOption = (projectData) => ({
] ]
}) })
export const getAlertTrendOption = () => ({ export const getAlertTrendOption = (payload = {}) => {
const dates = payload.dates || []
const seriesList = (payload.series || []).map((item, index) => {
const color = techChartSeriesColors[index % techChartSeriesColors.length]
return {
name: item.category || `系列${index + 1}`,
data: item.data || [],
type: 'line',
smooth: true,
lineStyle: {
color,
width: 2
},
itemStyle: {
color
},
markPoint: {
data: [
{
type: 'max',
name: 'Max'
},
{
type: 'min',
name: 'Min'
}
]
}
}
})
return {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
...techChartTooltip ...techChartTooltip
}, },
legend: { legend: {
data: ['二级报警', '报警', '预警'], data: seriesList.map((s) => s.name),
right: 10, right: 10,
top: 0, top: 0,
...techChartLegend, ...techChartLegend,
@@ -248,7 +289,7 @@ export const getAlertTrendOption = () => ({
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: ['01', '05', '10', '15', '20', '25', '30'], data: dates,
axisLine: techChartAxisLine, axisLine: techChartAxisLine,
axisLabel: compactAxisLabel axisLabel: compactAxisLabel
}, },
@@ -260,81 +301,6 @@ export const getAlertTrendOption = () => ({
axisLine: techChartAxisLine, axisLine: techChartAxisLine,
axisLabel: compactAxisLabel axisLabel: compactAxisLabel
}, },
series: [ series: seriesList
{
name: '二级报警',
data: [0, 1, 1, 2, 0, 0, 3],
type: 'line',
smooth: true,
lineStyle: {
color: techChartSeriesColors[5],
width: 2
},
itemStyle: {
color: techChartSeriesColors[5]
},
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: {
data: [
{
type: 'max',
name: 'Max'
},
{
type: 'min',
name: 'Min'
}
]
} }
} }
]
})