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: {
|
|
|
|
|
color: "#9DD3E8"
|
|
|
|
|
},
|
|
|
|
|
barWidth: "20em"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
animation: true
|
|
|
|
|
}
|
|
|
|
|
chart.setOption(option)
|
|
|
|
|
chart.resize()
|
|
|
|
|
}
|
2021-01-25 16:40:49 +08:00
|
|
|
})
|