|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <div class="chart-title">bug严重程度分布直方图</div>
|
|
|
+ <div class="chart-title">bug严重程度分布饼状图</div>
|
|
|
<div id="bugLevelChart" :class="className" :style="{height:height,width:width}" />
|
|
|
</div>
|
|
|
</template>
|
|
@@ -10,8 +10,6 @@ import echarts from 'echarts' // echarts theme
|
|
|
import resize from './mixins/resize'
|
|
|
require('echarts/theme/macarons')
|
|
|
|
|
|
-const animationDuration = 6000
|
|
|
-
|
|
|
export default {
|
|
|
mixins: [resize],
|
|
|
props: {
|
|
@@ -28,27 +26,27 @@ export default {
|
|
|
default: '300px'
|
|
|
},
|
|
|
counts: {
|
|
|
- type: Array,
|
|
|
+ type: Object,
|
|
|
default: function () {
|
|
|
- return [0, 0, 0, 0, 0]
|
|
|
+ return {}
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
counts: {
|
|
|
handler (nv, ov) {
|
|
|
- this.YValue = nv
|
|
|
+ this.datas = []
|
|
|
+ const names = Object.keys(nv)
|
|
|
+ names.forEach(name => this.datas.push({'name': name, 'value': nv[name]}))
|
|
|
this.initChart()
|
|
|
},
|
|
|
- deep: true,
|
|
|
- immediate: true
|
|
|
+ deep: true
|
|
|
}
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
chart: null,
|
|
|
- XData: ['致命', '严重', '一般', '轻微', '建议'],
|
|
|
- YValue: [0, 0, 0, 0, 0]
|
|
|
+ datas: []
|
|
|
}
|
|
|
},
|
|
|
mounted () {
|
|
@@ -63,52 +61,39 @@ export default {
|
|
|
this.chart.dispose()
|
|
|
this.chart = null
|
|
|
},
|
|
|
- methods:{
|
|
|
+ methods: {
|
|
|
initChart () {
|
|
|
this.chart = echarts.init(document.getElementById('bugLevelChart'), 'macarons')
|
|
|
this.chart.setOption({
|
|
|
- // title:{
|
|
|
- // text:'众测成绩分布直方图',
|
|
|
- // padding:20
|
|
|
- // },
|
|
|
- tooltip: {
|
|
|
- trigger: 'axis',
|
|
|
- axisPointer: { // 坐标轴指示器,坐标轴触发有效
|
|
|
- type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
|
|
|
- }
|
|
|
+ legend: {
|
|
|
+ orient: 'vertical',
|
|
|
+ left: 'left'
|
|
|
},
|
|
|
- grid: {
|
|
|
- top: 10,
|
|
|
- left: '2%',
|
|
|
- right: '2%',
|
|
|
- bottom: '3%',
|
|
|
- containLabel: true
|
|
|
- },
|
|
|
- xAxis: [{
|
|
|
- name: '严重程度',
|
|
|
- type: 'category',
|
|
|
- data: Array.from(this.XData),
|
|
|
- axisTick: {
|
|
|
- alignWithLabel: true
|
|
|
- },
|
|
|
- axisLabel: {interval: 0}
|
|
|
- }],
|
|
|
- yAxis: [{
|
|
|
- name: '数量',
|
|
|
- type: 'value',
|
|
|
- axisTick: {
|
|
|
- show: false
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ // name: '访问来源',
|
|
|
+ type: 'pie', // 设置图表类型为饼图
|
|
|
+ radius: '55%', // 饼图的半径,外半径为可视区尺寸(容器高宽中较小一项)的 55% 长度。
|
|
|
+ // roseType: 'angle',
|
|
|
+ data: this.datas,
|
|
|
+ label: {
|
|
|
+ normal: {
|
|
|
+ position: 'inner',
|
|
|
+ show: true,
|
|
|
+ formatter: '{d}%'
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }],
|
|
|
- series: [{
|
|
|
- type: 'bar',
|
|
|
- stack: 'vistors',
|
|
|
- barWidth: '60%',
|
|
|
- data: Array.from(this.YValue),
|
|
|
- animationDuration
|
|
|
- }]
|
|
|
+ ]
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
+<style>
|
|
|
+.chart-title{
|
|
|
+ padding: 5px 8px 15px 8px;
|
|
|
+ font-weight: bold;
|
|
|
+ font-size: 18px;
|
|
|
+}
|
|
|
+</style>
|