Highstock Y轴标签重叠海誓山盟

问题描述:

请查看此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 
    }); 
} 

});​ 

你可以控制的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

谢谢你是一个很大的帮助 - 得到它的工作。 –