admin管理员组文章数量:1291027
From the highcharts docs : .tickAmount
I can see tickInterval is not avilible for datetime axis, So my question is, is there a workaround to set the number of ticks labels in my xAxis?
I tried to play with it for a while, till now no success.
From the highcharts docs : http://api.highcharts./highstock#xAxis.tickAmount
I can see tickInterval is not avilible for datetime axis, So my question is, is there a workaround to set the number of ticks labels in my xAxis?
I tried to play with it for a while, till now no success.
Share Improve this question edited Jun 28, 2016 at 12:52 apokryfos 40.7k11 gold badges81 silver badges125 bronze badges asked Jun 28, 2016 at 12:39 omriman12omriman12 1,7007 gold badges28 silver badges54 bronze badges 4- You're linking tickAmount, tickInterval does work on datetime axes. – apokryfos Commented Jun 28, 2016 at 12:52
- but i dont want tickInterval... i want tickAmount... i am trying to find a workaround to get his functionality, i found some solution but not optimal – omriman12 Commented Jun 28, 2016 at 13:05
- 1 Easiest way to work around this is get the time difference between earliest/latest in milliseconds and then divide it by the tickAmount and use that as your tickInterval. But do update your question with what you really need, it's still saying that you need tickInterval. – apokryfos Commented Jun 28, 2016 at 13:18
- The tickInterval works well, morever you can use i.e tickPositioner and apply as much ticks as you need. Example: jsfiddle/3p2bfseu – Sebastian Bochan Commented Jun 29, 2016 at 8:33
2 Answers
Reset to default 9This answer is assuming you indeed want tickInterval
and not tickAmount
.
I've successfully used tickInterval
for datetime
axes. It all depends on how much time you want between each tick mark.
For example, if you want to display a tick for each calendar year, you could do the following:
tickInterval: 1000 * 60 * 60 * 24 * 365
// milliseconds * seconds * minutes * hours * days = 1 year
I hope this is helpful!
the value like this.dataMin / this.dataMax is seconds,not milliseconds
tickPositioner: function(){
var positions = [] ;
var min = Math.floor(this.dataMin) ;
var max = Math.floor(this.dataMax) ;
var gap = (max - min) / (60*60*24*30) ;
var d = new Date(this.min*1000);
for(i=0;i < (gap+1);i++){
var d2 = new Date( d.getFullYear()+'-'+(d.getMonth()+1+i)+'-01');
positions.push(d2.getTime()/1000);
}
return positions;
}
本文标签: javascriptHighchartsTickInterval with datetime valuesStack Overflow
版权声明:本文标题:javascript - Highcharts - TickInterval with datetime values - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741514909a2382826.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论