<template>
<div>
<div style="height: 28px;margin-bottom: 10px;"/>
<ve-bar :data="chartData" :grid="grid" :title="title" :extend="extend" :settings="chartSettings"/>
</div>
</template>
<script>
// 引入视觉映射组件
import 'echarts/lib/component/visualMap'
import { deviceStaticsByType } from '@/api/gasOverview'
export default {
data() {
this.extend = {
series: {
label: { show: true, position: 'right', color: '#333' }
}
}
this.grid = {
right: 60
}
this.title = {
text: '管网资产统计'
}
this.chartSettings = {
itemStyle: {
'barCategoryGap': 5
},
barWidth: 15,
labelMap: {
'deviceType': '设备类型',
'deviceCount': '设备数量'
},
dimension: ['deviceType'],
metrics: ['deviceCount']
}
return {
chartData: {
columns: ['deviceType', 'deviceCount'],
rows: []
}
}
},
mounted() {
// TODO:待调试真接口
this.fetchData()
this.chartData.rows = [
{ 'deviceType': '气体流量计', 'deviceCount': 20, '下单用户': 1093, '下单率': 0.32 },
{ 'deviceType': '供水泄露监测仪', 'deviceCount': 20, '下单用户': 3230, '下单率': 0.26 },
{ 'deviceType': '气体泄露监测仪', 'deviceCount': 50, '下单用户': 2623, '下单率': 0.76 },
{ 'deviceType': '腐蚀速率监测仪', 'deviceCount': 10, '下单用户': 1423, '下单率': 0.49 }
]
},
methods: {
fetchData() {
const data = {
extra: '0'
}
deviceStaticsByType(data).then(response => {
// this.chartData.rows = response.data
})
}
}
}
</script>