Navigation.js 1.6 KB

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