core.plugins.d.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * @typedef { import('./core.controller.js').default } Chart
  3. * @typedef { import('../types/index.js').ChartEvent } ChartEvent
  4. * @typedef { import('../plugins/plugin.tooltip.js').default } Tooltip
  5. */
  6. /**
  7. * @callback filterCallback
  8. * @param {{plugin: object, options: object}} value
  9. * @param {number} [index]
  10. * @param {array} [array]
  11. * @param {object} [thisArg]
  12. * @return {boolean}
  13. */
  14. export default class PluginService {
  15. _init: any[];
  16. /**
  17. * Calls enabled plugins for `chart` on the specified hook and with the given args.
  18. * This method immediately returns as soon as a plugin explicitly returns false. The
  19. * returned value can be used, for instance, to interrupt the current action.
  20. * @param {Chart} chart - The chart instance for which plugins should be called.
  21. * @param {string} hook - The name of the plugin method to call (e.g. 'beforeUpdate').
  22. * @param {object} [args] - Extra arguments to apply to the hook call.
  23. * @param {filterCallback} [filter] - Filtering function for limiting which plugins are notified
  24. * @returns {boolean} false if any of the plugins return false, else returns true.
  25. */
  26. notify(chart: Chart, hook: string, args?: object, filter?: filterCallback): boolean;
  27. /**
  28. * @private
  29. */
  30. private _notify;
  31. invalidate(): void;
  32. _oldCache: {
  33. plugin: any;
  34. options: any;
  35. }[];
  36. _cache: {
  37. plugin: any;
  38. options: any;
  39. }[];
  40. /**
  41. * @param {Chart} chart
  42. * @private
  43. */
  44. private _descriptors;
  45. _createDescriptors(chart: any, all: any): {
  46. plugin: any;
  47. options: any;
  48. }[];
  49. /**
  50. * @param {Chart} chart
  51. * @private
  52. */
  53. private _notifyStateChanges;
  54. }
  55. export type Chart = import('./core.controller.js').default;
  56. export type ChartEvent = import('../types/index.js').ChartEvent;
  57. export type Tooltip = any;
  58. export type filterCallback = (value: {
  59. plugin: object;
  60. options: object;
  61. }, index?: number, array?: any[], thisArg?: object) => boolean;