config/Options/axis/y2.ts

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