config/Options/common/point.ts

  1. /**
  2. * Copyright (c) 2017 ~ present NAVER Corp.
  3. * billboard.js project is licensed under the MIT license
  4. */
  5. import {IDataPoint} from "../../../ChartInternal/data/IData";
  6. /**
  7. * point config options
  8. */
  9. export default {
  10. /**
  11. * Set point options
  12. * @name point
  13. * @memberof Options
  14. * @type {object}
  15. * @property {object} point Point object
  16. * @property {boolean} [point.show=true] Whether to show each point in line.
  17. * @property {number|Function} [point.r=2.5] The radius size of each point.
  18. * - **NOTE:** Disabled for 'bubble' type
  19. * @property {boolean|object} [point.radialGradient=false] Set the radial gradient on point.<br><br>
  20. * Or customize by giving below object value:
  21. * - cx {number}: `cx` value (default: `0.3`)
  22. * - cy {number}: `cy` value (default: `0.3`)
  23. * - r {number}: `r` value (default: `0.7`)
  24. * - stops {Array}: Each item should be having `[offset, stop-color, stop-opacity]` values.
  25. * - (default: `[[0.1, $DATA_COLOR, 1], [0.9, $DATA_COLOR, 0]]`)
  26. * @property {boolean} [point.focus.expand.enabled=true] Whether to expand each point on focus.
  27. * @property {number} [point.focus.expand.r=point.r*1.75] The radius size of each point on focus.
  28. * - **NOTE:** For 'bubble' type, the default is `bubbleSize*1.15`
  29. * @property {boolean} [point.focus.only=false] Show point only when is focused.
  30. * @property {number|null} [point.opacity=undefined] Set point opacity value.
  31. * - **NOTE:**
  32. * - `null` will make to not set inline 'opacity' css prop.
  33. * - when no value(or undefined) is set, it defaults to set opacity value according its chart types.
  34. * @property {number|string|Function} [point.sensitivity=10] The senstivity value for interaction boundary.
  35. * - **Available Values:**
  36. * - {number}: Absolute sensitivity value which is the distance from the data point in pixel.
  37. * - "radius": sensitivity based on point's radius
  38. * - Function: callback for each point to determine the sensitivity<br>
  39. * ```js
  40. * sensitivity: function(d) {
  41. * // ex. of argument d:
  42. * // ==> {x: 2, value: 55, id: 'data3', index: 2, r: 19.820624179302296}
  43. *
  44. * // returning d.r, will make sensitivity same as point's radius value.
  45. * return d.r;
  46. * }
  47. * ```
  48. * @property {number} [point.select.r=point.r*4] The radius size of each point on selected.
  49. * @property {string} [point.type="circle"] The type of point to be drawn
  50. * - **NOTE:**
  51. * - If chart has 'bubble' type, only circle can be used.
  52. * - For IE, non circle point expansions are not supported due to lack of transform support.
  53. * - **Available Values:**
  54. * - circle
  55. * - rectangle
  56. * @property {Array} [point.pattern=[]] The type of point or svg shape as string, to be drawn for each line
  57. * - **NOTE:**
  58. * - This is an `experimental` feature and can have some unexpected behaviors.
  59. * - If chart has 'bubble' type, only circle can be used.
  60. * - For IE, non circle point expansions are not supported due to lack of transform support.
  61. * - **Available Values:**
  62. * - circle
  63. * - rectangle
  64. * - svg shape tag interpreted as string<br>
  65. * (ex. `<polygon points='2.5 0 0 5 5 5'></polygon>`)
  66. * @see [Demo: point type](https://naver.github.io/billboard.js/demo/#Point.RectanglePoints)
  67. * @see [Demo: point focus only](https://naver.github.io/billboard.js/demo/#Point.FocusOnly)
  68. * @see [Demo: point radialGradient](https://naver.github.io/billboard.js/demo/#Point.RadialGradientPoint)
  69. * @see [Demo: point sensitivity](https://naver.github.io/billboard.js/demo/#Point.PointSensitivity)
  70. * @example
  71. * point: {
  72. * show: false,
  73. * r: 5,
  74. *
  75. * // or customize the radius
  76. * r: function(d) {
  77. * ...
  78. * return r;
  79. * },
  80. *
  81. * // will generate follwing radialGradient:
  82. * // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/radialGradient
  83. * // <radualGradient cx="0.3" cy="0.3" r="0.7">
  84. * // <stop offset="0.1" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
  85. * // <stop offset="0.9" stop-color="$DATA_COLOR" stop-opacity="0"></stop>
  86. * // </radialrGradient>
  87. * radialGradient: true,
  88. *
  89. * // Or customized gradient
  90. * radialGradient: {
  91. * cx: 0.3, // cx attributes
  92. * cy: 0.5, // cy attributes
  93. * r: 0.7, // r attributes
  94. * stops: [
  95. * // offset, stop-color, stop-opacity
  96. * [0, "#7cb5ec", 1],
  97. *
  98. * // setting 'null' for stop-color, will set its original data color
  99. * [0.5, null, 0],
  100. *
  101. * // setting 'function' for stop-color, will pass data id as argument.
  102. * // It should return color string or null value
  103. * [1, function(id) { return id === "data1" ? "red" : "blue"; }, 0],
  104. * ]
  105. * },
  106. *
  107. * focus: {
  108. * expand: {
  109. * enabled: true,
  110. * r: 1
  111. * },
  112. * only: true
  113. * },
  114. *
  115. * // do not set inline 'opacity' css prop setting
  116. * opacity: null,
  117. *
  118. * // set every data point's opacity value
  119. * opacity: 0.7,
  120. *
  121. * select: {
  122. * r: 3
  123. * },
  124. *
  125. * // having lower value, means how closer to be for interaction
  126. * sensitivity: 3,
  127. *
  128. * // sensitivity based on point's radius
  129. * sensitivity: "radius",
  130. *
  131. * // callback for each point to determine the sensitivity
  132. * sensitivity: function(d) {
  133. * // ex. of argument d:
  134. * // ==> {x: 2, value: 55, id: 'data3', index: 2, r: 19.820624179302296}
  135. *
  136. * // returning d.r, will make sensitivity same as point's radius value.
  137. * return d.r;
  138. * }
  139. *
  140. * // valid values are "circle" or "rectangle"
  141. * type: "rectangle",
  142. *
  143. * // or indicate as pattern
  144. * pattern: [
  145. * "circle",
  146. * "rectangle",
  147. * "<polygon points='0 6 4 0 -4 0'></polygon>"
  148. * ],
  149. * }
  150. */
  151. point_show: true,
  152. point_r: 2.5,
  153. point_radialGradient: <boolean | {
  154. cx?: number,
  155. cy?: number,
  156. r?: number,
  157. stops?: [number, string | null | Function, number]
  158. }>false,
  159. point_sensitivity: <number | "radius" | ((d: IDataPoint) => number)>10,
  160. point_focus_expand_enabled: true,
  161. point_focus_expand_r: <number | undefined>undefined,
  162. point_focus_only: false,
  163. point_opacity: <number | null | undefined>undefined,
  164. point_pattern: <string[]>[],
  165. point_select_r: <number | undefined>undefined,
  166. point_type: "circle"
  167. };