平常的引入:
會出現x軸文字數據部分隱藏,如下:
但我們一般是不希望隱藏的,如圖:
解決方法:設置axisLabel屬性
// xAxis的屬性,設置x軸文本不隱藏,同理yAxis也有
axisLabel: {
interval: 0, // 坐標軸刻度標簽的顯示間隔
rotate: 40 // 標簽傾斜的角度
}
option = {
color: ['#3398DB'],
tooltip: {
trigger: 'axis',
axisPointer: { // 坐標軸指示器,坐標軸觸發有效
type: 'shadow' // 默認為直線,可選為:'line' | 'shadow'
}
},
legend: {
data: ['訪客數']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
data: ['1頁', '2頁', '3頁', '4頁', '5頁', '6-10頁', '11-20頁', '20+頁'],
// xAxis的屬性,設置x軸文本不隱藏,同理yAxis也有
axisLabel: {
interval: 0, // 坐標軸刻度標簽的顯示間隔
rotate: 40 // 標簽傾斜的角度
}
},
yAxis: {
type: 'value'
},
series: [{
name: '訪客數',
data: [0.7, 0.2, 0.8, 0.3, 0.4, 1, 0.5, 0.5],
type: 'bar',
barWidth: '80%',
showBackground: true,
backgroundStyle: {
color: 'rgba(220, 220, 220, 0.8)' // 剩余部分背景圖
}
}]
}