config/Options/data/axis.ts

  1. /**
  2. * Copyright (c) 2017 ~ present NAVER Corp.
  3. * billboard.js project is licensed under the MIT license
  4. */
  5. import type {DataRegionsType} from "../../../../types/types";
  6. /**
  7. * Axis based chart data config options
  8. */
  9. export default {
  10. /**
  11. * Specify the keys of the x values for each data.<br><br>
  12. * This option can be used if we want to show the data that has different x values.
  13. * @name data․xs
  14. * @memberof Options
  15. * @type {object}
  16. * @default {}
  17. * @example
  18. * data: {
  19. * xs: {
  20. * data1: "x1",
  21. * data2: "x2"
  22. * }
  23. * }
  24. */
  25. data_xs: {},
  26. /**
  27. * Set a format specifier to parse string specifed as x.
  28. * @name data․xFormat
  29. * @memberof Options
  30. * @type {string}
  31. * @default %Y-%m-%d
  32. * @example
  33. * data: {
  34. * x: "x",
  35. * columns: [
  36. * ["x", "01012019", "02012019", "03012019"],
  37. * ["data1", 30, 200, 100]
  38. * ],
  39. * // Format specifier to parse as datetime for given 'x' string value
  40. * xFormat: "%m%d%Y"
  41. * },
  42. * axis: {
  43. * x: {
  44. * type: "timeseries"
  45. * }
  46. * }
  47. * @see [D3's time specifier](https://d3js.org/d3-time-format#locale_format)
  48. */
  49. data_xFormat: "%Y-%m-%d",
  50. /**
  51. * Set localtime format to parse x axis.
  52. * @name data․xLocaltime
  53. * @memberof Options
  54. * @type {boolean}
  55. * @default true
  56. * @example
  57. * data: {
  58. * xLocaltime: false
  59. * }
  60. */
  61. data_xLocaltime: true,
  62. /**
  63. * Sort on x axis.
  64. * - **NOTE:** This option works for lineish(area/line/spline/step) types only.
  65. * @name data․xSort
  66. * @memberof Options
  67. * @type {boolean}
  68. * @default true
  69. * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataXSort)
  70. * @example
  71. * data: {
  72. * xSort: false,
  73. * x: "x",
  74. * columns: [
  75. * // The line graph will start to be drawn following the x axis sequence
  76. * // Below data, wil start drawing x=1: 200, x=2: 300, x=3: 100
  77. * ["x", 3, 1, 2],
  78. * ["data1", 100, 200, 300]
  79. * ]
  80. * }
  81. */
  82. data_xSort: true,
  83. /**
  84. * Set y axis the data related to. y and y2 can be used.
  85. * - **NOTE:** If all data is related to one of the axes, the domain of axis without related data will be replaced by the domain from the axis with related data
  86. * @name data․axes
  87. * @memberof Options
  88. * @type {object}
  89. * @default {}
  90. * @example
  91. * data: {
  92. * axes: {
  93. * data1: "y",
  94. * data2: "y2"
  95. * }
  96. * }
  97. */
  98. data_axes: <{[key: string]: string}>{},
  99. /**
  100. * Define regions for each data.<br>
  101. * The values must be an array for each data and it should include an object that has `start`, `end` and `style`.
  102. * - The object type should be as:
  103. * - start {number}: Start data point number. If not set, the start will be the first data point.
  104. * - [end] {number}: End data point number. If not set, the end will be the last data point.
  105. * - [style.dasharray="2 2"] {string}: The first number specifies a distance for the filled area, and the second a distance for the unfilled area.
  106. * - **NOTE:**
  107. * - Supports only line type.
  108. * - `start` and `end` values should be in the exact x value range.
  109. * - Dashes will be applied using `stroke-dasharray` css property when data doesn't contain nullish value(or nullish value with `line.connectNull=true` set).
  110. * - Dashes will be applied via path command when data contains nullish value.
  111. * @name data․regions
  112. * @memberof Options
  113. * @type {object}
  114. * @default {}
  115. * @example
  116. * data: {
  117. * regions: {
  118. * data1: [{
  119. * start: 1,
  120. * end: 2,
  121. * style: {
  122. * dasharray: "5 2"
  123. * }
  124. * }, {
  125. * start: 3
  126. * }],
  127. * ...
  128. * }
  129. * }
  130. */
  131. data_regions: <DataRegionsType>{},
  132. /**
  133. * Set the stacking to be normalized
  134. * - **NOTE:**
  135. * - For stacking, '[data.groups](#.data%25E2%2580%25A4groups)' option should be set
  136. * - y Axis will be set in percentage value (0 ~ 100%)
  137. * - Must have postive values
  138. * @name data․stack․normalize
  139. * @memberof Options
  140. * @type {boolean}
  141. * @default false
  142. * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataStackNormalized)
  143. * @example
  144. * data: {
  145. * stack: {
  146. * normalize: true
  147. * }
  148. * }
  149. */
  150. data_stack_normalize: false
  151. };