如何增加highchart.js图表上x轴标签区域的高度

How do you increase the height of the x-axis labels area on a highchart.js chart?

本文关键字:标签 区域 高度 何增加 增加 js highchart      更新时间:2023-09-26

我有一个由highcharts.js创建的简单折线图。我在x轴(30)上有很多勾号,所以我将交错设置为2,以处理水平重叠的标记。但是,x轴刻度标签的下一行被图表的末尾截断。

无论我把图表做得多高,x轴刻度线标签的下一行都会被切掉。我如何增加这个区域的高度来解决这个问题?或者还有其他方法吗?

month_chart = new Highcharts.Chart({
chart: {
    borderRadius: 0,
    height: chart_height,
    marginRight: 30,
    marginBottom: 25,
    renderTo: 'leads-by-month',
    type: 'line',
},
title: {
    text: 'Past 30 Days',
},
xAxis: {
    categories: [<?php print $bymonth_categories; ?>],
    labels: {
        staggerLines: 2,
    },
},
yAxis: {
    title: {
        text: 'Leads',
        style: {color: '#3d3e41', }
    },
    plotLines: [{
        value: 0,
        width: 1,
        color: '#808080'
    }],
    min: 0,
},
plotOptions: {
    line: {
        color: '#578df1',
        dataLabels: {
            enabled: true,
            color: '#3d3e41',
        },
        enableMouseTracking: false
    }
},
legend: {
    layout: 'vertical',
    align: 'right',
    verticalAlign: 'top',
    x: -100,
    y: 74,
    floating: true,
    borderWidth: 1,
    backgroundColor: '#FFFFFF',
    shadow: true
},
series: [{
    name: '<?php print $organization['name']; ?>',
    data: [<?php print $bymonth_data; ?>]
}]
        });

只需增加marginBottom选项。默认值是70,这对于2行刻度标签来说应该足够了,但您已经将其设置为25,这不是。