下定决心,好好过一天 ~
var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;
option = {
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
grid: { //整张图的大小,距离left,right,bottom的距离
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category', //类目轴
axisTick: {
alignWithLabel: true //在柱体在中间
},
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']//类目标签
},
yAxis: {
type: 'value' //y轴为数值
},
series: [{
barWidth: '60%', //俩柱之间的距离
data: [120, 200, {value:130,itemStyle:{color:'#a051'}}, 80, 70, {value:180,itemStyle:{color:'#f161'}}, 130],
type: 'bar', //柱状图
showBackground: true, //柱状背景
backgroundStyle: { //背景颜色,加透明度
color: 'rgba(180, 180, 180, 0.2)'
}
}]
};
myChart.setOption(option);