var mychart = echarts.init(document.getElementById('echarts1'));
option = {
color: ['#FED14A'],
title:{
show:true,
text: 'xxxx食堂',
x:'center',
padding: 10,
textStyle: { //主标题文本样式{"fontSize": 18,"fontWeight": "bolder","color": "#333"}
fontSize: 15,
fontWeight: 'normal',
},
},
dataZoom: [{ // 控制图表左右滑动
width: '15',
type: 'slider',
show: false, //flase直接隐藏图形
xAxisIndex: [0],
left: 33, //滚动条靠左侧的百分比
bottom: 40,
height: 20,//组件高度
start: 0,//滚动条的起始位置
showDataShadow: false,//是否显示数据阴影
showDetail: false,//是否显示想洗数值信息
end: 50 //滚动条的截止位置(按比例分割你的柱状图x轴长度)
}, {
type: 'inside',
show: true,
xAxisIndex: [0],
start: 0,//滚动条的起始位置
end: 0.25 //滚动条的截止位置(按比例分割你的柱状图x轴长度)
}],
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
axisTick: {
show: false,//隐藏x坐标轴刻度
alignWithLabel: true
},
axisLabel: {
show: true,
textStyle: {
color: '#8B8B8B',
fontSize:'12',
}
},
axisLine: {
lineStyle: {
color: "#8B8B8B",
}
},
}
],
yAxis: [
{
type: 'value',
name:'数量',
splitLine: {
show: false
},
axisTick: {
show: false,//隐藏x坐标轴刻度
alignWithLabel: true
},
axisLabel: {
show: true,
textStyle: {
color: '#8B8B8B',
fontSize:'12',
}
},
axisLine: {
lineStyle: {
color: "#8B8B8B",
}
},
}
],
series: [
{
name: '',
type: 'bar',
barWidth: '15',
showBackground: true,
backgroundStyle: {
color: 'rgba(239, 243, 247, 1)'
},
data: [100, 52, 208, 334, 390, 330, 220, 334, 390, 330, 220, 220]
}
]
};
mychart.setOption(option)
echart左右滑动
最新推荐文章于 2023-11-11 23:08:31 发布