config/Options/data/selection.ts

  1. /**
  2. * Copyright (c) 2017 ~ present NAVER Corp.
  3. * billboard.js project is licensed under the MIT license
  4. */
  5. /**
  6. * data.selection config options
  7. */
  8. export default {
  9. /**
  10. * Set data selection enabled<br><br>
  11. * If this option is set true, we can select the data points and get/set its state of selection by API (e.g. select, unselect, selected).
  12. * - **NOTE:** for ESM imports, needs to import 'selection' exports and instantiate it by calling `selection()`.
  13. * - `enabled: selection()`
  14. * @name data․selection․enabled
  15. * @memberof Options
  16. * @type {boolean}
  17. * @default false
  18. * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataSelection)
  19. * @example
  20. * data: {
  21. * selection: {
  22. * enabled: true
  23. * }
  24. * }
  25. * @example
  26. * // importing ESM
  27. * import bb, {selection} from "billboard.js";
  28. *
  29. * data: {
  30. * selection: {
  31. * enabled: selection(),
  32. * ...
  33. * }
  34. * }
  35. */
  36. data_selection_enabled: false,
  37. /**
  38. * Set grouped selection enabled.<br><br>
  39. * If this option set true, multiple data points that have same x value will be selected by one selection.
  40. * @name data․selection․grouped
  41. * @memberof Options
  42. * @type {boolean}
  43. * @default false
  44. * @example
  45. * data: {
  46. * selection: {
  47. * grouped: true
  48. * }
  49. * }
  50. */
  51. data_selection_grouped: false,
  52. /**
  53. * Set a callback for each data point to determine if it's selectable or not.<br><br>
  54. * The callback will receive d as an argument and it has some parameters like id, value, index. This callback should return boolean.
  55. * @name data․selection․isselectable
  56. * @memberof Options
  57. * @type {Function}
  58. * @default function() { return true; }
  59. * @example
  60. * data: {
  61. * selection: {
  62. * isselectable: function(d) { ... }
  63. * }
  64. * }
  65. */
  66. data_selection_isselectable: () => true,
  67. /**
  68. * Set multiple data points selection enabled.<br><br>
  69. * If this option set true, multile data points can have the selected state at the same time. If false set, only one data point can have the selected state and the others will be unselected when the new data point is selected.
  70. * @name data․selection․multiple
  71. * @memberof Options
  72. * @type {boolean}
  73. * @default true
  74. * @example
  75. * data: {
  76. * selection: {
  77. * multiple: false
  78. * }
  79. * }
  80. */
  81. data_selection_multiple: true,
  82. /**
  83. * Enable to select data points by dragging.
  84. * If this option set true, data points can be selected by dragging.
  85. * - **NOTE:** If this option set true, scrolling on the chart will be disabled because dragging event will handle the event.
  86. * @name data․selection․draggable
  87. * @memberof Options
  88. * @type {boolean}
  89. * @default false
  90. * @example
  91. * data: {
  92. * selection: {
  93. * draggable: true
  94. * }
  95. * }
  96. */
  97. data_selection_draggable: false,
  98. /**
  99. * Set a callback for on data selection.
  100. * @name data․onselected
  101. * @memberof Options
  102. * @type {Function}
  103. * @default function() {}
  104. * @example
  105. * data: {
  106. * onselected: function(d, element) {
  107. * // d - ex) {x: 4, value: 150, id: "data1", index: 4, name: "data1"}
  108. * // element - <circle>
  109. * ...
  110. * }
  111. * }
  112. */
  113. data_onselected: () => {},
  114. /**
  115. * Set a callback for on data un-selection.
  116. * @name data․onunselected
  117. * @memberof Options
  118. * @type {Function}
  119. * @default function() {}
  120. * @example
  121. * data: {
  122. * onunselected: function(d, element) {
  123. * // d - ex) {x: 4, value: 150, id: "data1", index: 4, name: "data1"}
  124. * // element - <circle>
  125. * ...
  126. * }
  127. * }
  128. */
  129. data_onunselected: () => {}
  130. };