Plugin/tableview/Options.ts

  1. /**
  2. * Copyright (c) 2021 ~ present NAVER Corp.
  3. * billboard.js project is licensed under the MIT license
  4. */
  5. /**
  6. * TableView plugin option class
  7. * @class TableviewOptions
  8. * @param {Options} options TableView plugin options
  9. * @augments Plugin
  10. * @returns {TableviewOptions}
  11. * @private
  12. */
  13. export default class Options {
  14. constructor() {
  15. return {
  16. /**
  17. * Set tableview holder selector.
  18. * - **NOTE:** If not set, will append new holder element dynamically right after chart element.
  19. * @name selector
  20. * @memberof plugin-tableview
  21. * @type {string}
  22. * @default undefined
  23. * @example
  24. * selector: "#table-holder"
  25. */
  26. selector: undefined,
  27. /**
  28. * Set category title text
  29. * @name categoryTitle
  30. * @memberof plugin-tableview
  31. * @type {string}
  32. * @default "Category"
  33. * @example
  34. * categoryTitle: "#table-holder"
  35. */
  36. categoryTitle: "Category",
  37. /**
  38. * Set category text format function.
  39. * @name categoryFormat
  40. * @memberof plugin-tableview
  41. * @type {Function}
  42. * @returns {string}
  43. * @default function(v) { // will return formatted value according x Axis type }}
  44. * @example
  45. * categoryFormat: "#table-holder"
  46. */
  47. categoryFormat: function(v: Date | number | string): string {
  48. let category = v;
  49. if (this.$$.axis.isCategorized()) {
  50. category = this.$$.categoryName(v);
  51. } else if (this.$$.axis.isTimeSeries()) {
  52. category = (v as Date).toLocaleDateString();
  53. }
  54. return category as string;
  55. },
  56. /**
  57. * Set tableview holder class name.
  58. * @name class
  59. * @memberof plugin-tableview
  60. * @type {string}
  61. * @default undefined
  62. * @example
  63. * class: "table-class-name"
  64. */
  65. class: undefined,
  66. /**
  67. * Set to apply default style(`.bb-tableview`) to tableview element.
  68. * @name style
  69. * @memberof plugin-tableview
  70. * @type {boolean}
  71. * @default true
  72. * @example
  73. * style: false
  74. */
  75. style: true,
  76. /**
  77. * Set tableview title text.
  78. * - **NOTE:** If set [title.text](https://naver.github.io/billboard.js/release/latest/doc/Options.html#.title), will be used when this option value is empty.
  79. * @name title
  80. * @memberof plugin-tableview
  81. * @type {string}
  82. * @default undefined
  83. * @example
  84. * title: "Table Title Text"
  85. */
  86. title: undefined,
  87. /**
  88. * Update tableview from data visibility update(ex. legend toggle).
  89. * @name updateOnToggle
  90. * @memberof plugin-tableview
  91. * @type {boolean}
  92. * @default true
  93. * @example
  94. * legendToggleUpdate: false
  95. */
  96. updateOnToggle: true,
  97. /**
  98. * Set how null value to be shown.
  99. * @name nullString
  100. * @memberof plugin-tableview
  101. * @type {string}
  102. * @default "-"
  103. * @example
  104. * nullString: "N/A"
  105. */
  106. nullString: "-"
  107. };
  108. }
  109. }