<template>
<div id="main" style="width: 100%;height: 348px;"></div>
</template>
methods: {
fetchData(){
let _this = this
home.queryHomeInfo().then(res=>{
if(res.messageCode === '0000'){
let data = res.data.res
let datax = []
let dataY = []
let echartArr = res.data.res.map
for(let i in echartArr){
datax.push(i)
dataY.push(echartArr[i])
}
this.$nextTick(function(){
this.drawLine(datax,dataY)
})
}
})
},
drawLine(datax,dataY){
var myChart = this.$echarts.init(document.getElementById( 'main'))
var option = {
color:['#409EFF'],
grid:{
left: '8%',
top: '4%',
width: '86%',
height: '76%'
},
xAxis: {
type: 'category',
axisLabel: {
interval: 'auto',
rotate: 15,
textstyle: {
fontsize: 12,
}
},
data: datax
},
yAxis: {
type: 'value'
},
series: [{
data: dataY,
type: 'bar',
barwidth: '30px',
}]
}
myChart.setOption(option)
}
}