Files
EdgeAdmin/web/views/@default/servers/server/stat/providers.js

65 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-01-25 16:40:49 +08:00
Tea.context(function () {
2021-06-08 11:22:44 +08:00
this.$delay(function () {
let that = this
2021-01-25 16:40:49 +08:00
2021-06-08 11:22:44 +08:00
let axis = teaweb.countAxis(this.providerStats, function (v) {
return v.count
})
this.reloadChart("provider-chart", "运营商", this.providerStats, function (v) {
return v.provider.name
}, function (args) {
2021-06-08 15:20:59 +08:00
return that.providerStats[args.dataIndex].provider.name + ": " + teaweb.formatNumber(that.providerStats[args.dataIndex].count)
}, axis)
2021-06-08 11:22:44 +08:00
})
2021-01-25 16:40:49 +08:00
2021-06-08 15:20:59 +08:00
this.reloadChart = function (chartId, name, stats, xFunc, tooltipFunc, axis) {
2021-06-08 11:22:44 +08:00
let chartBox = document.getElementById(chartId)
if (chartBox == null) {
return
}
2021-07-21 08:07:46 +08:00
let chart = teaweb.initChart(chartBox)
2021-06-08 11:22:44 +08:00
let option = {
xAxis: {
data: stats.map(xFunc),
axisLabel: {
interval: 0
}
},
yAxis: {
axisLabel: {
formatter: function (value) {
2021-06-08 15:20:59 +08:00
return value + axis.unit
2021-06-08 11:22:44 +08:00
}
}
},
tooltip: {
show: true,
trigger: "item",
formatter: tooltipFunc
},
grid: {
left: 40,
top: 10,
right: 20,
bottom: 20
},
series: [
{
name: name,
type: "bar",
data: stats.map(function (v) {
2021-06-08 15:20:59 +08:00
return v.count / axis.divider;
2021-06-08 11:22:44 +08:00
}),
itemStyle: {
2022-04-22 09:58:25 +08:00
color: teaweb.DefaultChartColor
2021-06-08 11:22:44 +08:00
},
barWidth: "20em"
}
],
animation: true
}
chart.setOption(option)
chart.resize()
}
2021-01-25 16:40:49 +08:00
})