John Meyer John Meyer - 1 month ago 20
Javascript Question

Trying to get the date range boundaries of a google daterangefilter

I've hooked up an event listener to notify me when the values on the slider change. However, I'm not able to read them.

google.visualization.events.addListener(dfHistorical,'statechange',function(e) {

alert("Min value: " + dfHistorical.getOption('minValue') + " Max value: " + dfHistorical.getOption('maxValue'));

});

Answer

the 'state' property of the DateRangeFilter has four properties...

lowValue - The lower extent of the selected range, inclusive.

highValue - The higher extent of the selected range, inclusive.

lowThumbAtMinimum - Whether the lower thumb of the slider is locked at the minimum allowed range. If set, overrides lowValue.

highThumbAtMaximum - Whether the higher thumb of the slider is locked at the maximum allowed range. If set, overrides highValue.

to access the properties, use the getState() method

DateRangeFilter.getState().lowValue

e.g.

google.visualization.events.addListener(dfHistorical, 'statechange', function () {
  var valHigh = dfHistorical.getState().highValue;
  var valLow = dfHistorical.getState().lowValue;

  console.log(valLow, valHigh);
});
Comments