Commit 5b88c815 by liuguorong93

工作犬专业方向统计 改为饼图

parent afc23b74
...@@ -36,7 +36,10 @@ ...@@ -36,7 +36,10 @@
</div> </div>
<!-- 工作犬专业方向统计 --> <!-- 工作犬专业方向统计 -->
<div style="margin-top: 20px"> <div style="margin-top: 20px">
<dogMajor :qzCount="qzCount"></dogMajor> <dogMajor
:qzCount="qzCount"
v-if="qzCount.major"
></dogMajor>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
</template> </template>
<script> <script>
import * as echarts from "echarts";
export default { export default {
props: { props: {
qzCount: { qzCount: {
...@@ -23,119 +22,106 @@ export default { ...@@ -23,119 +22,106 @@ export default {
}, },
data() { data() {
return { return {
offsetZero: [ myChart: null,
"rgba(78, 187, 255, 1)",
"rgba(241, 166, 54, 1)", colorDatas: [
"rgba(255, 102, 78, 1)", "#5DECE8",
"rgba(46, 223, 209, 1)", "#F57B92",
"rgba(255, 172, 39, 1)", "#F58B4E",
], "#FBDD62",
offsetOne: [ "#A29BF0",
"rgba(134, 223, 255, 0.05)", "#FFEC97",
"rgba(241, 166, 54, 0.05)", "#398DDB",
"rgba(255, 102, 78, 0.05)", "#3EBEC2",
"rgba(46, 223, 209, 0.05)", "#5D52D6",
"rgba(255, 172, 39, 0.05)", "#1D51D8",
"#B52AB5",
"#6EF9AA",
"#3BC568",
"#F25555",
"#B4FB62",
"#FFBB01",
], ],
seriesDatas: [],
}; };
}, },
mounted() {
this.getData();
},
methods: { methods: {
xyrzyRender(_name, _value) { getData() {
// console.log("_name, _value", _name, _value); for (let key in this.qzCount.major) {
//案件性质发案分析 this.seriesDatas.push({
// debugger; name: key,
// 基于准备好的dom,初始化echarts实例 value: this.qzCount.major[key],
let myChart = this.$echarts.init(document.getElementById("dogMajors")); });
// 绘制图表 }
myChart.setOption({ setTimeout(() => {
// color: ["#4db7f8", "#fa654f", "#ffc64e"], this.drawEcharts();
xAxis: { }, 1);
type: "category", },
data: _name, drawEcharts() {
axisLabel: { if (this.myChart) this.myChart.dispose();
color: "#B8BDC6", this.myChart = this.$echarts.init(document.getElementById("dogMajors"));
fontSize: "12px",
show: true, let options = {
interval: 0, color: this.colorDatas,
// rotate: '-60px', tooltip: {
margin: 6, trigger: "item",
}, backgroundColor: "#FFFFFF",
axisLine: { padding: [12, 8],
lineStyle: { extraCssText:
color: "#2C4E86", "box-shadow: 0px 8px 24px -8px rgba(0,0,0,0.08), 0px 16px 24px 0px rgba(0,0,0,0.08), 0px 8px 24px 0px rgba(0,0,0,0.08);",
}, textStyle: {
color: "#242424",
fontSize: 12,
}, },
}, },
yAxis: { legend: {
type: "value", type: "scroll",
splitLine: { orient: "horizontal",
show: true, left: "center",
lineStyle: { align: "left",
type: "dashed", bottom: 30,
color: "#2C4E86", itemWidth: 10,
}, itemHeight: 10,
}, itemGap: 10,
axisLine: { textStyle: {
show: false, fontSize: 12,
color: "#fff",
fontFamily: "Microsoft YaHei",
}, },
axisLabel: { width: 250,
color: "#d7e7ff00", pageIconColor: "#fff",
pageIconInactiveColor: "#fff",
pageTextStyle: {
color: "#fff",
}, },
}, },
series: [ series: [
{ {
barWidth: 24, name: "工作犬专业方向统计",
data: _value, type: "pie",
type: "bar", radius: "60%",
itemStyle: {}, center: ["50%", "42%"],
label: { label: {
formatter: "{c}", show: false,
show: true, },
position: "top", emphasis: {
fontWeight: "bolder", scale: false,
fontSize: "12",
color: "#fff",
}, },
itemStyle: {
borderColor: "#fff",
borderWidth: 2,
},
data: this.seriesDatas,
}, },
], ],
}); };
myChart.resize({ this.myChart.setOption(options);
width: $("#dogMajors").width(),
height: $("#dogMajors").height(),
});
myChart.off("click");
myChart.on("click", function (params) {});
}, },
}, },
mounted() {
setTimeout(() => {
let _name = [],
_value = [];
let index = 0;
for (let item in this.qzCount.major) {
_name.push(item);
_value.push({
name: item,
value: this.qzCount.major[item],
itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: this.offsetZero[index],
},
{
offset: 1,
color: this.offsetOne[index],
},
]),
},
});
index++;
}
this.xyrzyRender(_name, _value);
}, 1000);
},
}; };
</script> </script>
......
...@@ -109,8 +109,8 @@ export default { ...@@ -109,8 +109,8 @@ export default {
fontSize: 12, fontSize: 12,
color: "#5E5E5E", color: "#5E5E5E",
fontFamily: "Microsoft YaHei", fontFamily: "Microsoft YaHei",
// interval: 0, interval: 0,
// rotate: 30, rotate: 30,
}, },
axisTick: { axisTick: {
show: false, show: false,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment