Skip to content

Commit

Permalink
Merge pull request #3001 from emqx/dev/1.10.1
Browse files Browse the repository at this point in the history
Sync code from refs/heads/dev/1.10.1 to enterprise
  • Loading branch information
Kinplemelon authored Oct 12, 2024
2 parents 91fae43 + b37e75b commit 7a5242c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/views/Dashboard/components/PolylineCards.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ import { ChartType } from '@/types/enum'
import useI18nTl from '@/hooks/useI18nTl'
import useSyncPolling from '@/hooks/useSyncPolling'
import { FullScreen } from '@element-plus/icons-vue'
import { isNumber } from 'lodash'
import InfoTooltip from '@/components/InfoTooltip.vue'

const POLLING_INTERVAL = 60000
Expand Down Expand Up @@ -307,11 +308,15 @@ const openedFullScreen = async () => {
fullScreenChart.value?.chart?.resize()
}

const calculateStatistics = (data: number[]) => {
const max = Math.max(...data)
const min = Math.min(...data)
const sum = data.reduce((acc, val) => acc + val, 0)
const avg = Math.round(sum / data.length)
const calculateStatistics = (data: Array<number | null>) => {
const validData: Array<number> = data.filter(
(item) => isNumber(item) && item !== -1,
) as Array<number>
const validDataLength = validData.length
const max = Math.max(...validData)
const min = Math.min(...validData)
const sum = validData.reduce((acc, val) => acc + val, 0)
const avg = Math.round(sum / validDataLength)
const last = data[data.length - 1]
return { max, min, avg, last }
}
Expand Down

0 comments on commit 7a5242c

Please sign in to comment.