core.layouts.d.ts 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. declare namespace _default {
  2. /**
  3. * Register a box to a chart.
  4. * A box is simply a reference to an object that requires layout. eg. Scales, Legend, Title.
  5. * @param {Chart} chart - the chart to use
  6. * @param {LayoutItem} item - the item to add to be laid out
  7. */
  8. function addBox(chart: import("./core.controller.js").default, item: LayoutItem): void;
  9. /**
  10. * Remove a layoutItem from a chart
  11. * @param {Chart} chart - the chart to remove the box from
  12. * @param {LayoutItem} layoutItem - the item to remove from the layout
  13. */
  14. function removeBox(chart: import("./core.controller.js").default, layoutItem: LayoutItem): void;
  15. /**
  16. * Sets (or updates) options on the given `item`.
  17. * @param {Chart} chart - the chart in which the item lives (or will be added to)
  18. * @param {LayoutItem} item - the item to configure with the given options
  19. * @param {object} options - the new item options.
  20. */
  21. function configure(chart: import("./core.controller.js").default, item: LayoutItem, options: any): void;
  22. /**
  23. * Fits boxes of the given chart into the given size by having each box measure itself
  24. * then running a fitting algorithm
  25. * @param {Chart} chart - the chart
  26. * @param {number} width - the width to fit into
  27. * @param {number} height - the height to fit into
  28. * @param {number} minPadding - minimum padding required for each side of chart area
  29. */
  30. function update(chart: import("./core.controller.js").default, width: number, height: number, minPadding: number): void;
  31. }
  32. export default _default;
  33. export type Chart = import('./core.controller.js').default;
  34. export type LayoutItem = {
  35. /**
  36. * - The position of the item in the chart layout. Possible values are
  37. * 'left', 'top', 'right', 'bottom', and 'chartArea'
  38. */
  39. position: string;
  40. /**
  41. * - The weight used to sort the item. Higher weights are further away from the chart area
  42. */
  43. weight: number;
  44. /**
  45. * - if true, and the item is horizontal, then push vertical boxes down
  46. */
  47. fullSize: boolean;
  48. /**
  49. * - returns true if the layout item is horizontal (ie. top or bottom)
  50. */
  51. isHorizontal: Function;
  52. /**
  53. * - Takes two parameters: width and height. Returns size of item
  54. */
  55. update: Function;
  56. /**
  57. * - Draws the element
  58. */
  59. draw: Function;
  60. /**
  61. * - Returns an object with padding on the edges
  62. */
  63. getPadding?: Function;
  64. /**
  65. * - Width of item. Must be valid after update()
  66. */
  67. width: number;
  68. /**
  69. * - Height of item. Must be valid after update()
  70. */
  71. height: number;
  72. /**
  73. * - Left edge of the item. Set by layout system and cannot be used in update
  74. */
  75. left: number;
  76. /**
  77. * - Top edge of the item. Set by layout system and cannot be used in update
  78. */
  79. top: number;
  80. /**
  81. * - Right edge of the item. Set by layout system and cannot be used in update
  82. */
  83. right: number;
  84. /**
  85. * - Bottom edge of the item. Set by layout system and cannot be used in update
  86. */
  87. bottom: number;
  88. };