使用echarts做柱状图,需要在X轴上分两行显示时间和日期,如下图所示,应该如何操作?
可以参考这篇文章
https://blog.csdn.net/z291493823/article/details/105053565
这是我做过的中效果,可以看下这个配置能否满足你的需求
双x轴实现
以下是双轴配置
xAxis: [
{
type: 'category',
data: [8, 9, 10, 11, 12, 13],//x轴数据(x轴第一行)
axisLabel: {
color: '#00000080',
fontWeight: 500,
},
axisLine: {
lineStyle: {
color: '#979797',
},
},
axisTick: {
length: 10,
},
},
{
type: 'category',
position: 'bottom',
axisLine: {
show: false,
},
axisPointer: {
show: false,
},
data: [ // x轴分组的数据(x轴第二行)
{
value: `W32 2022/08/01-08/07`,
textStyle: {
fontSize: 12,
lineHeight: 60,
color: '#000',
fontWeight: 500,
},
},
{
value: `W33 2022/08/08-08/014`,
textStyle: {
fontSize: 12,
lineHeight: 60,
color: '#000',
fontWeight: 500,
},
},
],
axisTick: {
length: 24,
},
splitArea: {
show: true,
areaStyle: {
color: ['#115DFF0D', '#FF1D140D'],
},
},
},
]