core.interaction.d.ts 5.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. declare namespace _default {
  2. export { evaluateInteractionItems };
  3. export namespace modes {
  4. /**
  5. * Returns items at the same index. If the options.intersect parameter is true, we only return items if we intersect something
  6. * If the options.intersect mode is false, we find the nearest item and return the items at the same index as that item
  7. * @function Chart.Interaction.modes.index
  8. * @since v2.4.0
  9. * @param {Chart} chart - the chart we are returning items from
  10. * @param {Event} e - the event we are find things at
  11. * @param {InteractionOptions} options - options to use
  12. * @param {boolean} [useFinalPosition] - use final element position (animation target)
  13. * @return {InteractionItem[]} - items that are found
  14. */
  15. function index(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
  16. /**
  17. * Returns items in the same dataset. If the options.intersect parameter is true, we only return items if we intersect something
  18. * If the options.intersect is false, we find the nearest item and return the items in that dataset
  19. * @function Chart.Interaction.modes.dataset
  20. * @param {Chart} chart - the chart we are returning items from
  21. * @param {Event} e - the event we are find things at
  22. * @param {InteractionOptions} options - options to use
  23. * @param {boolean} [useFinalPosition] - use final element position (animation target)
  24. * @return {InteractionItem[]} - items that are found
  25. */
  26. function dataset(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
  27. /**
  28. * Point mode returns all elements that hit test based on the event position
  29. * of the event
  30. * @function Chart.Interaction.modes.intersect
  31. * @param {Chart} chart - the chart we are returning items from
  32. * @param {Event} e - the event we are find things at
  33. * @param {InteractionOptions} options - options to use
  34. * @param {boolean} [useFinalPosition] - use final element position (animation target)
  35. * @return {InteractionItem[]} - items that are found
  36. */
  37. function point(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
  38. /**
  39. * nearest mode returns the element closest to the point
  40. * @function Chart.Interaction.modes.intersect
  41. * @param {Chart} chart - the chart we are returning items from
  42. * @param {Event} e - the event we are find things at
  43. * @param {InteractionOptions} options - options to use
  44. * @param {boolean} [useFinalPosition] - use final element position (animation target)
  45. * @return {InteractionItem[]} - items that are found
  46. */
  47. function nearest(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
  48. /**
  49. * x mode returns the elements that hit-test at the current x coordinate
  50. * @function Chart.Interaction.modes.x
  51. * @param {Chart} chart - the chart we are returning items from
  52. * @param {Event} e - the event we are find things at
  53. * @param {InteractionOptions} options - options to use
  54. * @param {boolean} [useFinalPosition] - use final element position (animation target)
  55. * @return {InteractionItem[]} - items that are found
  56. */
  57. function x(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
  58. /**
  59. * y mode returns the elements that hit-test at the current y coordinate
  60. * @function Chart.Interaction.modes.y
  61. * @param {Chart} chart - the chart we are returning items from
  62. * @param {Event} e - the event we are find things at
  63. * @param {InteractionOptions} options - options to use
  64. * @param {boolean} [useFinalPosition] - use final element position (animation target)
  65. * @return {InteractionItem[]} - items that are found
  66. */
  67. function y(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
  68. }
  69. }
  70. export default _default;
  71. export type Chart = import('./core.controller.js').default;
  72. export type ChartEvent = import('../types/index.js').ChartEvent;
  73. export type InteractionOptions = {
  74. axis?: string;
  75. intersect?: boolean;
  76. includeInvisible?: boolean;
  77. };
  78. export type InteractionItem = {
  79. datasetIndex: number;
  80. index: number;
  81. element: import('./core.element.js').default;
  82. };
  83. export type Point = import('../types/index.js').Point;
  84. /**
  85. * Helper function to select candidate elements for interaction
  86. * @param {Chart} chart - the chart
  87. * @param {string} axis - the axis mode. x|y|xy|r
  88. * @param {Point} position - the point to be nearest to, in relative coordinates
  89. * @param {function} handler - the callback to execute for each visible item
  90. * @param {boolean} [intersect] - consider intersecting items
  91. */
  92. declare function evaluateInteractionItems(chart: Chart, axis: string, position: Point, handler: Function, intersect?: boolean): void;