<div id="mainchartnewed"></div>
var mainchartnewed = document.getElementById('mainchartnewed');
var myChartnewed = echarts.init(mainchartnewed);
var optionnewed;
optionnewed = {
grid: {
left: "27",
top: "1",
containLabel: true,
},
xAxis: {
show: false
},
yAxis: [{
type: "category",
offset: 0,
barWidth: 10,
axisLine: {
show: false,
},
data: ['三仁鑫族乡民宿入住优惠', '濂竹乡民宿入住、用餐优惠', '龙洋乡农家乐入住、停车优惠', '按口乡神龙谷景区优惠', '大镇景区、入住、用餐优惠', '金竹镇农家乐入住优惠'],
axisLabel: { //y轴文字的配置
textStyle: {
fontSize: '11',
color: "#fff", //Y轴内容文字颜色
},
},
axisTick: {
show: false,
},
}, ],
series: [{
data: [666, 566, 506, 450, 410, 400],
type: "bar",
// barWidth: 22,
barWidth: 10,
label: {
normal: {
show: true,
position: "right",
},
},
itemStyle: {
//通常情况下:
normal: {
barBorderRadius: 8,
//每个柱子的颜色即为colorList数组里的每一项,如果柱子数目多于colorList的长度,则柱子颜色循环使用该数组
color: function (params) {
var colorList = [
['#072643', '#48b3db'],
['#072643', '#48b3db'],
['#072643', '#48b3db'],
['#072643', '#48b3db'],
['#072643', '#48b3db'],
];
var index = params.dataIndex;
if (params.dataIndex >= colorList.length) {
index = params.dataIndex - colorList.length;
}
return new echarts.graphic.LinearGradient(0, 0, 1, 0,
[{
offset: 0,
color: colorList[index][0]
},
{
offset: 1,
color: colorList[index][1]
}
]);
},
label: {
textStyle: { //数值样式
color: '#6ec8f1',
fontSize: 11
}
}
},
},
}, ],
},
optionnewed && myChartnewed.setOption(optionnewed);