当图表没有标题时,隐藏带有偏移的highcharts y轴标签

时间:2016-05-24 07:43:41

标签: highcharts

我使用highcharts来显示stackbars图。 我将y轴标签显示在y轴的顶部,这就是我将其偏移设置为-10的原因。但是,当没有显示图表的标题时,我看不到轴标签。

Here's an example with graph title and axis title

Here's an example without graph title and from some reason axis title disappears

以下是我如何设置yAxis标签:

 yAxis: {
        lineWidth: 2,
        tickWidth: 1,
        title: {
            align: 'high',
            offset: 0,
            text: 'Rainfall (mm)',
            rotation: 0,
            y: -20
        }
    },

1 个答案:

答案 0 :(得分:2)

updated Link

$(function () {
$('#container').highcharts({

    chart: {
        type: 'column',
        margin: [70, 0]
    },
    title: {
        text: ''
    },
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    yAxis: {
        lineWidth: 1,
        tickWidth: 1,
        title: {
            align: 'high',
            offset: 0,
            text: 'Rainfall (mm)',
            rotation: 0,
            y: -10
        }
    },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }]

});
});

保证金:[70,0]