config/Options/common/grid.ts

  1. /**
  2. * Copyright (c) 2017 ~ present NAVER Corp.
  3. * billboard.js project is licensed under the MIT license
  4. */
  5. /**
  6. * grid config options
  7. */
  8. type Lines = {value?: number, text?: string, class?: string, position?: string}[];
  9. export default {
  10. /**
  11. * Set related options
  12. * @name grid
  13. * @memberof Options
  14. * @type {object}
  15. * @property {boolean} [front=false] Set 'grid & focus lines' to be positioned over grid lines and chart elements.
  16. * @property {object} x Grid x object
  17. * @property {boolean} [x.show=false] Show grids along x axis.
  18. * @property {Array} [x.lines=[]] Show additional grid lines along x axis.<br>
  19. * This option accepts array including object that has value, text, position and class. text, position and class are optional. For position, start, middle and end (default) are available.
  20. * If x axis is category axis, value can be category name. If x axis is timeseries axis, value can be date string, Date object and unixtime integer.
  21. * @property {object} y Grid y object
  22. * @property {boolean} [y.show=false] Show grids along x axis.
  23. * @property {Array} [y.lines=[]] Show additional grid lines along y axis.<br>
  24. * This option accepts array including object that has value, text, position and class.
  25. * @property {number} [y.ticks=undefined] Number of y grids to be shown.
  26. * @property {object} focus Grid focus object
  27. * @property {boolean} [focus.edge=false] Show edged focus grid line.<br>**NOTE:** Available when [`tooltip.grouped=false`](#.tooltip) option is set.
  28. * @property {boolean} [focus.show=true] Show grid line when focus.
  29. * @property {boolean} [focus.y=false] Show y coordinate focus grid line.<br>**NOTE:** Available when [`tooltip.grouped=false`](#.tooltip) option is set.
  30. * @property {object} lines Grid lines object
  31. * @property {boolean} [lines.front=true] Set grid lines to be positioned over chart elements.
  32. * @default undefined
  33. * @see [Demo](https://naver.github.io/billboard.js/demo/#Grid.GridLines)
  34. * @see [Demo: X Grid Lines](https://naver.github.io/billboard.js/demo/#Grid.OptionalXGridLines)
  35. * @see [Demo: Y Grid Lines](https://naver.github.io/billboard.js/demo/#Grid.OptionalYGridLines)
  36. * @example
  37. * grid: {
  38. * x: {
  39. * show: true,
  40. * lines: [
  41. * {value: 2, text: "Label on 2"},
  42. * {value: 5, text: "Label on 5", class: "label-5"},
  43. * {value: 6, text: "Label on 6", position: "start"}
  44. * ]
  45. * },
  46. * y: {
  47. * show: true,
  48. * lines: [
  49. * {value: 100, text: "Label on 100"},
  50. * {value: 200, text: "Label on 200", class: "label-200"},
  51. * {value: 300, text: "Label on 300", position: 'middle'}
  52. * ],
  53. * ticks: 5
  54. * },
  55. * front: true,
  56. * focus: {
  57. * show: false,
  58. *
  59. * // Below options are available when 'tooltip.grouped=false' option is set
  60. * edge: true,
  61. * y: true
  62. * },
  63. * lines: {
  64. * front: false
  65. * }
  66. * }
  67. */
  68. grid_x_show: false,
  69. grid_x_type: "tick",
  70. grid_x_lines: <Lines>[],
  71. grid_y_show: false,
  72. grid_y_lines: <Lines>[],
  73. grid_y_ticks: <number | undefined>undefined,
  74. grid_focus_edge: false,
  75. grid_focus_show: true,
  76. grid_focus_y: false,
  77. grid_front: false,
  78. grid_lines_front: true
  79. };