2012-11-22 38 views
0

請查看此fiddle我正在建設的圖表。Highstock Y軸標籤重疊海誓山盟

我的問題是:

  • Y軸標籤和百分比重疊。是否可以將它們對齊,以便獲得綠色百分比,標籤「兩」,然後是紅色百分比,最後是標籤「三」?如果你看看另一個fiddle它肯定看起來更整潔。
  • Highstock在圖形網格內顯示其標籤。這些可以推到外面,使標籤看起來更像我的第二個JSFiddle顯示它們的方式嗎?

的第一個問題,我解決的是最重要的,第二我可以,如果我要活:

chart = new Highcharts.StockChart({ 
     chart: { 
      renderTo: 'container', 
      zoomType: 'xy' 
     }, 

     rangeSelector: { 
      selected: 4 
     }, 

     yAxis: [{ 
      title: { 
       text: 'One', 
       style: { 
        color: 'blue' 
       } 
      }, 
      labels: { 
       formatter: function() { 
        return (this.value > 0 ? '+' : '') + this.value + '%'; 
       } 
      } 
     }, 
     { 

      title: { 
       text: 'Two', 
       style: { 
        color: 'green' 
       } 
      }, 
      labels: { 
       formatter: function() { 
        return this.value + '%'; 
       }, 
       style: { 
        color: 'green' 
       } 
      }, 
    opposite: true 
     }, 
{ 

      title: { 
       text: 'THree', 
       style: { 
        color: 'red' 
       } 
      }, 
      labels: { 
       formatter: function() { 
        return this.value + '%'; 
       }, 
       style: { 
        color: 'red' 
       } 
      }, 
    opposite: true 
     } 
     ], 

     plotOptions: { 
      series: { 
       compare: 'percent' 
      } 
     }, 

     tooltip: { 
      pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>', 
      valueDecimals: 2 
     }, 

     series: seriesOptions 
    }); 
} 

});​ 

回答

6

你可以控制的yAxis.labels.xyAxis.title.margin組合的位置。

例如,第一Y軸:

 { 
      title: { 
       text: 'One', 
       style: { 
        color: 'blue' 
       }, 
       margin: 25 //push out 25 pixels 
      }, 
      labels: { 
       formatter: function() { 
        return (this.value > 0 ? '+' : '') + this.value + '%'; 
       }, 
       x: -20 //push out 20 pixels 
      } 
     } 

更新撥弄here

enter image description here

+0

謝謝你是一個很大的幫助 - 得到它的工作。 –