Zoom hook

528 views
Skip to first unread message

tradetree

unread,
Jan 1, 2012, 3:11:00 PM1/1/12
to jqplot-users
I have a large data set and in order to reduce the latency I do not
want to transfer all the data from the server at once, but I want to
do the following:
1) Draw a chart with only a few points, lets say 10. This is easy and
just a regular chart plot.
2) Upon zoom, I want to fetch the data for the zoomed area, then draw
it at higher resolution. This I don't know how to do.

I already have the ability to send via php the different data sets
based on the date range I want to plot, and number of points. What I
don't have is the ability in jqplot to redraw the chart with updated
data based on the zoom level. I have read many posts and there is
nothing I have found.

My best guess is that I need a hook, and that hook needs to be able to
give me the x-axis range that was zoomed. Then I would replot the
chart with the updated data. There is the
"$.jqplot.preDrawSeriesHooks" that may serve this function, but I
don't see any way to get at the x-axis zoom range?

Here is an example case of what I'd like to do: If I have market data
for every day of the year, like the S&P for each day. The first chart
would plot 12 points, from Jan 2011 to Jan 2012, one per month. Then
someone zooms into June 2011, and then I transfer the data for every
day of June and plot just that one month.

Thanks for the great chart package!

tony

unread,
Jan 2, 2012, 3:17:09 AM1/2/12
to jqplot-users
The values you are looking for are newmax and newmin. I have for the
moment added some jQuery to cursor.js to feed these values to my input
fields. I have a refresh button to update but hope (I am learning
jQuery as I go) to activate an automatic reload of the chart when
these values change.

Cheers

Tony

tradetree

unread,
Jan 2, 2012, 11:48:25 PM1/2/12
to jqplot-users
I think we are trying to do similar things. From what I gather you
also do not have a complete solution. I looked at cursor.js and I
agree that I need newmax and newmin, but I also need to know when they
change. For this I believe I need a callback "hook". Looking at the
code there does not appear to be a hook for the zoom case, at least
not around "handleZoomMove". However, it is possible that
"preDrawHooks" or "preDrawSeriesHooks" may work. I just don't know if
I'm on the right track. It may be that I'd need to use
"postDrawHooks", so I would allow the drawing of the chart at low
resolution, then right away load my high-resolution data use the
newmax, newmin, then replot.

But I then only know the chart completed drawing, not that a zoom
event took place. That would put me in an infinite loop where I
"replot" then hit the callback of "postDrawHooks" then do it all over
again. I have to know it is a new zoom event so I fetch data once.

tony

unread,
Jan 5, 2012, 9:41:34 AM1/5/12
to jqplot...@googlegroups.com
An update on this:

We have a function called by postDrawHooks to grab the min and max values because we are zooming the controller and the target plot at the same time. 

What we did notice is that postDrawHooks is not the last thing that happens on plot.redraw or that plot.redraw takes a while to run and we have had to cheat a little to give whatever is happening time to finish before calling our function. This will eventually become a modification to the jqplot code which we will send to Chris when we have it working.

Cheers

Tony
Reply all
Reply to author
Forward
0 new messages