Stockcharts - Adding an offset to avoid drawing points at the edge

落爺英雄遲暮 提交于 2019-12-12 04:28:51

问题


Highcharts and stockcharts, they both provide the options to add some padding at the x axis in order to avoid drawing some values on the edge of the plot area (left or right). According to the doc this is archived by employing the minPadding and maxPadding members of the xAxis property of the configuration object used for constructing the chart... but in practice this is not working for stockcharts. So i wonder how i can achieve this... i leave you with the examples...

var examples
  • Working example for highcharts
  • Not Working example for stockcharts

P.D: Using property min for setting the lowest x value also isn't working.


回答1:


The maxPadding is applied when you not call the setExtremes() method. In the Highstock, we call the setExtremes to set the range on the navigator, as a result padding is ignored.

To achieve your goal, you can define the tickLength parameter and set x param per labels.

yAxis: {
  tickWidth: 1,
  tickLength: 50,
  labels:{
    x: 50
  }
},

Example:

  • http://jsfiddle.net/b6a42kz0/

OP Note: See the comments for updated answer.



来源:https://stackoverflow.com/questions/37015672/stockcharts-adding-an-offset-to-avoid-drawing-points-at-the-edge

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!