数据看板使用字节代替比特

This commit is contained in:
GoEdgeLab
2021-07-11 11:09:41 +08:00
parent 8d1965d997
commit ae96474efa
4 changed files with 42 additions and 17 deletions

View File

@@ -35,19 +35,32 @@ Tea.context(function () {
}
this.reloadHourlyTrafficChart = function () {
let axis = teaweb.bytesAxis(this.hourlyTrafficStats, function (v) {
return v.bytes
})
let chartBox = document.getElementById("hourly-traffic-chart-box")
let chart = echarts.init(chartBox)
let that = this
let option = {
xAxis: {
data: this.hourlyTrafficStats.map(function (v) {
return v.hour;
})
},
yAxis: {},
yAxis: {
axisLabel: {
formatter: function (v) {
return v + axis.unit
}
}
},
tooltip: {
show: true,
trigger: "item",
formatter: "{c} GB"
formatter: function (args) {
let index = args.dataIndex
return that.hourlyTrafficStats[index].hour + "时:" + teaweb.formatBytes(that.hourlyTrafficStats[index].bytes)
}
},
grid: {
left: 40,
@@ -59,7 +72,7 @@ Tea.context(function () {
name: "流量",
type: "line",
data: this.hourlyTrafficStats.map(function (v) {
return v.count;
return v.bytes / axis.divider;
}),
itemStyle: {
color: "#9DD3E8"
@@ -85,19 +98,32 @@ Tea.context(function () {
}
this.reloadDailyTrafficChart = function () {
let axis = teaweb.bytesAxis(this.dailyTrafficStats, function (v) {
return v.bytes
})
let chartBox = document.getElementById("daily-traffic-chart-box")
let chart = echarts.init(chartBox)
let that = this
let option = {
xAxis: {
data: this.dailyTrafficStats.map(function (v) {
return v.day;
})
},
yAxis: {},
yAxis: {
axisLabel: {
formatter: function (v) {
return v + axis.unit
}
}
},
tooltip: {
show: true,
trigger: "item",
formatter: "{c} GB"
formatter: function (args) {
let index = args.dataIndex
return that.dailyTrafficStats[index].day + "" + teaweb.formatBytes(that.dailyTrafficStats[index].bytes)
}
},
grid: {
left: 40,
@@ -109,7 +135,7 @@ Tea.context(function () {
name: "流量",
type: "line",
data: this.dailyTrafficStats.map(function (v) {
return v.count;
return v.bytes / axis.divider;
}),
itemStyle: {
color: "#9DD3E8"