admin 管理员组

文章数量: 1086019

Here is the test :

$(function() {
var chart;
$(document).ready(function() {
    chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container',
            type: 'column'
        },
        title: {
            text: 'Long xAxis legends',
        },
        xAxis: {
            categories: ['a long category name', 'another long category name', 'a very long category name', 'Thats enormous', 'short', 'a long category name', 'another long category name', 'a very long category name', 'Thats enormous', 'short'],
            labels:{
               rotation:90,
               y:100,
            },
        },
        series: [
            {
            name: 'Some values',
            data: [10, 20, 53, 2.51, 1.35, 10, 20, 53, 2.51, 1.35],
            },
            {
            name: 'Other values',
            data: [22.40, 0.15, 40, 10.73, 13, 22, 15, 40.11, 10, 13],
            }
        ],
        legend: {
            layout: 'vertical',
            align: 'top',
            verticalAlign: 'top',
            x: 50,
            y: 65,
            borderWidth: 0,
            margin: 30
        },
    });
});

}); /

I would like to have a chart with vertical xAxis labels with a top alignment.

In my real case, i would have many more data, so i can't do otherwise than a rotation.

I have tried the xAxis parameters : .labels

I thought the align would do the trick but when i add it to the rotation parameter, the chart is broken.

Thanks in advance.

Here is the test :

$(function() {
var chart;
$(document).ready(function() {
    chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container',
            type: 'column'
        },
        title: {
            text: 'Long xAxis legends',
        },
        xAxis: {
            categories: ['a long category name', 'another long category name', 'a very long category name', 'Thats enormous', 'short', 'a long category name', 'another long category name', 'a very long category name', 'Thats enormous', 'short'],
            labels:{
               rotation:90,
               y:100,
            },
        },
        series: [
            {
            name: 'Some values',
            data: [10, 20, 53, 2.51, 1.35, 10, 20, 53, 2.51, 1.35],
            },
            {
            name: 'Other values',
            data: [22.40, 0.15, 40, 10.73, 13, 22, 15, 40.11, 10, 13],
            }
        ],
        legend: {
            layout: 'vertical',
            align: 'top',
            verticalAlign: 'top',
            x: 50,
            y: 65,
            borderWidth: 0,
            margin: 30
        },
    });
});

}); http://jsfiddle/Y5Qhm/1/

I would like to have a chart with vertical xAxis labels with a top alignment.

In my real case, i would have many more data, so i can't do otherwise than a rotation.

I have tried the xAxis parameters : http://api.highcharts./highcharts#xAxis.labels

I thought the align would do the trick but when i add it to the rotation parameter, the chart is broken.

Thanks in advance.

Share Improve this question asked Jun 12, 2013 at 15:49 OverdoseOverdose 5851 gold badge9 silver badges32 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

Use:

align: 'top'

like this:

labels:{
   rotation:90,
   align: 'top'
   //y:100,
},

jsFiddle: http://jsfiddle/Y5Qhm/2/

本文标签: javascriptHighchartsHow to fix labels to the top when xAxis rotation is 90176Stack Overflow