2013-05-13 114 views
0

我使用this插件来创建图表。如何保持y轴标签在HighChart插头的线之间

我有这样的:enter image description here

,这就是我想要的:

enter image description here

我怎样才能做到这一点?任何参考?

这里是我此图表代码

$(function() 
{ 
    $('#container').highcharts({ 
     chart: { 
      type: 'column', 
      margin: [ 100] 
     }, 
     title: { 
      text: 'World\'s largest cities per 2008' 
     }, 
     xAxis: { 
      categories: personNameList, 
      labels: { 
       rotation: -45, 
       align: 'right', 
       style: { 
        fontSize: '13px', 
        fontFamily: 'Verdana, sans-serif' 
       } 
      } 
     }, 
     yAxis: { 
      min: 0, 
      title: { 
       text: 'Population (millions)' 
      } 
     }, 
     legend: { 
      enabled: false 
     }, 
     tooltip: { 
      formatter: function() { 
       return '<b>'+ this.x +'</b><br/>'+ 
        'Population in 2008: '+ Highcharts.numberFormat(this.y, 1) + 
        ' millions'; 
      } 
     }, 
     series: [{ 
      name: 'Population', 
      data: dataList, 
      dataLabels: { 
       enabled: true, 
       rotation: -90, 
       color: '#FFFFFF', 
       align: 'right', 
       x: 4, 
       y: 10, 
       style: { 
        fontSize: '13px', 
        fontFamily: 'Verdana, sans-serif' 
       } 
      } 
     }] 
    }); 
}); 
+0

你能提供HTML代码吗?或者在http://jsfiddle.net/上发布。 – 2013-05-13 09:01:01

+0

@JEES:这里是小提琴:HTTP://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/column-rotated-labels/ – 2013-05-13 09:50:22

+0

嗯,我看到两个相同的图像,所以有什么区别? – 2013-05-13 12:22:43

回答

0

这里是实现这个的一种方法:

在你labels对象中的highcharts对象,设定Y位置,并摆脱“0”是这样的:

labels: { 
    formatter: function() { 
     if (this.value != 0) { 
      return this.value; 
     } else { 
      return ''; 
     } 
    }, 
    y: 40 
} 

利用该性质,可以改变位置[向上或向下],每个标签被定位。唯一不利的是,y轴上的0应该被移除。

Here is a fiddle