//材价统计柱形图
priceBarOption = {
title: {
text: '材价统计',
// x: 15,
// y: 15,
textStyle: {
fontSize: '14',
fontWeight: 'normal',
color: '#333'
}
},
tooltip: {
trigger: 'item',
padding: 10,
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
},
formatter: '{b}<br/>{a}:{c}'
},
grid: {
x: 45,
x2: 25,
y: 60,
y2: 40,
borderWidth: '1',
borderColor:'#E0EBFF'
},
xAxis: [{
type: 'category',
// name: '价格',
nameTextStyle: {
color: '#999'
},
splitLine: false,
axisLabel: {
textStyle: {
color: '#999'
}
},
axisTick: {
show:true,
lineStyle: {
width: 2,
color: '#999'
}
},
axisLine: {
textStyle: {
color: '#999'
},
lineStyle: {
width: 2,
color: '#999'
}
},
data: function () {
var list = [];
for (var i = 1;i<=12;i++){
list.push(i + "月");
}
return list;
}()
}],
yAxis: [{
type: 'value',
// name: '工时',
nameTextStyle: {
color: '#999'
},
splitLine: {
lineStyle: {
color: ['#E0EBFF'],
width: 1
}
},
splitArea:{ //背景区域分隔
show:true
},
axisLine: {
lineStyle: {
width: 2,
color: '#999'
}
},
axisLabel: {
textStyle: {
color: '#999'
}
},
axisTick: {
show: false
}
}],
series: [{
name: '工时',
type: 'bar',
itemStyle: {
normal: {
barBorderRadius: [8, 8, 2, 2],
barBorderColor: 'rgba(0,0,0,0)',
areaStyle: {
type: 'default'
},
//每个柱子的颜色为一组,循环
color: function(params) {
var colorItem = ['#C1232B','#B5C334'];
var currentItem=0;
var colorList=[];
for(var i=0;i<params.series.data.length;i++){
colorList.push(colorItem[currentItem]);
if(currentItem==0){
currentItem=1;
}
else {
currentItem=0;
}
}
return colorList[params.dataIndex]
}
},
emphasis: { //鼠标悬停时
barBorderRadius: [8, 8, 2, 2]
}
},
barMaxWidth: 15,
data: [200,350,460,1500,2000,1800,1300,800,900,1000,1100,700,600]
}]
};
附图: