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 + '
' + "" + params[0].seriesName + ' : ' + params[0].value.toLocaleString() + '个
' } }, 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: [], }, ]