config/Options/axis/y.ts

  1. /**
  2. * Copyright (c) 2017 ~ present NAVER Corp.
  3. * billboard.js project is licensed under the MIT license
  4. */
  5. /**
  6. * y Axis config options
  7. */
  8. export default {
  9. /**
  10. * Set clip-path attribute for y axis element
  11. * - **NOTE**: `clip-path` attribute for y Axis is set only when `axis.y.inner` option is true.
  12. * @name axis․y․clipPath
  13. * @memberof Options
  14. * @type {boolean}
  15. * @default true
  16. * @example
  17. * // don't set 'clip-path' attribute
  18. * clipPath: false
  19. */
  20. axis_y_clipPath: true,
  21. /**
  22. * Show or hide y axis.
  23. * @name axis․y․show
  24. * @memberof Options
  25. * @type {boolean}
  26. * @default true
  27. * @example
  28. * axis: {
  29. * y: {
  30. * show: false
  31. * }
  32. * }
  33. */
  34. axis_y_show: true,
  35. /**
  36. * Set type of y axis.<br><br>
  37. * **Available Values:**
  38. * - indexed
  39. * - log
  40. * - timeseries
  41. *
  42. * **NOTE:**<br>
  43. * - **log** type:
  44. * - the bound data values must be exclusively-positive.
  45. * - y axis min value should be >= 0.
  46. * - [`data.groups`](#.data%25E2%2580%25A4groups)(stacked data) option aren't supported.
  47. *
  48. * @name axis․y․type
  49. * @memberof Options
  50. * @type {string}
  51. * @default "indexed"
  52. * @see [Demo: log](https://naver.github.io/billboard.js/demo/#Axis.LogScales)
  53. * @example
  54. * axis: {
  55. * y: {
  56. * type: "log"
  57. * }
  58. * }
  59. */
  60. axis_y_type: <"indexed" | "log" | "timeseries">"indexed",
  61. /**
  62. * Set max value of y axis.
  63. * - **NOTE:** Padding will be added based on this value, so if you don't need the padding, please set axis.y.padding to disable it (e.g. axis.y.padding = 0).
  64. * @name axis․y․max
  65. * @memberof Options
  66. * @type {number}
  67. * @default undefined
  68. * @example
  69. * axis: {
  70. * y: {
  71. * max: 1000
  72. * }
  73. * }
  74. */
  75. axis_y_max: <number | undefined>undefined,
  76. /**
  77. * Set min value of y axis.
  78. * - **NOTE:**
  79. * Padding will be added based on this value, so if you don't need the padding, please set axis.y.padding to disable it (e.g. axis.y.padding = 0).
  80. * @name axis․y․min
  81. * @memberof Options
  82. * @type {number}
  83. * @default undefined
  84. * @example
  85. * axis: {
  86. * y: {
  87. * min: 1000
  88. * }
  89. * }
  90. */
  91. axis_y_min: <number | undefined>undefined,
  92. /**
  93. * Change the direction of y axis.<br><br>
  94. * If true set, the direction will be `top -> bottom`.
  95. * @name axis․y․inverted
  96. * @memberof Options
  97. * @type {boolean}
  98. * @default false
  99. * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.InvertedAxis)
  100. * @example
  101. * axis: {
  102. * y: {
  103. * inverted: true
  104. * }
  105. * }
  106. */
  107. axis_y_inverted: false,
  108. /**
  109. * Set center value of y axis.
  110. * @name axis․y․center
  111. * @memberof Options
  112. * @type {number}
  113. * @default undefined
  114. * @example
  115. * axis: {
  116. * y: {
  117. * center: 0
  118. * }
  119. * }
  120. */
  121. axis_y_center: <number | undefined>undefined,
  122. /**
  123. * Show y axis inside of the chart.
  124. * @name axis․y․inner
  125. * @memberof Options
  126. * @type {boolean}
  127. * @default false
  128. * @example
  129. * axis: {
  130. * y: {
  131. * inner: true
  132. * }
  133. * }
  134. */
  135. axis_y_inner: false,
  136. /**
  137. * Set label on y axis.<br><br>
  138. * You can set y axis label and change its position by this option. This option works in the same way as [axis.x.label](#.axis%25E2%2580%25A4x%25E2%2580%25A4label).
  139. * @name axis․y․label
  140. * @memberof Options
  141. * @type {string|object}
  142. * @default {}
  143. * @see [axis.x.label](#.axis%25E2%2580%25A4x%25E2%2580%25A4label) for position string value.
  144. * @example
  145. * axis: {
  146. * y: {
  147. * label: "Your Y Axis"
  148. * }
  149. * }
  150. *
  151. * axis: {
  152. * y: {
  153. * label: {
  154. * text: "Your Y Axis",
  155. * position: "outer-middle"
  156. * }
  157. * }
  158. * }
  159. */
  160. axis_y_label: <string | object>{},
  161. /**
  162. * Set formatter for y axis tick text.<br><br>
  163. * This option accepts d3.format object as well as a function you define.
  164. * @name axis․y․tick․format
  165. * @memberof Options
  166. * @type {Function}
  167. * @default undefined
  168. * @example
  169. * axis: {
  170. * y: {
  171. * tick: {
  172. * format: function(x) {
  173. * return x.getFullYear();
  174. * }
  175. * }
  176. * }
  177. * }
  178. */
  179. axis_y_tick_format: <Function | undefined>undefined,
  180. /**
  181. * Setting for culling ticks.
  182. * - `true`: the ticks will be culled, then only limited tick text will be shown.<br>
  183. * This option does not hide the tick lines by default, if want to hide tick lines, set `axis.y.tick.culling.lines=false`.
  184. * - `false`: all of ticks will be shown.<br><br>
  185. * The number of ticks to be shown can be chaned by `axis.y.tick.culling.max`.
  186. * @name axis․y․tick․culling
  187. * @memberof Options
  188. * @type {boolean}
  189. * @default false
  190. * @example
  191. * axis: {
  192. * y: {
  193. * tick: {
  194. * culling: false
  195. * }
  196. * }
  197. * }
  198. */
  199. axis_y_tick_culling: false,
  200. /**
  201. * The number of tick texts will be adjusted to less than this value.
  202. * @name axis․y․tick․culling․max
  203. * @memberof Options
  204. * @type {number}
  205. * @default 5
  206. * @example
  207. * axis: {
  208. * y: {
  209. * tick: {
  210. * culling: {
  211. * max: 5
  212. * }
  213. * }
  214. * }
  215. * }
  216. */
  217. axis_y_tick_culling_max: 5,
  218. /**
  219. * Control visibility of tick lines within culling option, along with tick text.
  220. * @name axis․y․tick․culling․lines
  221. * @memberof Options
  222. * @type {boolean}
  223. * @default true
  224. * @example
  225. * axis: {
  226. * y: {
  227. * tick: {
  228. * culling: {
  229. * lines: false,
  230. * }
  231. * }
  232. * }
  233. * }
  234. */
  235. axis_y_tick_culling_lines: true,
  236. /**
  237. * Show y axis outer tick.
  238. * @name axis․y․tick․outer
  239. * @memberof Options
  240. * @type {boolean}
  241. * @default true
  242. * @example
  243. * axis: {
  244. * y: {
  245. * tick: {
  246. * outer: false
  247. * }
  248. * }
  249. * }
  250. */
  251. axis_y_tick_outer: true,
  252. /**
  253. * Set y axis tick values manually.
  254. * @name axis․y․tick․values
  255. * @memberof Options
  256. * @type {Array|Function}
  257. * @default null
  258. * @example
  259. * axis: {
  260. * y: {
  261. * tick: {
  262. * values: [100, 1000, 10000],
  263. *
  264. * // an Array value should be returned
  265. * values: function() {
  266. * return [ ... ];
  267. * }
  268. * }
  269. * }
  270. * }
  271. */
  272. axis_y_tick_values: <number[] | (() => number[]) | null>null,
  273. /**
  274. * Rotate y axis tick text.
  275. * - If you set negative value, it will rotate to opposite direction.
  276. * - Applied when [`axis.rotated`](#.axis%25E2%2580%25A4rotated) option is `true`.
  277. * @name axis․y․tick․rotate
  278. * @memberof Options
  279. * @type {number}
  280. * @default 0
  281. * @example
  282. * axis: {
  283. * y: {
  284. * tick: {
  285. * rotate: 60
  286. * }
  287. * }
  288. * }
  289. */
  290. axis_y_tick_rotate: 0,
  291. /**
  292. * Set the number of y axis ticks.<br><br>
  293. * - **NOTE:** The position of the ticks will be calculated precisely, so the values on the ticks will not be rounded nicely. In the case, axis.y.tick.format or axis.y.tick.values will be helpful.
  294. * @name axis․y․tick․count
  295. * @memberof Options
  296. * @type {number}
  297. * @default undefined
  298. * @example
  299. * axis: {
  300. * y: {
  301. * tick: {
  302. * count: 5
  303. * }
  304. * }
  305. * }
  306. */
  307. axis_y_tick_count: <number | undefined>undefined,
  308. /**
  309. * Show or hide y axis tick line.
  310. * @name axis․y․tick․show
  311. * @memberof Options
  312. * @type {boolean}
  313. * @default true
  314. * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
  315. * @example
  316. * axis: {
  317. * y: {
  318. * tick: {
  319. * show: false
  320. * }
  321. * }
  322. * }
  323. */
  324. axis_y_tick_show: true,
  325. /**
  326. * Set axis tick step(interval) size.
  327. * - **NOTE:** Will be ignored if `axis.y.tick.count` or `axis.y.tick.values` options are set.
  328. * @name axis․y․tick․stepSize
  329. * @memberof Options
  330. * @type {number}
  331. * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.StepSizeForYAxis)
  332. * @example
  333. * axis: {
  334. * y: {
  335. * tick: {
  336. * // tick value will step as indicated interval value.
  337. * // ex) 'stepSize=15' ==> [0, 15, 30, 45, 60]
  338. * stepSize: 15
  339. * }
  340. * }
  341. * }
  342. */
  343. axis_y_tick_stepSize: <number | null>null,
  344. /**
  345. * Show or hide y axis tick text.
  346. * @name axis․y․tick․text․show
  347. * @memberof Options
  348. * @type {boolean}
  349. * @default true
  350. * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
  351. * @example
  352. * axis: {
  353. * y: {
  354. * tick: {
  355. * text: {
  356. * show: false
  357. * }
  358. * }
  359. * }
  360. * }
  361. */
  362. axis_y_tick_text_show: true,
  363. /**
  364. * Set the y Axis tick text's position relatively its original position
  365. * @name axis․y․tick․text․position
  366. * @memberof Options
  367. * @type {object}
  368. * @default {x: 0, y:0}
  369. * @example
  370. * axis: {
  371. * y: {
  372. * tick: {
  373. * text: {
  374. * position: {
  375. * x: 10,
  376. * y: 10
  377. * }
  378. * }
  379. * }
  380. * }
  381. * }
  382. */
  383. axis_y_tick_text_position: {x: 0, y: 0},
  384. /**
  385. * Set the number of y axis ticks.<br><br>
  386. * - **NOTE:** The position of the ticks will be calculated precisely, so the values on the ticks will not be rounded nicely. In the case, axis.y.tick.format or axis.y.tick.values will be helpful.
  387. * @name axis․y․tick․time
  388. * @memberof Options
  389. * @private
  390. * @type {object}
  391. * @property {object} time time object
  392. * @property {Function} [time.value] D3's time interval function (https://github.com/d3/d3-time#intervals)
  393. * @example
  394. * axis: {
  395. * y: {
  396. * tick: {
  397. * time: {
  398. * // ticks at 15-minute intervals
  399. * // https://github.com/d3/d3-scale/blob/master/README.md#time_ticks
  400. * value: d3.timeMinute.every(15)
  401. * }
  402. * }
  403. * }
  404. * }
  405. */
  406. // @TODO: not fully implemented yet
  407. axis_y_tick_time_value: <Function | undefined>undefined,
  408. /**
  409. * Set padding for y axis.<br><br>
  410. * You can set padding for y axis to create more space on the edge of the axis.
  411. * This option accepts object and it can include top and bottom. top, bottom will be treated as pixels.
  412. *
  413. * - **NOTE:**
  414. * - Given values are translated relative to the y Axis domain value for padding
  415. * - For area and bar type charts, [area.zerobased](#.area) or [bar.zerobased](#.bar) options should be set to 'false` to get padded bottom.
  416. * @name axis․y․padding
  417. * @memberof Options
  418. * @type {object|number}
  419. * @default {}
  420. * @example
  421. * axis: {
  422. * y: {
  423. * padding: {
  424. * top: 0,
  425. * bottom: 0
  426. * },
  427. *
  428. * // or set both values at once.
  429. * padding: 10
  430. * }
  431. * }
  432. */
  433. axis_y_padding: <number | {top?: number, bottom?: number}>{},
  434. /**
  435. * Set default range of y axis.<br><br>
  436. * This option set the default value for y axis when there is no data on init.
  437. * @name axis․y․default
  438. * @memberof Options
  439. * @type {Array}
  440. * @default undefined
  441. * @example
  442. * axis: {
  443. * y: {
  444. * default: [0, 1000]
  445. * }
  446. * }
  447. */
  448. axis_y_default: <number[] | undefined>undefined,
  449. /**
  450. * Set additional axes for y Axis.
  451. * - **NOTE:** Axis' scale is based on y Axis value if domain option isn't set.
  452. *
  453. * Each axis object should consist with following options:
  454. *
  455. * | Name | Type | Default | Description |
  456. * | --- | --- | --- | --- |
  457. * | domain | Array | - | Set the domain value |
  458. * | tick.outer | boolean | true | Show outer tick |
  459. * | tick.format | Function | - | Set formatter for tick text |
  460. * | tick.count | Number | - | Set the number of y axis ticks |
  461. * | tick.values | Array | - | Set tick values manually |
  462. * @name axis․y․axes
  463. * @memberof Options
  464. * @type {Array}
  465. * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.MultiAxes)
  466. * @see [Demo: Domain](https://naver.github.io/billboard.js/demo/#Axis.MultiAxesDomain)
  467. * @example
  468. * y: {
  469. * axes: [
  470. * {
  471. * // if set, will not be correlated with the main y Axis domain value
  472. * domain: [0, 1000],
  473. * tick: {
  474. * outer: false,
  475. * format: function(x) {
  476. * return x + "%";
  477. * },
  478. * count: 2,
  479. * values: [10, 20, 30]
  480. * }
  481. * },
  482. * ...
  483. * ]
  484. * }
  485. */
  486. axis_y_axes: <object[]>[]
  487. };