navigation.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * (c) 2010-2018 Paweł Fus
  3. *
  4. * License: www.highcharts.com/license
  5. */
  6. 'use strict';
  7. var chartNavigation = {
  8. /**
  9. * Initializes `chart.navigation` object which delegates `update()` methods
  10. * to all other common classes (used in exporting and navigationBindings).
  11. *
  12. * @private
  13. *
  14. * @param {Highcharts.Chart} chart
  15. * The chart instance.
  16. */
  17. initUpdate: function (chart) {
  18. if (!chart.navigation) {
  19. chart.navigation = {
  20. updates: [],
  21. update: function (options, redraw) {
  22. this.updates.forEach(function (updateConfig) {
  23. updateConfig.update.call(
  24. updateConfig.context,
  25. options,
  26. redraw
  27. );
  28. });
  29. }
  30. };
  31. }
  32. },
  33. /**
  34. * Registers an `update()` method in the `chart.navigation` object.
  35. *
  36. * @private
  37. *
  38. * @param {function} update
  39. * The `update()` method that will be called in `chart.update()`.
  40. *
  41. * @param {Highcharts.Chart} chart
  42. * The chart instance. `update()` will use that as a context
  43. * (`this`).
  44. */
  45. addUpdate: function (update, chart) {
  46. if (!chart.navigation) {
  47. this.initUpdate(chart);
  48. }
  49. chart.navigation.updates.push({
  50. update: update,
  51. context: chart
  52. });
  53. }
  54. };
  55. export default chartNavigation;