let chartBase64 = myChart.getDataURL()
return chartBase64
drawLine (type) {
var that = this
window.addEventListener('resize', this.drawLine)
let myChart = this.$echarts.init(this.$refs.echarts)
if (type == 0) {
var option = {
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
grid: {
left: '2%',
right: '4%',
bottom: '5%',
top: '8%',
containLabel: true
},
legend: {
data: ['预警次数'],
right: '5%',
top: 12,
textStyle: {
color: '#fff',
fontSize: 18
},
itemWidth: 20,
itemHeight: 20
},
xAxis: {
type: 'category',
data: that.xdata,
axisLine: {
lineStyle: {
color: '#274076'
}
},
axisTick: {
show: false
},
axisLabel: {
textStyle: {
fontFamily: 'Microsoft YaHei',
color: 'rgba(143, 178, 204, 1)',
fontSize: 17
},
rotate: 40
},
},
yAxis: {
type: 'value',
name: '次数',
nameTextStyle: {
fontSize: 17,
color: 'rgba(143, 178, 204, 1)',
padding: [0, 0, 0, -50]
},
axisLine: {
show: true,
lineStyle: {
color: '#274077'
}
},
axisTick: {
show: false
},
splitLine: {
show: true,
lineStyle: {
color: '#274077',
}
},
axisLabel: {
textStyle: {
fontFamily: 'Microsoft YaHei',
color: 'rgba(143, 178, 204, 1)',
fontSize: 18
}
}
},
series: [{
name: '预警次数',
type: 'bar',
barWidth: '30',
itemStyle: {
normal: {
color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: 'rgba(61, 212, 242, 1)'
}, {
offset: 1,
color: 'rgba(89, 89, 255, 1)'
}]),
barBorderRadius: [20, 20, 0, 0]
},
},
data: that.ydata
}]
}
myChart.clear()
myChart.resize()
myChart.setOption(option)
}
if (type == 1) {
let chartBase64 = myChart.getDataURL()
return chartBase64
}
},