rangeChanging: Function

Sets the rangeChanging Event handler for StockChart. rangeChanging is triggered before the range of StockChart is changed / updated upon zooming / panning through slider or through charts or by selecting the range buttons or by changing the value in the inputfields of range selector.

When event is triggered, a parameter that contains event related data is passed to the assigned event handler. Parameter includes source, minimum and maximum value corresponding to the event.


Note
  • rangeChanging is triggered only when the range of the StockChart is changed manually using mouse/pointer (zooming/panning/sliding) and it doesn’t trigger when range of StockChart is set programmatically.

Default: null
Options: rangeChanging: function(e) { alert ( “Event Source: ” + e.source) }

var stockChart = new CanvasJS.StockChart("container",
{
 .
 .
 rangeChanging: function(e) { 
    console.log("Source: "+ e.source + ,
      "Minimum: "+ e.minimum,
      "Maximum: "+ e.maximum )
    },
 .
 . 
});
stockChart.render();

Event Object

e: {
      source, // "chart", "buttons" , "inputFields", "navigator"
      index, // sets only if source is chart or buttons else null
      minimum,
      maximum,
      stockChart
}



Try it Yourself by Editing the Code below.




If you have any questions, please feel free to ask in our forums.