优化界面

This commit is contained in:
刘祥超
2021-07-21 08:07:46 +08:00
parent d6efb2dd12
commit 8d203a1d7c
25 changed files with 187 additions and 178 deletions

View File

@@ -410,16 +410,24 @@ window.teaweb = {
}
let click = options.click
let bottom = 24
let rotate = 0
let chartBox = document.getElementById(chartId)
if (chartBox == null) {
return
}
let chart = echarts.init(chartBox)
let chart = this.initChart(chartBox)
let result = this.xRotation(chart, values.map(xFunc))
if (result != null) {
bottom = result[0]
rotate = result[1]
}
let option = {
xAxis: {
data: values.map(xFunc),
axisLabel: {
interval: 0
interval: 0,
rotate: rotate
}
},
yAxis: {
@@ -440,7 +448,7 @@ window.teaweb = {
left: 40,
top: 10,
right: 20,
bottom: 24
bottom: bottom
},
series: [
{
@@ -478,7 +486,7 @@ window.teaweb = {
if (chartBox == null) {
return
}
let chart = echarts.init(chartBox)
let chart = this.initChart(chartBox)
let option = {
xAxis: {
data: values.map(xFunc),
@@ -522,6 +530,25 @@ window.teaweb = {
}
chart.setOption(option)
chart.resize()
},
xRotation: function (chart, names) {
let chartWidth = chart.getWidth()
let width = 0
names.forEach(function (name) {
width += name.length * 10
})
if (width <= chartWidth) {
return null
}
return [40, -20]
},
initChart: function (dom) {
let instance = echarts.init(dom)
window.addEventListener("resize", function () {
instance.resize()
})
return instance
}
}
@@ -537,4 +564,4 @@ String.prototype.quoteIP = function () {
return ip
}
return "[" + ip + "]"
}
}