Swapping in preset date ranges on ng-click
-
So the first thing I need to say is "I LOVE the new MANGO dashboard builder!"
Often there is a requirement for several watchlists on one dashboard and it is cool to control all of them from a single parameter. Even cooler is the ability to synchronize all the charts on the dashboard to the same time frame. I want to share this programming technique because it is so cool. Basically you create as many <ma-date-range-picker> objects as you need PRESETS. With each button's on-click behaviour set the dateBar. to and dateBar.from to the variable set as the to and from within each <ma-date-range-picker> settings.
So as example create an object <ma-date-range-picker id="SET_PREVIOUS_MONTH" from="prevmonth_from" to="prevmonth_to" preset="PREVIOUS_MONTH" update-interval="5 seconds" ng-show="false"> </ma-date-range-picker>When the user clicks the prev month button
the ng-click="dateBar.to = prevmonth_to; dateBar.from = prevmonth_from; dateBar.rollupIntervals='1'; dateBar.rollupIntervalPeriod='DAYS'"and
Brilliantly all the watchlist charts which have dateBar assigned as to and from will automatically update to this period... very cool indeed.
Thanks team :)