It is currently Thu Apr 24, 2014 8:59 pm Advanced search

Problem with resetting the y-axis tickInterval

Technical support for the Highcharts Stock package

Problem with resetting the y-axis tickInterval

Postby ahukkanen » Fri Feb 17, 2012 8:34 pm

Hello!

I have a client that uses HighStock in their service and they are showing cumulative data on date-range axis. So, their data is basically "you did 1h on date 1/1/2012, 2h on date 1/2/2012, etc." and we're showing this on time axis x-axis being the time.

The data on y-axis is cumulative data, so if we showed range 1/1-1/2, the on 1st would be 1h and on the 2nd it would be 3h.

They have the following requirements for Y-axis display on the left side:
- When there is less than 2 hours of data, you should have minimum tick interval of 15mins
- When there is 2-3 hours of data, you should have minimum tick interval of 30mins
- Otherwise, let highstock decide

So, I've managed to setup this with the options.yAxis.tickInterval variable BUT the problem arises when user hides some of the series showing on the graph by clicking them on the legend.

I've also managed to grab on to the event options.plotOptions.series.events.legendItemClick to re-calculate the tickInterval there but when I set it there, it does not apply to the drawing.

Also, if I check on the chart.event.redraw event what the tickInterval is on the yAxis, it has be overridden by highcharts from the one I previously set in legendItemClick event. Also, if I set it in the chart.event.redraw event again for the yAxis, it is too late because the axis has already been drawn there (as I can see if I temporarily stop the script from proceeding by calling alert() there).

How can I fix this? I don't know even if I'm on the right track here but I've googled/searched the forums/tried our everything and nothing seems to work.

Basically my question: How can I re-set the tickInterval (so that HighStock doesn't re-calculate it by itself) after user has clicked one item on the legend? I've managed to do everything else but this is what I'm strugling with...
ahukkanen
 
Posts: 4
Joined: Fri Feb 17, 2012 8:23 pm

Re: Problem with resetting the y-axis tickInterval

Postby ahukkanen » Sat Feb 18, 2012 1:01 pm

Anyone?
ahukkanen
 
Posts: 4
Joined: Fri Feb 17, 2012 8:23 pm

Re: Problem with resetting the y-axis tickInterval

Postby hfrntt » Wed Feb 22, 2012 9:28 pm

Hi, sorry for late reply. How about using tickPositioner it's a callback function that let's you decide which ticks shows, you can learn more in the doc: http://www.highcharts.com/stock/ref/#yA ... Positioner
Slawek Kolodziej
Highcharts support team
hfrntt
 
Posts: 6394
Joined: Mon Aug 30, 2010 10:41 am

Re: Problem with resetting the y-axis tickInterval

Postby ahukkanen » Fri Feb 24, 2012 3:41 pm

hfrntt wrote:Hi, sorry for late reply. How about using tickPositioner it's a callback function that let's you decide which ticks shows, you can learn more in the doc: http://www.highcharts.com/stock/ref/#yA ... Positioner


Hi, thanks for the answer! Yeah, I noticed that but it seems like too much of overhead for just this task.

I would just like a static setting for the tickInterval that is not overridden at any point. Seems like quite too much if I need to write the whole logic again...


EDIT: I take that back A BIT. I found it quite easy to do this with tickPositioner ONLY on these special cases and otherwise return false when it does the default. Thanks! However, I'd still like if there was an easier solutions to this one.
ahukkanen
 
Posts: 4
Joined: Fri Feb 17, 2012 8:23 pm

Re: Problem with resetting the y-axis tickInterval

Postby ahukkanen » Sat Feb 25, 2012 5:28 pm

By the way in the docs http://www.highcharts.com/stock/ref/#yAxis--tickPositioner, you don't also have it specified that you can "fall back" to highcharts default positioner by returning a false there.

I think this would be an essential addition to the docs.
ahukkanen
 
Posts: 4
Joined: Fri Feb 17, 2012 8:23 pm


Return to Highstock Usage

Who is online

Users browsing this forum: No registered users and 2 guests