如何防止Highcharts截断类别?

时间:2014-10-03 02:31:09

标签: highcharts

如果空间太紧,轴标签会被截断。我处理变量类别,所以我更喜欢让它们重叠而不是消失。

实施例: http://jsfiddle.net/z1axtk31/

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Historic World Population by Region'
        },
        subtitle: {
            text: 'Source: Wikipedia.org'
        },
        xAxis: {
            categories: ['Sub-saharan Africa', 'North America', 'South America', 'East Asia', 'Middle East', 'Europe', 'Oceania', 'Ancapistan', 'North Africa', 'Mordor', 'Atlantis'],
            title: {
                text: null
            }
        },
        yAxis: {
            min: 0,
            title: {
                text: 'Population (millions)',
                align: 'high'
            },
            labels: {
                overflow: 'justify'
            }
        },
        tooltip: {
            valueSuffix: ' millions'
        },
        plotOptions: {
            bar: {
                dataLabels: {
                    enabled: true
                }
            }
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'top',
            x: -40,
            y: 100,
            floating: true,
            borderWidth: 1,
            backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
            shadow: true
        },
        credits: {
            enabled: false
        },
        series: [{
            name: 'Year 1800',
            data: [107, 31, 635, 203, 2, 45, 23, 201, 50, 89, 210]
        }/*, {
            name: 'Year 1900',
            data: [133, 156, 947, 408, 6, 45, 23, 166, 50, 20, 110]
        }, {
            name: 'Year 2008',
            data: [973, 914, 4054, 732, 34, 45, 23, 20, 50, 133, 100]
        }*/]
    });
});

1 个答案:

答案 0 :(得分:4)

只需设置:

xAxis: {
    labels: {
        step: 1
    }
}

Example