behaviordis.vue
3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<template>
<div>
<div class="chart-header-box">
<div class="header-title ">今日事件类型占比</div>
</div>
<div id="eventchart" class="eventchart"></div>
</div>
</template>
<script>
export default {
data() {
return {
illtype: ""
};
},
methods: {
initchart(data) {
var ydata = [];
if(data.length > 0) {
data.map(ele => {
let obj = {
name:ele.event_name,
value:ele.total_num
}
ydata.push(obj)
})
}
var color = [
"#0069FF",
"#3BB7FF",
"#FF9630",
"#FFC62E",
"#87D14B",
"#7460EE",
"#f59a8f",
];
var xdata = [
"拥堵",
"异常停车",
"遗撒",
"行人上路",
"追尾",
"其他",
];
let maychart = this.$echarts.init(document.getElementById("eventchart"));
let option = {
color: color,
legend: {
orient: "vartical",
x: "left",
top: "center",
left: "55%",
bottom: "0%",
data: xdata,
itemWidth: 6,
itemHeight: 8,
itemGap: 10,
/*formatter:function(name){
var oa = option.series[0].data;
var num = oa[0].value + oa[1].value + oa[2].value + oa[3].value+oa[4].value + oa[5].value + oa[6].value + oa[7].value+oa[8].value + oa[9].value ;
for(var i = 0; i < option.series[0].data.length; i++){
if(name==oa[i].name){
return ' '+name + ' | ' + oa[i].value + ' | ' + (oa[i].value/num * 100).toFixed(2) + '%';
}
}
}*/
formatter: function(name) {
return "" + name;
}
},
series: [
{
type: "pie",
clockwise: false, //饼图的扇区是否是顺时针排布
minAngle: 2, //最小的扇区角度(0 ~ 360)
radius: ["50%", "70%"],
center: ["30%", "50%"],
avoidLabelOverlap: false,
itemStyle: {
//图形样式
normal: {
borderColor: "#ffffff",
borderWidth: 1
}
},
label: {
normal: {
show: false,
position: "center",
formatter: "{text|{b}}\n{c} ({d}%)",
rich: {
text: {
color: "#666",
fontSize: 14,
align: "center",
verticalAlign: "middle",
padding: 8
},
value: {
color: "#8693F3",
fontSize: 24,
align: "center",
verticalAlign: "middle"
}
}
},
emphasis: {
show: true,
textStyle: {
fontSize: 14
}
}
},
data: ydata
}
]
};
maychart.setOption(option);
},
getbehaviortype() {
}
},
mounted() {
this.$api.show.getBehaviorType().then(res => {
this.initchart(res.list_data);
})
}
};
</script>
<style lang="stylus" scoped>
.chart-header-box {
height: 3vh;
overflow: hidden;
font-size: 14px;
}
.header-title{
line-height 3vh;
padding-left 5px
}
.eventchart {
height: 22vh;
width: 20vw;
}
.header-label {
font-size: 12px;
line-height: 3vh;
float: left;
}
.header-select {
width: 4.5vw;
margin: 0.2vh 0.5vw 0 0.2vw;
float: left;
}
</style>