4
hao
2025-04-16 c5fb1fbcbb2bf4d511773d348f9ef625855c61fc
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
 
var dataList = dataType1.data//原始数据
dataList=dataList[2]
 
var xAxis=[];
var yAxis1=[];//计划数量
var yAxis2=[];//完成数量
 
$.each(dataList,function (i, item) {
    xAxis.push(item.TASK_NO)
    yAxis1.push(item.PLAN_QTY)
    yAxis2.push(item.COMPLETE_QTY)
})
 
var dom = document.getElementById("box2");
var myChart = echarts.init(dom);
var app = {};
option = null;
var posList = [
    'left', 'right', 'top', 'bottom',
    'inside',
    'insideTop', 'insideLeft', 'insideRight', 'insideBottom',
    'insideTopLeft', 'insideTopRight', 'insideBottomLeft', 'insideBottomRight'
];
 
app.configParameters = {
    rotate: {
        min: -90,
        max: 90
    },
    align: {
        options: {
            left: 'left',
            center: 'center',
            right: 'right'
        }
    },
    verticalAlign: {
        options: {
            top: 'top',
            middle: 'middle',
            bottom: 'bottom'
        }
    },
    position: {
        options: echarts.util.reduce(posList, function (map, pos) {
            map[pos] = pos;
            return map;
        }, {})
    },
    distance: {
        min: 0,
        max: 100
    }
};
 
app.config = {
    rotate: 90,
    align: 'left',
    verticalAlign: 'middle',
    position: 'insideBottom',
    distance: 15,
    onChange: function () {
        var labelOption = {
            normal: {
                rotate: app.config.rotate,
                align: app.config.align,
                verticalAlign: app.config.verticalAlign,
                position: app.config.position,
                distance: app.config.distance
            }
        };
    }
};
 
 
var labelOption = {
    normal: {
        show: true,
        position: app.config.position,
        distance: app.config.distance,
        align: app.config.align,
        verticalAlign: app.config.verticalAlign,
        rotate: app.config.rotate,
        //formatter: '{c}  {name|{a}}',
        formatter: '{c}',
        fontSize: 10,
        rich: {
            name: {
                textBorderColor: '#fff'
            }
        }
    }
};
 
option = {
    color: ['#00fff6', '#006699', '#4cabce', '#e5323e'],
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'shadow'
        }
    },
    
    legend: {
        textStyle:{//图例文字的样式
                color:'#dbdbdb',
                fontSize:10
           },
        data: ['计划数量', '完成数量']
    },
    textStyle:{//图例文字的样式
                color:'#dbdbdb',
                fontSize:14
           },
    calculable: true,
    xAxis: [
        {
            type: 'category',
            axisTick: {show: false},
            data: xAxis
        }
    ],
    yAxis: [
        {
            type: 'value'
        }
    ],
    series: [
        {
            name: '计划数量',
            type: 'bar',
            barGap: 0,
            label: labelOption,
            data: yAxis1
        },
        {
            name: '完成数量',
            type: 'bar',
            label: labelOption,
            data: yAxis2
        }
        /*{
            name: 'Wetland',
            type: 'bar',
            label: labelOption,
            data: [98, 77, 101, 99, 40]
        }*/
    ]
};;
if (option && typeof option === "object") {
    myChart.setOption(option, true);
}