1
hao
2025-05-20 8e24c6fea30d9b179375ee2893710cdec2443b13
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
 
var dataList = dataType2.data//原始数据
dataList=dataList[2]
console.log(dataList)
 
var nameList=[];
var valueList=[];
 
if(dataList.length==0){//无数据时显示整圆
    nameList.push('None:0');
    valueList.push({
        value:0,
        name:'None:0',
        itemStyle:{
            normal:{
                color:'rgb(0,100,0)'
            }
        }
    })
}else{
    $.each(dataList,function (i, item) {
        nameList.push(item.DEFECT_NAME)
        var arr={}
        arr['value']=item.DEFCODE_QTY
        arr['name']=item.DEFECT_NAME;
 
        valueList.push(arr)
    })
}
 
 
    
 
 
 
 
var dom = document.getElementById("box4");
var myChart = echarts.init(dom);
var app = {};
option = null;
option = {
        tooltip: {
            trigger: 'item',
            formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
            type: 'scroll',
            orient: 'vertical',
            right: 90,
            top: 20,
            bottom: 20,
            data: nameList,
            textStyle:{//图例文字的样式
                color:'#dbdbdb',
                fontSize:14
           },
        },
        series: [
            {
                type: 'pie',
                radius: '65%',
                center: ['50%', '50%'],
                selectedMode: 'single',
                data: valueList,
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
 
if (option && typeof option === "object") {
    myChart.setOption(option, true);
}