统计分析

This commit is contained in:
geting 2024-10-31 15:34:33 +08:00
parent 0b80076d24
commit a3c29f08b1
2 changed files with 14 additions and 5 deletions

View File

@ -340,9 +340,12 @@ const getTimeIntervals = (startTimestamp, endTimestamp) => {
return count
}
const calculate = reactive([{ max: '', min: '', average: '' }])
var xDatas = []
const statAnalysisOperate = () => {
option.series = []
option.legend.data = []
xDatas = []
chart.value.setOption(option, { notMerge: true })
times.forEach((time, index) => {
if (time[0] && time[1]) {
@ -361,8 +364,7 @@ const statAnalysisOperate = () => {
}
})
}
const calculate = reactive([{ max: '', min: '', average: '' }])
const xDatas = reactive([])
const historyDataReq = (data, index) => {
historyReq(data).then((res) => {
if (res.code == 200) {
@ -377,12 +379,15 @@ const historyDataReq = (data, index) => {
min: Math.floor(Math.min(...yData)),
average: Math.floor(yData.reduce((a, b) => a + b, 0) / yData.length),
}
xDatas.push(xData)
xDatas.push({
series: String(customName[index]),
data: xData,
})
option.tooltip = {
show: true,
formatter: function (params) {
const index = customName.indexOf(params.seriesName)
const x = timestampToTime(xDatas[index][params.dataIndex])
const matchData = xDatas.filter((x) => x.series == params.seriesName)
const x = timestampToTime(matchData[0]['data'][params.dataIndex])
return `${params.marker} ${params.seriesName} <br/> ${x} <b>${params.data}</b>`
},
}
@ -391,6 +396,7 @@ const historyDataReq = (data, index) => {
name: customName[index],
type: 'line',
data: yData,
showSymbol: true,
}
option.legend.data.push(customName[index])
option.series.push(seriesData)

View File

@ -197,6 +197,9 @@ const option = {
xAxis: {
type: 'category',
data: [],
axisLabel: {
rotate: 15,
},
},
yAxis: {
type: 'value',