var vms = Vue.component("Company-amplify-scslsbfb", {
template: `
`,
props: {
},
data() {
return {
show:false,
typedata:[],
height:460,
text:'设备总数',
active:0,
option:{}
}
},
mounted(){
},
methods: {
openAmplify(){
this.show = true
this.getMeasureDeviceList()
},
closeAmplify(){
this.show = false
},
closeAmplifyAll(e){
if(e.target.className == 'amplify-fixed'){
this.show = false
}
},
//实测实量设备分布
getMeasureDeviceList() {
var that = this
axios({
method: 'post',
url: "/mkl/api/getMeasureDeviceList",
data: {
"deptId":131,
"ledgerType":1
}
}).then(res => {
if(res.data.code == 0) {
that.educationTrainingData = []
var data = res.data.data.list
console.log(data)
for (let i = 0; i < data.length; i++) {
data[i].name = data[i].deviceName
data[i].value = data[i].total
}
that.typedata = data
this.getChartData()
}
})
},
getChartData(){
//品类金额占比 饼图
var chChartPie = echarts.init(this.$refs.warningPieChart);
this.echartPie(chChartPie,this.typedata)
},
echartPie(chChart,chartData){
var that = this
let newPromise = new Promise((resolve) => {
resolve()
})
//然后异步执行echarts的初始化函数
newPromise.then(() => {
var total_datas = 0;
var data = [];
var legendData = [];
var color = ['#4974ff','#52aef7','#6863d7','#1d5d89','#20e6ff','#67feef']
for (let i = 0; i {
return a + b.value;
}, 0);*/
let legendOption = {
top: "center",
orient: "vertical",
icon: "circle",
itemWidth: 24,
itemHeight:24,
itemGap: 24,
textStyle: {
fontSize: 24,
rich: {
name: {
color: "#c3dbfd",
padding: [20, 10, 40, 10],
// align: 'right'
// width: 60
fontSize:24
},
percent: {
color: "#18DB9F",
fontSize: 25,
padding: [0, 10, 0, 10],
// align: 'right'
},
},
},
formatter: function (name) {
let res = chartData.filter((v) => v.name === name);
let percent = total_datas == 0 ?0:(((res[0].value * 100) / total_datas).toFixed(1));
return "{name| " + name + "}\n{percent|" + res[0].value + "}{percent|" + percent + "%}";
},
};
this.option = {
title: {
text: total_datas,
subtext: this.text,
x: "175",
y: "189",
textStyle: {
color: "#0dd2fd",
fontSize: 32,
fontWeight: "bold",
align: "center",
width: "200px",
},
subtextStyle: {
color: "#a5b5f0",
fontSize: 24,
align: "center",
},
},
tooltip: {
show: false,
trigger: 'item',
formatter: "{b}
{c} ({d}%)"
},
legend: [
{
right: 20,
data: legendData,
align: "left",
...legendOption,
},
],
series: [
{
name: "品类金额占比",
type: "pie",
center: ["25%", "50%"],
radius: ["46%", "63%"],
data: data,
label: {
show: false,
},
itemStyle: {
normal: {
borderWidth: 10,
borderColor: "#051a36"
}
},
},
{
name: "外边框",
type: "pie",
clockWise: false, //顺时加载
hoverAnimation: false, //鼠标移入变大
center: ["25%", "50%"],
radius: ["70%", "70%"],
label: {
normal: {
show: false,
},
},
data: [
{
value: 9,
name: "",
itemStyle: {
normal: {
borderWidth: 6,
borderColor: "#152c65",
},
},
},
],
},
],
}
chChart.setOption(this.option);
window.onresize = chChart.resize;
chChart.off('click')
chChart.on('click', function (params) {
for(let i= 0;i