ansel0926
2022-05-16 e6c25766b95dfd792009423a5972cd43cbd7c3ce
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
var cost = [1, 2, 3,4, 5]
var totalCost = [ 5,5, 5, 5,5]//比例综合
var grade = ['类别1','类别2','类别3','类别4','类别5', ]
var myColor = ['#21BF57','#56D0E3',  '#1089E7', '#F8B448','#F57474', ];
var data = {
    grade: grade,
    cost: cost,
    totalCost: totalCost,
};
barTemplate2 = {
    title:{
        text:"输入标题",
        textStyle:{
            color:'#fff',
            fontStyle:'normal',
            fontWeight:'bold',
            fontFamily:'sans-serif',
         fontSize:12
        }
    },
    grid: {
        top:20,
        left:0,
        bottom:0,
        right:30,
        containLabel: true
    },
    textStyle:{
        fontFamily: "Microsoft YaHei",
        fontSize: 9,
        fontStyle: "normal",
        fontWeight: "normal",
        color: '#fff'
    },
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'none',
            textStyle: {
                color: '#fff',
                fontSize:9
            },
        },
        formatter: function(params) {
            return params[0].name + '<br/>' +
                "<span style='display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:rgba(36,207,233,0.9)'></span>" +
                params[0].seriesName + ' : ' + params[0].value.toLocaleString() + '个<br/>'
        }
    },
    xAxis: {
        show: false,
    },
    yAxis: [{
        type: 'category',
        inverse: true,
        axisLabel: {
            show: true,
            color: '#4DCEF8',
            fontSize: 9,
        },
        axisTick: {
            show: false,
        },
        axisLine: {
            show: false,
        },
        data: data.grade
    },{
        type: 'category',
        inverse: true,
        axisTick: 'none',
        axisLine: 'none',
        show: true,
        axisLabel: {
            color: '#4DCEF8',
            fontSize: 9,
            formatter: function(value) {
                return value.toLocaleString()+ '个';
            },
        },
        data: data.cost
    }],
    series: [{
        name:'值',
        type: 'bar',
        barGap: '-150%',
        barWidth: '10%',
        itemStyle: {
            normal: {
                borderColor: '#1089E7',
                borderWidth: 1,
                barBorderRadius: 15,
                color: '#1089E7',
            },
        },
        max: 1,
        // label: {
        //     normal: {
        //         show: true,
        //         position: 'inside',
        //         formatter: '{c}'
        //     }
        // },
        labelLine: {
            show: true,
        },
        z: 2,
        data: data.cost,
    },{
        type: 'bar',
        // label: {
        //     normal: {
        //         show: true,
        //         position: 'right',
        //         color: '#fff',
        //         fontSize: 10,
        //         formatter: 
        //         function(param) {
        //             return data.cost[param.dataIndex];
        //         },
        //     }
        // },
        barWidth: '20%',
        itemStyle: {
            normal: {
                borderColor: '#4DCEF8',
                borderWidth: 1,
                barBorderRadius: 15,
                color: 'rgba(102, 102, 102,0)'
            },
        },
        z: 1,
        data: data.totalCost,
    }]
}
 
barTemplate2Series=[{
    name:'',
    type: 'bar',
    barGap: '-150%',
    barWidth: '10%',
    itemStyle: {
        normal: {
            borderColor: '#1089E7',
            borderWidth: 1,
            barBorderRadius: 15,
            color: '#1089E7',
        },
    },
    // itemStyle: {
    //     normal: {
    //         barBorderRadius: 16,
    //         color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
    //             offset: 0,
    //             color: 'rgb(57,89,255,1)'
    //         }, {
    //             offset: 1,
    //             color: 'rgb(46,200,207,1)'
    //         }]),
    //     },
    // },
    max: 1,
    labelLine: {
        show: true,
    },
    z: 2,
    data: [],
    },{
    type: 'bar',
    barWidth: '20%',
    itemStyle: {
        normal: {
            borderColor: '#4DCEF8',
            borderWidth: 1,
            barBorderRadius: 15,
            color: 'rgba(102, 102, 102,0)'
        },
    },
    z: 1,
    data: [],
}, ]