2013-05-13 49 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