diff --git a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue index 01d89767a..b4386f54c 100644 --- a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue +++ b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue @@ -191,7 +191,7 @@ export default { this.legends = [] this.series = chartOption.series = this.handleTimeSeries(this.chartInfo, chartOption.series[0], this.chartData) // 生成series和legends - + console.log(this.$lodash.cloneDeep( this.chartData), ' this.chartData') chartOption.series.forEach(item => { if (item.lineStyle) { item.lineStyle.width = this.lineOption.lineWidth @@ -238,6 +238,7 @@ export default { delete chartOption.tooltip.position } const option = this.renderYAxis(this.chartData, this.chartInfo) + console.log(option) chartOption.yAxis[0] = { ...chartOption.yAxis[0], ...option.yAxis[0] } chartOption.yAxis[1] = { ...chartOption.yAxis[1], ...option.yAxis[1] } if (chartOption.toolbox.feature) { @@ -611,7 +612,11 @@ export default { yAxisLabelFormatter (minValue, maxValue, copies, unit, dot) { const self = this return function (val, index) { - const value = formatScientificNotation(val, 6) + console.log(val) + let value = formatScientificNotation(val, 6) + if (!val) { + value = 0 + } return unit.compute(value, index, -1, dot) } }, diff --git a/nezha-fronted/src/components/chart/chart/legend.vue b/nezha-fronted/src/components/chart/chart/legend.vue index 49c6eccfc..0157b04c6 100644 --- a/nezha-fronted/src/components/chart/chart/legend.vue +++ b/nezha-fronted/src/components/chart/chart/legend.vue @@ -350,7 +350,7 @@ export default { maxValue = Math.abs(minValue) } maxValue = maxValue - minValue - maxValue = chartDataFormat.formatDatas(maxValue, unit.type, 'ceil', unit.ascii) + maxValue = chartDataFormat.formatDatas(maxValue, unit, 'ceil', unit.ascii) let oldValue = maxValue if (maxValue < 0) { oldValue = Math.abs(maxValue) diff --git a/nezha-fronted/src/components/chart/chart/line-chart-block.vue b/nezha-fronted/src/components/chart/chart/line-chart-block.vue index 27c2eb92f..1b5f48c50 100644 --- a/nezha-fronted/src/components/chart/chart/line-chart-block.vue +++ b/nezha-fronted/src/components/chart/chart/line-chart-block.vue @@ -2083,7 +2083,7 @@ export default { maxValue = Math.abs(minValue) } maxValue = maxValue - minValue - maxValue = chartDataFormat.formatDatas(maxValue, unit.type, 'ceil', unit.ascii) + maxValue = chartDataFormat.formatDatas(maxValue, unit, 'ceil', unit.ascii) let oldValue = maxValue let dot = 0 if (maxValue == 1) { diff --git a/nezha-fronted/src/components/chart/chartDataFormat.js b/nezha-fronted/src/components/chart/chartDataFormat.js index 4bcd81b17..2fbd8dbdd 100644 --- a/nezha-fronted/src/components/chart/chartDataFormat.js +++ b/nezha-fronted/src/components/chart/chartDataFormat.js @@ -73,6 +73,22 @@ function bits (value, index, type = 1, dot = 0) { return asciiCompute(num, 1024, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2) } } +function bitsSI (value, index, type = 1, dot = 0) { + const num = value / 8 + if (value < 8) { + return value + 'b' + } + if (num < 1000) { + return num + 'B' + } + if (type == 1) { + return asciiCompute(num, 1000, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0) + } else if (type == -1) { + return asciiCompute(num, 1000, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], dot) + } else { + return asciiCompute(num, 1000, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2) + } +} function bytes (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1024, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0) @@ -82,6 +98,15 @@ function bytes (value, index, type = 1, dot) { return asciiCompute(value, 1024, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2) } } +function bytesSI (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1000, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0) + } else if (type == -1) { + return asciiCompute(value, 1000, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], dot) + } else { + return asciiCompute(value, 1000, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2) + } +} function kilobytes (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1024, ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0) @@ -91,6 +116,15 @@ function kilobytes (value, index, type = 1, dot) { return asciiCompute(value, 1024, ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2) } } +function kilobytesSI (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1000, ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0) + } else if (type == -1) { + return asciiCompute(value, 1000, ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], dot) + } else { + return asciiCompute(value, 1000, ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2) + } +} function megabytes (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1024, ['MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0) @@ -100,6 +134,15 @@ function megabytes (value, index, type = 1, dot) { return asciiCompute(value, 1024, ['MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2) } } +function megabytesSI (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1000, ['MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0) + } else if (type == -1) { + return asciiCompute(value, 1000, ['MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], dot) + } else { + return asciiCompute(value, 1000, ['MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2) + } +} function gigabytes (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1024, ['GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0) @@ -109,6 +152,15 @@ function gigabytes (value, index, type = 1, dot) { return asciiCompute(value, 1024, ['GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2) } } +function gigabytesSI (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1000, ['GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 0) + } else if (type == -1) { + return asciiCompute(value, 1000, ['GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], dot) + } else { + return asciiCompute(value, 1000, ['GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 2) + } +} function terabytes (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1024, ['TB', 'PB', 'EB', 'ZB', 'YB'], 0) @@ -118,6 +170,15 @@ function terabytes (value, index, type = 1, dot) { return asciiCompute(value, 1024, ['TB', 'PB', 'EB', 'ZB', 'YB'], 2) } } +function terabytesSI (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1000, ['TB', 'PB', 'EB', 'ZB', 'YB'], 0) + } else if (type == -1) { + return asciiCompute(value, 1000, ['TB', 'PB', 'EB', 'ZB', 'YB'], dot) + } else { + return asciiCompute(value, 1000, ['TB', 'PB', 'EB', 'ZB', 'YB'], 2) + } +} function petabytes (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1024, ['PB', 'EB', 'ZB', 'YB'], 0) @@ -127,6 +188,15 @@ function petabytes (value, index, type = 1, dot) { return asciiCompute(value, 1024, ['PB', 'EB', 'ZB', 'YB'], 2) } } +function petabytesSI (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1024, ['PB', 'EB', 'ZB', 'YB'], 0) + } else if (type == -1) { + return asciiCompute(value, 1024, ['PB', 'EB', 'ZB', 'YB'], dot) + } else { + return asciiCompute(value, 1024, ['PB', 'EB', 'ZB', 'YB'], 2) + } +} function packetsSec (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1000, ['pps', 'Kpps', 'Mpps', 'Gpps', 'Tpps', 'Ppps', 'Epps', 'Zpps', 'Ypps'], 1) @@ -137,6 +207,128 @@ function packetsSec (value, index, type = 1, dot) { } } function bitsSec (value, index, type = 1, dot) { + const num = value / 8 + if (value < 8) { + return value + 'b' + } + if (num < 1024) { + return num + 'B' + } + if (type == 1) { + return asciiCompute(value, 1024, ['bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Epps', 'Zpps', 'Ypps'], 1) + } else if (type == -1) { + return asciiCompute(value, 1024, ['bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Epps', 'Zpps', 'Ypps'], dot) + } else { + return asciiCompute(value, 1024, ['bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Epps', 'Zpps', 'Ypps'], 2) + } +} +function bytesSec (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1024, ['Bs', 'KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1) + } else if (type == -1) { + return asciiCompute(value, 1024, ['Bs', 'KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], dot) + } else { + return asciiCompute(value, 1024, ['Bs', 'KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2) + } +} +function kilobytesSec (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1024, ['KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1) + } else if (type == -1) { + return asciiCompute(value, 1024, ['KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], dot) + } else { + return asciiCompute(value, 1024, ['KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1) + } +} +function kilobitsSec (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1024, ['Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1) + } else if (type == -1) { + return asciiCompute(value, 1024, ['Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], dot) + } else { + return asciiCompute(value, 1024, ['Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2) + } +} +function megabytesSec (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1024, ['MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1) + } else if (type == -1) { + return asciiCompute(value, 1024, ['MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], dot) + } else { + return asciiCompute(value, 1024, ['MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2) + } +} +function megabitsSec (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1024, ['Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1) + } else if (type == -1) { + return asciiCompute(value, 1024, ['Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], dot) + } else { + return asciiCompute(value, 1024, ['Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2) + } +} +function gigabytesSec (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1024, ['GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1) + } else if (type == -1) { + return asciiCompute(value, 1024, ['GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], dot) + } else { + return asciiCompute(value, 1024, ['GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2) + } +} +function gigabitsSec (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1024, ['Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1) + } else if (type == -1) { + return asciiCompute(value, 1024, ['Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], dot) + } else { + return asciiCompute(value, 1024, ['Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2) + } +} +function terabytesSec (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1024, ['TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1) + } else if (type == -1) { + return asciiCompute(value, 1024, ['TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], dot) + } else { + return asciiCompute(value, 1024, ['TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2) + } +} +function terabitsSec (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1024, ['Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1) + } else if (type == -1) { + return asciiCompute(value, 1024, ['Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], dot) + } else { + return asciiCompute(value, 1024, ['Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2) + } +} +function petabytesSec (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1024, ['PBs', 'EBs', 'ZBs', 'YBs'], 1) + } else if (type == -1) { + return asciiCompute(value, 1024, ['PBs', 'EBs', 'ZBs', 'YBs'], dot) + } else { + return asciiCompute(value, 1024, ['PBs', 'EBs', 'ZBs', 'YBs'], 2) + } +} +function petabitsSec (value, index, type = 1, dot) { + if (type == 1) { + return asciiCompute(value, 1024, ['Pbps', 'Ebps', 'Zbps', 'Ybps'], 1) + } else if (type == -1) { + return asciiCompute(value, 1024, ['Pbps', 'Ebps', 'Zbps', 'Ybps'], dot) + } else { + return asciiCompute(value, 1024, ['Pbps', 'Ebps', 'Zbps', 'Ybps'], 2) + } +} +function bitsSecSI (value, index, type = 1, dot) { + const num = value / 8 + if (value < 8) { + return value + 'b' + } + if (num < 1000) { + return num + 'B' + } if (type == 1) { return asciiCompute(value, 1000, ['bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Epps', 'Zpps', 'Ypps'], 1) } else if (type == -1) { @@ -145,7 +337,7 @@ function bitsSec (value, index, type = 1, dot) { return asciiCompute(value, 1000, ['bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Epps', 'Zpps', 'Ypps'], 2) } } -function bytesSec (value, index, type = 1, dot) { +function bytesSecSI (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1000, ['Bs', 'KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1) } else if (type == -1) { @@ -154,7 +346,7 @@ function bytesSec (value, index, type = 1, dot) { return asciiCompute(value, 1000, ['Bs', 'KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2) } } -function kilobytesSec (value, index, type = 1, dot) { +function kilobytesSecSI (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1000, ['KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1) } else if (type == -1) { @@ -163,7 +355,7 @@ function kilobytesSec (value, index, type = 1, dot) { return asciiCompute(value, 1000, ['KBs', 'MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1) } } -function kilobitsSec (value, index, type = 1, dot) { +function kilobitsSecSI (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1000, ['Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1) } else if (type == -1) { @@ -172,7 +364,7 @@ function kilobitsSec (value, index, type = 1, dot) { return asciiCompute(value, 1000, ['Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2) } } -function megabytesSec (value, index, type = 1, dot) { +function megabytesSecSI (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1000, ['MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1) } else if (type == -1) { @@ -181,7 +373,7 @@ function megabytesSec (value, index, type = 1, dot) { return asciiCompute(value, 1000, ['MBs', 'GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2) } } -function megabitsSec (value, index, type = 1, dot) { +function megabitsSecSI (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1000, ['Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1) } else if (type == -1) { @@ -190,7 +382,7 @@ function megabitsSec (value, index, type = 1, dot) { return asciiCompute(value, 1000, ['Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2) } } -function gigabytesSec (value, index, type = 1, dot) { +function gigabytesSecSI (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1000, ['GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1) } else if (type == -1) { @@ -199,7 +391,7 @@ function gigabytesSec (value, index, type = 1, dot) { return asciiCompute(value, 1000, ['GBs', 'TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2) } } -function gigabitsSec (value, index, type = 1, dot) { +function gigabitsSecSI (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1000, ['Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1) } else if (type == -1) { @@ -208,7 +400,7 @@ function gigabitsSec (value, index, type = 1, dot) { return asciiCompute(value, 1000, ['Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2) } } -function terabytesSec (value, index, type = 1, dot) { +function terabytesSecSI (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1000, ['TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 1) } else if (type == -1) { @@ -217,7 +409,7 @@ function terabytesSec (value, index, type = 1, dot) { return asciiCompute(value, 1000, ['TBs', 'PBs', 'EBs', 'ZBs', 'YBs'], 2) } } -function terabitsSec (value, index, type = 1, dot) { +function terabitsSecSI (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1000, ['Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 1) } else if (type == -1) { @@ -226,7 +418,7 @@ function terabitsSec (value, index, type = 1, dot) { return asciiCompute(value, 1000, ['Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'], 2) } } -function petabytesSec (value, index, type = 1, dot) { +function petabytesSecSI (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1000, ['PBs', 'EBs', 'ZBs', 'YBs'], 1) } else if (type == -1) { @@ -235,7 +427,7 @@ function petabytesSec (value, index, type = 1, dot) { return asciiCompute(value, 1000, ['PBs', 'EBs', 'ZBs', 'YBs'], 2) } } -function petabitsSec (value, index, type = 1, dot) { +function petabitsSecSI (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1000, ['Pbps', 'Ebps', 'Zbps', 'Ybps'], 1) } else if (type == -1) { @@ -244,6 +436,7 @@ function petabitsSec (value, index, type = 1, dot) { return asciiCompute(value, 1000, ['Pbps', 'Ebps', 'Zbps', 'Ybps'], 2) } } + function Hertz (value, index, type = 1, dot) { if (type == 1) { return asciiCompute(value, 1000, ['Hz', 'KHz', 'MHz', 'GHz', 'THz', 'PHz', 'EHz', 'ZHz', 'YHz'], 1) @@ -549,37 +742,86 @@ const unitOptions = [ { value: 6, compute: bits, - label: 'bits' + label: 'bits(IEC)', + ascii: 1024 + }, + { + value: 36, + compute: bitsSI, + label: 'bits(SI)', + ascii: 1000 }, { value: 7, compute: bytes, - label: 'bytes' + label: 'bytes(IEC)', + ascii: 1024 + }, + { + value: 37, + compute: bytesSI, + label: 'bytes(SI)', + ascii: 1000 }, { value: 8, compute: kilobytes, - label: 'kilobytes' + label: 'kilobytes(IEC)', + ascii: 1024 + }, + { + value: 38, + compute: kilobytesSI, + label: 'kilobytes(SI)', + ascii: 1000 }, { value: 9, compute: megabytes, - label: 'megabytes' + label: 'megabytes(IEC)', + ascii: 1024 + }, + { + value: 39, + compute: megabytesSI, + label: 'megabytes(SI)', + ascii: 1000 }, { value: 10, compute: gigabytes, - label: 'gigabytes' + label: 'gigabytes(IEC)', + ascii: 1024 + }, + { + value: 40, + compute: gigabytesSI, + label: 'gigabytes(SI)', + ascii: 1000 }, { value: 11, compute: terabytes, - label: 'terabytes' + label: 'terabytes(IEC)', + ascii: 1024 + }, + { + value: 41, + compute: terabytesSI, + label: 'terabytes(SI)', + ascii: 1000 }, { value: 12, compute: petabytes, - label: 'petabytes' + label: 'petabytes(IEC)', + ascii: 1024 + }, + { + value: 42, + compute: petabytesSI, + label: 'petabytes(SI)', + ascii: 1000 } ] }, // Data end @@ -590,67 +832,152 @@ const unitOptions = [ { value: 13, compute: packetsSec, - label: 'packets/sec' + label: 'packets/sec', + ascii: 1024 }, { value: 14, compute: bitsSec, - label: 'bits/sec' + label: 'bits/sec(IEC)', + ascii: 1024 + }, + { + value: 43, + compute: bitsSecSI, + label: 'bits/sec(SI)', + ascii: 1000 }, { value: 15, compute: bytesSec, - label: 'bytes/sec' + label: 'bytes/sec(IEC)', + ascii: 1024 + }, + { + value: 44, + compute: bytesSecSI, + label: 'bytes/sec(SI)', + ascii: 1000 }, { value: 16, compute: kilobytesSec, - label: 'kilobytes/sec' + label: 'kilobytes/sec(IEC)', + ascii: 1024 + }, + { + value: 45, + compute: kilobytesSecSI, + label: 'kilobytes/sec(SI)', + ascii: 1000 }, { value: 17, compute: kilobitsSec, - label: 'kilobits/sec' + label: 'kilobits/sec(IEC)', + ascii: 1024 + }, + { + value: 46, + compute: kilobitsSecSI, + label: 'kilobits/sec(SI)', + ascii: 1000 }, { value: 18, compute: megabytesSec, - label: 'megabytes/sec' + label: 'megabytes/sec(IEC)', + ascii: 1024 + }, + { + value: 47, + compute: megabytesSecSI, + label: 'megabytes/sec(SI)', + ascii: 1000 }, { value: 19, compute: megabitsSec, - label: 'megabits/sec' + label: 'megabits/sec(IEC)', + ascii: 1024 + }, + { + value: 48, + compute: megabitsSecSI, + label: 'megabits/sec(SI)', + ascii: 1000 }, { value: 20, compute: gigabytesSec, - label: 'gigabytes/sec' + label: 'gigabytes/sec(IEC)', + ascii: 1024 + }, + { + value: 49, + compute: gigabytesSecSI, + label: 'gigabytes/sec(SI)', + ascii: 1000 }, { value: 21, compute: gigabitsSec, - label: 'gigabits/sec' + label: 'gigabits/sec(IEC)', + ascii: 1024 + }, + { + value: 50, + compute: gigabitsSec, + label: 'gigabits/sec(SI)', + ascii: 1000 }, { value: 22, compute: terabytesSec, - label: 'terabytes/sec' + label: 'terabytes/sec(IEC)', + ascii: 1024 + }, + { + value: 51, + compute: terabytesSecSI, + label: 'terabytes/sec(SI)', + ascii: 1000 }, { value: 23, compute: terabitsSec, - label: 'terabits/sec' + label: 'terabits/sec(IEC)', + ascii: 1024 + }, + { + value: 52, + compute: terabitsSecSI, + label: 'terabits/sec(SI)', + ascii: 1000 }, { value: 24, compute: petabytesSec, - label: 'petabytes/sec' + label: 'petabytes/sec(IEC)', + ascii: 1024 + }, + { + value: 53, + compute: petabytesSecSI, + label: 'petabytes/sec(SI)', + ascii: 1000 }, { value: 25, compute: petabitsSec, - label: 'petabits/sec' + label: 'petabits/sec(IEC)', + ascii: 1024 + }, + { + value: 54, + compute: petabitsSecSI, + label: 'petabits/sec(SI)', + ascii: 1000 } ] }, // DataRate end @@ -739,7 +1066,7 @@ export default { unitOptions: function () { return unitOptions }, - getUnit: function (index) { + getUnit: function (value) { if (units.length < 1) { unitOptions.forEach((item, index) => { item.children.forEach((n, i) => { @@ -747,13 +1074,15 @@ export default { }) }) } - return units[index - 1] + return units.find(item => item.value === value) }, formatData: function (value, unit) { return this.getUnit(unit).compute(value, null, 2) }, - formatDatas: function (value, type, flow = 'ceil', ascii) { + formatDatas: function (value, unit, flow = 'ceil') { let pow = 0 + const ascii = unit.ascii || 1000 + const type = unit.type if (value < 1 && value != 0) { while (value < 1) { pow++ @@ -767,19 +1096,19 @@ export default { if (type === 'Data') { if (value > 1) { - while (value > 1024) { + while (value > ascii) { pow++ - value = value / 1024 + value = value / ascii } if (flow === 'ceil') { const length = JSON.stringify(Math.ceil(value)).length value = value / Math.pow(10, length - 1) - return Math.ceil(value) * Math.pow(1024, pow) * Math.pow(10, length - 1) + return Math.ceil(value) * Math.pow(ascii, pow) * Math.pow(10, length - 1) } else if (flow === 'floor') { const length = JSON.stringify(Math.floor(value)).length value = value / Math.pow(10, length - 1) - return Math.floor(value) * Math.pow(1024, pow) * Math.pow(10, length - 1) + return Math.floor(value) * Math.pow(ascii, pow) * Math.pow(10, length - 1) } } else { return value @@ -788,19 +1117,19 @@ export default { if (type === 'Misc' || type === 'DataRate') { if (value > 1) { - while (value > 1000) { + while (value > ascii) { pow++ - value = value / 1000 + value = value / ascii } if (flow === 'ceil') { const length = JSON.stringify(Math.ceil(value)).length value = value / Math.pow(10, length - 1) - return Math.ceil(value) * Math.pow(1000, pow) * Math.pow(10, length - 1) + return Math.ceil(value) * Math.pow(ascii, pow) * Math.pow(10, length - 1) } else if (flow === 'floor') { const length = JSON.stringify(Math.floor(value)).length value = value / Math.pow(10, length - 1) - return Math.floor(value) * Math.pow(1000, pow) * Math.pow(10, length - 1) + return Math.floor(value) * Math.pow(ascii, pow) * Math.pow(10, length - 1) } } else { return value @@ -823,7 +1152,10 @@ export default { case 10: return 5 } }, - Interval: function (value, copies, type, interValType) { + Interval: function (value, copies, unit, interValType) { + console.log(unit) + const type = unit.type + const ascii = unit.ascii || 1000 if (!copies) { copies = 1 } @@ -834,12 +1166,12 @@ export default { return value || 1 } - if (value < 1024 && type === 'Data') { + if (value < ascii && type === 'Data') { let interVal = value / copies interVal = !isNaN(interVal) ? interVal : 1 return interVal } - if (value < 1000 && (type === 'DataRate' || type === 'Misc')) { + if (value < ascii && (type === 'DataRate' || type === 'Misc')) { let interVal = value / copies interVal = !isNaN(interVal) ? interVal : 1 return interVal @@ -848,17 +1180,17 @@ export default { let interVal = value / copies let pow = 0 if (interVal) { - while (interVal > 1024) { + while (interVal > ascii) { pow++ - interVal = interVal / 1024 + interVal = interVal / ascii } - interVal = Math.ceil(interVal) * Math.pow(1024, pow) + interVal = Math.ceil(interVal) * Math.pow(ascii, pow) } interVal = !isNaN(interVal) ? interVal : 1 - if (interVal >= 1 && interVal <= 512) { - interVal = 512 - } else if (interVal > 512 && interVal <= 1024) { - interVal = 1024 + if (interVal >= 1 && interVal <= ascii / 2) { + interVal = ascii / 2 + } else if (interVal > 512 && interVal <= ascii) { + interVal = ascii } return interVal } @@ -866,11 +1198,11 @@ export default { let interVal = value / copies let pow = 0 if (interVal) { - while (interVal > 1000) { + while (interVal > ascii) { pow++ - interVal = interVal / 1000 + interVal = interVal / ascii } - interVal = Math.ceil(interVal) * Math.pow(1000, pow) + interVal = Math.ceil(interVal) * Math.pow(ascii, pow) } interVal = !isNaN(interVal) ? interVal : 1 return interVal diff --git a/nezha-fronted/src/components/chart/chartMixin.js b/nezha-fronted/src/components/chart/chartMixin.js index 358b34672..0633bec31 100644 --- a/nezha-fronted/src/components/chart/chartMixin.js +++ b/nezha-fronted/src/components/chart/chartMixin.js @@ -405,7 +405,7 @@ export default { maxValue = Math.abs(minValue) } maxValue = maxValue - minValue - maxValue = chartDataFormat.formatDatas(maxValue, unit.type, 'ceil', unit.ascii) + maxValue = chartDataFormat.formatDatas(maxValue, unit, 'ceil', unit.ascii) let oldValue = maxValue if (maxValue < 0) { oldValue = Math.abs(maxValue) diff --git a/nezha-fronted/src/components/chart/panelChart.vue b/nezha-fronted/src/components/chart/panelChart.vue index 38f062f9a..1b3cec996 100644 --- a/nezha-fronted/src/components/chart/panelChart.vue +++ b/nezha-fronted/src/components/chart/panelChart.vue @@ -436,6 +436,7 @@ export default { if (this.chartInfo.type === 'log') { this.logChartDataFormat() } + console.log(this.$lodash.cloneDeep(this.chartData), '123123') }).catch(res => { // console.info(res) }).finally(() => { diff --git a/nezha-fronted/src/components/chart/renderChart.js b/nezha-fronted/src/components/chart/renderChart.js index a7a1e2673..17f80f1d8 100644 --- a/nezha-fronted/src/components/chart/renderChart.js +++ b/nezha-fronted/src/components/chart/renderChart.js @@ -5,6 +5,7 @@ import { formatScientificNotation } from '@/components/common/js/tools' export default { methods: { renderYAxis (chartDatas, chartInfo, type) { + console.log(chartDatas, '1') let chartData = lodash.cloneDeep(chartDatas) if (type === 'legend') { chartData.forEach(item => { @@ -12,6 +13,7 @@ export default { }) chartData = chartData.map(item => [item]) } + console.log(chartDatas, '2') const decimals = chartInfo.param.decimals || 2 const chartOption = { yAxis: [ @@ -30,9 +32,10 @@ export default { } // 左y轴 const leftData = chartData.filter(item => item[0] && !item[0].yAxisIndex) + console.log(chartDatas, '3') const leftInfo = this.getMinMaxFromData(leftData, chartInfo.unit, chartInfo.param) // - chartOption.yAxis[0].minInterval = chartDataFormat.Interval(leftInfo.maxValue, leftInfo.copies, leftInfo.unit.type, 'min') - chartOption.yAxis[0].maxInterval = chartDataFormat.Interval(leftInfo.maxValue, leftInfo.copies, leftInfo.unit.type, 'max') * Math.ceil(this.series.length / 5) + chartOption.yAxis[0].minInterval = chartDataFormat.Interval(leftInfo.maxValue, leftInfo.copies, leftInfo.unit, 'min') + chartOption.yAxis[0].maxInterval = chartDataFormat.Interval(leftInfo.maxValue, leftInfo.copies, leftInfo.unit, 'max') * Math.ceil(this.series.length / 5) if (chartInfo.param.stack) { chartOption.yAxis[0].maxInterval = chartOption.yAxis[0].maxInterval * (Math.ceil(leftData.length / 5) + 1) } @@ -61,11 +64,16 @@ export default { // 如果全都为右y轴数据 则右y轴显示网格 const unit = chartDataFormat.getUnit(lodash.get(chartInfo, 'param.rightYAxis.unit', 2)) const allRight = this.series.every(item => item.yAxisIndex == 1) + console.log(allRight) chartOption.yAxis[1].splitLine.show = allRight + console.log(chartDatas, '4') const rightData = chartData.filter(item => item[0] && item[0].yAxisIndex) + console.log(chartDatas, '5') + console.log(rightData) const rightInfo = this.getMinMaxFromData(rightData, lodash.get(chartInfo, 'param.rightYAxis.unit', 2), lodash.get(chartInfo, 'param.rightYAxis', {}))// - chartOption.yAxis[1].minInterval = chartDataFormat.Interval(rightInfo.maxValue, rightInfo.copies, rightInfo.unit.type, 'min') - chartOption.yAxis[1].maxInterval = chartDataFormat.Interval(rightInfo.maxValue, rightInfo.copies, rightInfo.unit.type, 'max') * Math.ceil(this.series.length / 5) + console.log(rightInfo) + chartOption.yAxis[1].minInterval = chartDataFormat.Interval(rightInfo.maxValue, rightInfo.copies, rightInfo.unit, 'min') + chartOption.yAxis[1].maxInterval = chartDataFormat.Interval(rightInfo.maxValue, rightInfo.copies, rightInfo.unit, 'max') * Math.ceil(this.series.length / 5) if (chartInfo.param.stack) { chartOption.yAxis[1].maxInterval = chartOption.yAxis[1].maxInterval * (Math.ceil(rightData.length / 5) + 1) } @@ -158,7 +166,7 @@ export default { maxValue = Math.abs(minValue) } maxValue = maxValue - minValue - maxValue = chartDataFormat.formatDatas(maxValue, unit.type, 'ceil', unit.ascii) // 取最大值后 需要对其进行取整 + maxValue = chartDataFormat.formatDatas(maxValue, unit, 'ceil', unit.ascii) // 取最大值后 需要对其进行取整 let oldValue = maxValue let dot = 0 if (oldValue == 1) { diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/endpointTabNew.vue b/nezha-fronted/src/components/common/bottomBox/tabs/endpointTabNew.vue index 6d2e68443..2c3088be2 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/endpointTabNew.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/endpointTabNew.vue @@ -267,7 +267,9 @@ export default { this.object.paramObj.push({ key: '', value: [] }) } this.object.assetName = this.object.asset ? this.object.asset.name : '' + this.object.softwareAssetName = this.object.softwareAsset ? this.object.softwareAsset.name : '' this.object.assetId = this.object.asset ? this.object.asset.id + '' : '' + this.object.softwareAssetId = this.object.softwareAsset ? this.object.softwareAsset.id + '' : '' this.object.projectId = this.object.project.id this.object.moduleId = this.object.module.id this.object.type = this.object.module.type diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/licenseManagementTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/licenseManagementTab.vue index f1aa7d149..d1cf079b6 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/licenseManagementTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/licenseManagementTab.vue @@ -86,6 +86,7 @@ export default { async handler (n) { if (n) { this.searchLabel = {} + this.tableData = [] this.getTableData() } } @@ -152,6 +153,9 @@ export default { this.toTopBtnHandler(this.scrollbarWrap) }) } + } else { + console.log(response) + this.$message.error(response.msg || response.error) } }) }, diff --git a/nezha-fronted/src/components/common/table/asset/licenseMangeTable.vue b/nezha-fronted/src/components/common/table/asset/licenseMangeTable.vue index 868c2899b..aab603f60 100644 --- a/nezha-fronted/src/components/common/table/asset/licenseMangeTable.vue +++ b/nezha-fronted/src/components/common/table/asset/licenseMangeTable.vue @@ -110,13 +110,13 @@ export default { tableTitle: [ // 原始table列 { label: this.$t('licenseMange.product'), - prop: 'typename', + prop: 'name', show: true, width: 350 // sortable: 'custom' }, { label: this.$t('licenseMange.keyType'), - prop: 'name', + prop: 'typename', minWidth: 200, show: true }, { diff --git a/nezha-fronted/src/components/page/dashboard/overview/chart.vue b/nezha-fronted/src/components/page/dashboard/overview/chart.vue index ce840a534..3e4863574 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/chart.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/chart.vue @@ -684,7 +684,7 @@ export default { maxValue = Math.abs(minValue) } maxValue = maxValue - minValue - maxValue = chartDataFormat.formatDatas(maxValue, unit.type, 'ceil', unit.ascii) + maxValue = chartDataFormat.formatDatas(maxValue, unit, 'ceil', unit.ascii) let oldValue = maxValue let dot = 0 if (maxValue == 1) {