|
|
@ -1,5 +1,5 @@
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div class="dpiePanel">
|
|
|
|
<div class="dpiePanel" id="dpieWrap">
|
|
|
|
<div class="dpieLegend">
|
|
|
|
<div class="dpieLegend">
|
|
|
|
<div class="dpieRow" v-for="item in data" :key="item.name">
|
|
|
|
<div class="dpieRow" v-for="item in data" :key="item.name">
|
|
|
|
<div class="flex-center">
|
|
|
|
<div class="flex-center">
|
|
|
@ -13,7 +13,13 @@
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="flex-center" style="flex: 1">
|
|
|
|
<div class="flex-center" style="flex: 1">
|
|
|
|
<div class="dpiebg">
|
|
|
|
<div
|
|
|
|
|
|
|
|
class="dpiebg"
|
|
|
|
|
|
|
|
:style="{
|
|
|
|
|
|
|
|
height: parseInt(viewH) + 'px',
|
|
|
|
|
|
|
|
width: 2 * viewH + 'px',
|
|
|
|
|
|
|
|
}"
|
|
|
|
|
|
|
|
>
|
|
|
|
<div ref="dpieWrapRef" class="dpieWrap"></div>
|
|
|
|
<div ref="dpieWrapRef" class="dpieWrap"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
@ -25,6 +31,7 @@ import "echarts-gl";
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
data: [
|
|
|
|
data: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "竞技体育用枪",
|
|
|
|
name: "竞技体育用枪",
|
|
|
@ -49,20 +56,34 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
total: 1,
|
|
|
|
total: 1,
|
|
|
|
|
|
|
|
viewH: 1,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {},
|
|
|
|
mounted() {
|
|
|
|
mounted() {
|
|
|
|
this.total = 1;
|
|
|
|
this.total = 1;
|
|
|
|
for (let i = 0; i < this.data.length; i++) {
|
|
|
|
for (let i = 0; i < this.data.length; i++) {
|
|
|
|
this.total += this.data[i].value;
|
|
|
|
this.total += this.data[i].value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let temp = this.getHeight();
|
|
|
|
|
|
|
|
let height = parseInt(temp / 4);
|
|
|
|
|
|
|
|
this.viewH = 2 * height;
|
|
|
|
|
|
|
|
console.log(height);
|
|
|
|
|
|
|
|
this.fontSize = 12;
|
|
|
|
|
|
|
|
if (height < 30) {
|
|
|
|
|
|
|
|
this.fontSize = 8;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (height > 40) {
|
|
|
|
|
|
|
|
this.fontSize = 14;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
this.setOption();
|
|
|
|
this.setOption();
|
|
|
|
|
|
|
|
}, 500);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
setOption() {
|
|
|
|
setOption() {
|
|
|
|
let optionsData = this.data;
|
|
|
|
|
|
|
|
let hoveredIndex = "";
|
|
|
|
|
|
|
|
let chartDom = this.$refs["dpieWrapRef"];
|
|
|
|
let chartDom = this.$refs["dpieWrapRef"];
|
|
|
|
let myChart = echarts.init(chartDom);
|
|
|
|
let myChart = echarts.init(chartDom);
|
|
|
|
const getPie3D = (pieData, internalDiameterRatio) => {
|
|
|
|
const getPie3D = (pieData, internalDiameterRatio) => {
|
|
|
@ -276,6 +297,10 @@ export default {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
option && myChart.setOption(option);
|
|
|
|
option && myChart.setOption(option);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
getHeight() {
|
|
|
|
|
|
|
|
let div = document.getElementById("dpieWrap");
|
|
|
|
|
|
|
|
return div.clientHeight;
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
watch: {
|
|
|
|
chartObj: {
|
|
|
|
chartObj: {
|
|
|
@ -295,8 +320,8 @@ export default {
|
|
|
|
height: 100%;
|
|
|
|
height: 100%;
|
|
|
|
.dpieLegend {
|
|
|
|
.dpieLegend {
|
|
|
|
position: absolute;
|
|
|
|
position: absolute;
|
|
|
|
top: 100px;
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
bottom: vw(10);
|
|
|
|
flex-direction: column;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: center;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
align-items: center;
|
|
|
@ -305,7 +330,6 @@ export default {
|
|
|
|
display: flex;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
justify-content: space-between;
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
|
|
|
width: 150px;
|
|
|
|
width: 150px;
|
|
|
|
//background-color: rgba(108, 128, 151, 0.1);
|
|
|
|
//background-color: rgba(108, 128, 151, 0.1);
|
|
|
|
.dpieIcon {
|
|
|
|
.dpieIcon {
|
|
|
@ -327,8 +351,8 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.dpieWrap {
|
|
|
|
.dpieWrap {
|
|
|
|
width: 160px;
|
|
|
|
width: 100%;
|
|
|
|
height: 80px;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.dpiebg {
|
|
|
|
.dpiebg {
|
|
|
|
margin-top: vw(14);
|
|
|
|
margin-top: vw(14);
|
|
|
|