Highcharts y轴标签浮动问题

时间:2015-01-02 09:19:00

标签: javascript jquery highcharts

我在我的项目中使用Highcharts,并且在条形图中的y轴标签变得不对齐时遇到问题。请使用jsFiddle中的给定代码来查看问题。

JavaScript代码:

$(function () {
$('#container').highcharts({
    chart: {
        type: 'bar'
    },
    title: {
        text: 'Historic World Population by Region'
    },
    subtitle: {
        text: 'Source: Wikipedia.org'
    },
    xAxis: {
        categories: ['Africa', 'America', 'Asia', 'Europe', 'Oceania'],
        title: {
            text: null
        }
    },
    yAxis: [{
        min: 0,
        title: {
            text: 'Population (millions)',
            align: 'high'                
        },
        labels: {
            overflow: 'justify'
        },
        opposite: true
    },
    {
        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: [{
        yAxis: 0,
        name: 'Year 1800',
        data: [107, 31, 635, 203, 2]
    }, {
        yAxis: 0,
        name: 'Year 1900',
        data: [133, 156, 947, 408, 6]
    }, {
        yAxis: 1,
        name: 'Year 2008',
        data: [973, 914, 4054, 732, 34]
    }]
});});

Html代码:

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="chartContainer" style="min-width: 310px; max-width: 800px; height: 600px; margin: 0 auto"></div>

0 个答案:

没有答案