如何为长日期字符串增加轴下方的空间?

uci*_*ass 2 javascript echarts

底部 Xaxis 字段的 Echarts 切割

请查看图片,让我知道是否可以选择增加此图像的边距/边框以适应长日期/时间字符串。

Ian*_*ong 6

你可以设置grid选项可以实现这个目标:

grid.containLabel = true
Run Code Online (Sandbox Code Playgroud)

如果你愿意,还可以设置:

grid.bottom = 0
Run Code Online (Sandbox Code Playgroud)

例如:

    option = {
    xAxis: {
        type: 'category',
        axisLabel: {
            interval: 1,
            rotate: 45
        },
        data: ['2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04', '2018-06-07 14:27:04']
    },
    yAxis: {
        type: 'value'
    },
    grid: {
        bottom: 0,
        containLabel: true
    },
    series: [{
        data: [820, 932, 901, 934, 1290, 1330, 1320, 820, 932, 901, 934, 1290, 1330, 1320, 820, 932, 901, 934, 1290, 1330, 1320, 820, 932, 901, 934, 1290, 1330, 1320,820, 932, 901, 934, 1290, 1330, 1320],
        type: 'line',
        smooth: true
    }]
};
Run Code Online (Sandbox Code Playgroud)

结果: 在此处输入图片说明