I have used the rangechange event like you suggested. Here is the
code:
google.visualization.events.addListener(chart, 'rangechange',
function(event) {
var range = chart.getVisibleChartRange();
var start = range['start'];
var end = range['end'];
var rangeDiff = end - start;
if( rangeDiff > 3600000 ) {
data1.setColumns([0,4,5,6]);
} else {
data1.setColumns([0,1,2,3]);
}
chart.draw(data1,{'zoomStartTime' : start,
'zoomEndTime' : end});
});
Let me give the scenario which has the problem. If I clicked on '1h' ,
data1 now has columns set as [0,1,2,3] which is the minutes data. And
now, if I click on 'Max', within the minutes data, it zooms out to the
maximum and the chart displays lots of data points. What I am
expecting is that it fires the 'rangechange' event and picks up the
hourly data and displays less number of data points.
The reason I am switching between mins vs hourly data is to achieve
something similar to google finance's behavior of changing the volume
from '2min' to '30min', '1d', etc depending on the zoom range
selected(1d, 1m, 3m)..If you know a better way to achieve this
behavior I would appreciate it.
Thanks.
On Oct 27, 5:46 am, asgallant <[email protected]> wrote:
> You can hook the 'rangechange' event to capture changes in zoom level.
> Something like this should work:
>
> google.visualization.events.addListener(chart, 'rangechange', function () {
> if (chart.getVisibleRange().end - chart.getVisibleRange().start >
> 3600000) {
> // if the zoom range is > 1 hour (3.6 million microseconds), hide
> minutes and show hours
> }
> else {
> // if the zoom range is < 1 hour, hide hours and show minutes
> }
>
>
>
>
>
>
>
> });
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.