config/Options/data/data.ts

  1. /**
  2. * Copyright (c) 2017 ~ present NAVER Corp.
  3. * billboard.js project is licensed under the MIT license
  4. */
  5. import type {ChartTypes, d3Selection} from "../../../../types/types";
  6. /**
  7. * data config options
  8. */
  9. export default {
  10. /**
  11. * Specify the key of x values in the data.<br><br>
  12. * We can show the data with non-index x values by this option. This option is required when the type of x axis is timeseries. If this option is set on category axis, the values of the data on the key will be used for category names.
  13. * @name data․x
  14. * @memberof Options
  15. * @type {string}
  16. * @default undefined
  17. * @example
  18. * data: {
  19. * x: "date"
  20. * }
  21. */
  22. data_x: <string | undefined>undefined,
  23. /**
  24. * Converts data id value
  25. * @name data․idConverter
  26. * @memberof Options
  27. * @type {Function}
  28. * @default function(id) { return id; }
  29. * @example
  30. * data: {
  31. * idConverter: function(id) {
  32. * // when id is 'data1', converts to be 'data2'
  33. * // 'data2' should be given as the initial data value
  34. * if (id === "data1") {
  35. * return "data2";
  36. * } else {
  37. * return id;
  38. * }
  39. * }
  40. * }
  41. */
  42. data_idConverter: id => id,
  43. /**
  44. * Set custom data name.
  45. * If a name is set to `null`, the series is omitted from the legend.
  46. * @name data․names
  47. * @memberof Options
  48. * @type {object}
  49. * @default {}
  50. * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataName)
  51. * @example
  52. * data: {
  53. * names: {
  54. * data1: "Data Name 1",
  55. * data2: "Data Name 2"
  56. * }
  57. * }
  58. */
  59. data_names: <{[key: string]: string | null}>{},
  60. /**
  61. * Set custom data class.<br><br>
  62. * If this option is specified, the element g for the data has an additional class that has the prefix 'bb-target-' (eg. bb-target-additional-data1-class).
  63. * @name data․classes
  64. * @memberof Options
  65. * @type {object}
  66. * @default {}
  67. * @example
  68. * data: {
  69. * classes: {
  70. * data1: "additional-data1-class",
  71. * data2: "additional-data2-class"
  72. * }
  73. * }
  74. */
  75. data_classes: <{[key: string]: string}>{},
  76. /**
  77. * Set chart type at once.<br><br>
  78. * If this option is specified, the type will be applied to every data. This setting can be overwritten by data.types.<br><br>
  79. * **Available Values:**
  80. * - area
  81. * - area-line-range
  82. * - area-spline
  83. * - area-spline-range
  84. * - area-step
  85. * - area-step-range
  86. * - bar
  87. * - bubble
  88. * - candlestick
  89. * - donut
  90. * - funnel
  91. * - gauge
  92. * - line
  93. * - pie
  94. * - polar
  95. * - radar
  96. * - scatter
  97. * - spline
  98. * - step
  99. * - treemap
  100. * @name data․type
  101. * @memberof Options
  102. * @type {string}
  103. * @default "line"<br>NOTE: When importing shapes by ESM, `line()` should be specified for type.
  104. * @example
  105. * data: {
  106. * type: "bar"
  107. * }
  108. * @example
  109. * // Generate chart by importing ESM
  110. * // Import types to be used only, where this will make smaller bundle size.
  111. * import bb, {
  112. * area,
  113. * areaLineRange,
  114. * areaSpline,
  115. * areaSplineRange,
  116. * areaStep,
  117. * areaStepRange,
  118. * bar,
  119. * bubble,
  120. * candlestick,
  121. * donut,
  122. * funnel,
  123. * gauge,
  124. * line,
  125. * pie,
  126. * polar,
  127. * radar,
  128. * scatter,
  129. * spline,
  130. * step,
  131. * treemap
  132. * }
  133. *
  134. * bb.generate({
  135. * ...,
  136. * data: {
  137. * type: bar()
  138. * }
  139. * });
  140. */
  141. data_type: <ChartTypes | undefined>undefined,
  142. /**
  143. * Set chart type for each data.<br>
  144. * This setting overwrites data.type setting.
  145. * - **NOTE:** `radar` and `treemap` type can't be combined with other types.
  146. * @name data․types
  147. * @memberof Options
  148. * @type {object}
  149. * @default {}
  150. * @example
  151. * data: {
  152. * types: {
  153. * data1: "bar",
  154. * data2: "spline"
  155. * }
  156. * }
  157. * @example
  158. * // Generate chart by importing ESM
  159. * // Import types to be used only, where this will make smaller bundle size.
  160. * import bb, {
  161. * area,
  162. * areaLineRange,
  163. * areaSpline,
  164. * areaSplineRange,
  165. * areaStep,
  166. * areaStepRange,
  167. * bar,
  168. * bubble,
  169. * candlestick,
  170. * donut,
  171. * funnel,
  172. * gauge,
  173. * line,
  174. * pie,
  175. * polar,
  176. * radar,
  177. * scatter,
  178. * spline,
  179. * step,
  180. * treemap
  181. * }
  182. *
  183. * bb.generate({
  184. * ...,
  185. * data: {
  186. * types: {
  187. * data1: bar(),
  188. * data1: spline()
  189. * }
  190. * }
  191. * });
  192. */
  193. data_types: <{[key: string]: ChartTypes}>{},
  194. /**
  195. * This option changes the order of stacking data and pieces of pie/donut.
  196. * - If `null` specified, it will be the order the data loaded.
  197. * - If function specified, it will be used as [Array.sort compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters)<br><br>
  198. *
  199. * **Available Values:**
  200. * - `desc`: In descending order
  201. * - `asc`: In ascending order
  202. * - `null`: It keeps the data load order
  203. * - `function(data1, data2) { ... }`: Array.sort compareFunction
  204. *
  205. * **NOTE**: order function, only works for Axis based types & Arc types, except `Radar` type.
  206. * @name data․order
  207. * @memberof Options
  208. * @type {string|Function|null}
  209. * @default desc
  210. * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataOrder)
  211. * @example
  212. * data: {
  213. * // in descending order (default)
  214. * order: "desc"
  215. *
  216. * // in ascending order
  217. * order: "asc"
  218. *
  219. * // keeps data input order
  220. * order: null
  221. *
  222. * // specifying sort function
  223. * order: function(a, b) {
  224. * // param data passed format
  225. * // {
  226. * // id: "data1", id_org: "data1", values: [
  227. * // {x: 5, value: 250, id: "data1", index: 5, name: "data1"},
  228. * // ...
  229. * // ]
  230. * // }
  231. *
  232. * const reducer = (p, c) => p + Math.abs(c.value);
  233. * const aSum = a.values.reduce(reducer, 0);
  234. * const bSum = b.values.reduce(reducer, 0);
  235. *
  236. * // ascending order
  237. * return aSum - bSum;
  238. *
  239. * // descending order
  240. * // return bSum - aSum;
  241. * }
  242. * }
  243. */
  244. data_order: <"desc" | "asc" | Function | null>"desc",
  245. /**
  246. * Set groups for the data for stacking.
  247. * @name data․groups
  248. * @memberof Options
  249. * @type {Array}
  250. * @default []
  251. * @example
  252. * data: {
  253. * groups: [
  254. * ["data1", "data2"],
  255. * ["data3"]
  256. * ]
  257. * }
  258. */
  259. data_groups: <string[][]>[],
  260. /**
  261. * Set how zero value will be treated on groups.<br>
  262. * Possible values:
  263. * - `zero`: 0 will be positioned at absolute axis zero point.
  264. * - `positive`: 0 will be positioned at the top of a stack.
  265. * - `negative`: 0 will be positioned at the bottom of a stack.
  266. * @name data․groupsZeroAs
  267. * @memberof Options
  268. * @type {string}
  269. * @default "positive"
  270. * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.Groups)
  271. * @example
  272. * data: {
  273. * groupsZeroAs: "zero" // "positive" or "negative"
  274. * }
  275. */
  276. data_groupsZeroAs: <"zero" | "positive" | "negative">"positive",
  277. /**
  278. * Set color converter function.<br><br>
  279. * This option should a function and the specified function receives color (e.g. '#ff0000') and d that has data parameters like id, value, index, etc. And it must return a string that represents color (e.g. '#00ff00').
  280. * @name data․color
  281. * @memberof Options
  282. * @type {Function}
  283. * @default undefined
  284. * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataColor)
  285. * @example
  286. * data: {
  287. * color: function(color, d) { ... }
  288. * }
  289. */
  290. data_color: <Function | undefined>undefined,
  291. /**
  292. * Set color for each data.
  293. * @name data․colors
  294. * @memberof Options
  295. * @type {object}
  296. * @default {}
  297. * @example
  298. * data: {
  299. * colors: {
  300. * data1: "#ff0000",
  301. * data2: function(d) {
  302. * return "#000";
  303. * }
  304. * ...
  305. * }
  306. * }
  307. */
  308. data_colors: <{[key: string]: string | (() => string)}>{},
  309. /**
  310. * Set labels options
  311. * @name data․labels
  312. * @memberof Options
  313. * @type {object}
  314. * @property {object} data Data object
  315. * @property {boolean} [data.labels=false] Show or hide labels on each data points
  316. * @property {boolean} [data.labels.centered=false] Centerize labels on `bar` shape. (**NOTE:** works only for 'bar' type)
  317. * @property {Function} [data.labels.format] Set formatter function for data labels.<br>
  318. * The formatter function receives 4 arguments such as `v, id, i, texts` and it **must return a string** (`\n` character will be used as line break) that will be shown as the label.<br><br>
  319. * The arguments are:<br>
  320. * - `v` is the value of the data point where the label is shown.
  321. * - `id` is the id of the data where the label is shown.
  322. * - `i` is the index of the data series point where the label is shown.
  323. * - `texts` is the array of whole corresponding data series' text labels.<br><br>
  324. * Formatter function can be defined for each data by specifying as an object and D3 formatter function can be set (ex. d3.format('$'))
  325. * @property {string|object} [data.labels.backgroundColors] Set label text background colors.
  326. * @property {string|object|Function} [data.labels.colors] Set label text colors.
  327. * @property {object|Function} [data.labels.position] Set each dataset position, relative the original.<br><br>
  328. * When function is specified, will receives 5 arguments such as `type, v, id, i, texts` and it must return a position number.<br><br>
  329. * The arguments are:<br>
  330. * - `type` coordinate type string, which will be 'x' or 'y'.
  331. * - `v` is the value of the data point where the label is shown.
  332. * - `id` is the id of the data where the label is shown.
  333. * - `i` is the index of the data series point where the label is shown.
  334. * - `texts` is the array of whole corresponding data series' text labels.<br><br>
  335. * @property {number} [data.labels.position.x=0] x coordinate position, relative the original.
  336. * @property {number} [data.labels.position.y=0] y coordinate position, relative the original.
  337. * @property {object} [data.labels.rotate] Rotate label text. Specify degree value in a range of `0 ~ 360`.
  338. * - **NOTE:** Depend on rotate value, text position need to be adjusted manually(using `data.labels.position` option) to be shown nicely.
  339. * @memberof Options
  340. * @type {object}
  341. * @default {}
  342. * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataLabel)
  343. * @see [Demo: label colors](https://naver.github.io/billboard.js/demo/#Data.DataLabelColors)
  344. * @see [Demo: label format](https://naver.github.io/billboard.js/demo/#Data.DataLabelFormat)
  345. * @see [Demo: label multiline](https://naver.github.io/billboard.js/demo/#Data.DataLabelMultiline)
  346. * @see [Demo: label overlap](https://naver.github.io/billboard.js/demo/#Data.DataLabelOverlap)
  347. * @see [Demo: label position](https://naver.github.io/billboard.js/demo/#Data.DataLabelPosition)
  348. * @see [Demo: label rotate](https://naver.github.io/billboard.js/demo/#Data.DataLabelRotate)
  349. * @example
  350. * data: {
  351. * labels: true,
  352. *
  353. * // or set specific options
  354. * labels: {
  355. * format: function(v, id, i, texts) {
  356. * ...
  357. * // to multiline, return with '\n' character
  358. * return "Line1\nLine2";
  359. * },
  360. *
  361. * // it's possible to set for each data
  362. * format: {
  363. * data1: function(v, id, i, texts) { ... },
  364. * ...
  365. * },
  366. *
  367. * // align text to center of the 'bar' shape (works only for 'bar' type)
  368. * centered: true,
  369. *
  370. * // apply backgound color for label texts
  371. * backgroundColors: "red",
  372. *
  373. * // set differenct backround colors per dataset
  374. * backgroundColors: {
  375. * data1: "green",
  376. * data2: "yellow"
  377. * }
  378. *
  379. * // apply for all label texts
  380. * colors: "red",
  381. *
  382. * // set different colors per dataset
  383. * // for not specified dataset, will have the default color value
  384. * colors: {
  385. * data1: "yellow",
  386. * data3: "green"
  387. * },
  388. *
  389. * // call back for label text color
  390. * colors: function(color, d) {
  391. * // color: the default data label color string
  392. * // data: ex) {x: 0, value: 200, id: "data3", index: 0}
  393. * ....
  394. * return d.value > 200 ? "cyan" : color;
  395. * },
  396. *
  397. * // return x, y coordinate position
  398. * // apt to handle each text position manually
  399. * position: function(type, v, id, i, texts) {
  400. * ...
  401. * return type == "x" ? 10 : 20;
  402. * },
  403. *
  404. * // set x, y coordinate position
  405. * position: {
  406. * x: -10,
  407. * y: 10
  408. * },
  409. *
  410. * // or set x, y coordinate position by each dataset
  411. * position: {
  412. * data1: {x: 5, y: 5},
  413. * data2: {x: 10, y: -20}
  414. * },
  415. *
  416. * // rotate degree for label text
  417. * rotate: 90
  418. * }
  419. * }
  420. */
  421. data_labels: <boolean | {
  422. centered?: boolean,
  423. format?: (v: number, id: string, i: number, texts: d3Selection) => number,
  424. colors?: string | {[key: string]: string},
  425. position?: (type: "x" | "y", v: number, id: string, i: number, texts: d3Selection) =>
  426. | number
  427. | {[key: string]: number}
  428. | {[key: string]: {x?: number, y?: number}},
  429. rotate?: number
  430. }>{},
  431. data_labels_backgroundColors: <string | {[key: string]: string} | undefined>undefined,
  432. data_labels_colors: <string | object | Function | undefined>undefined,
  433. data_labels_position: {},
  434. /**
  435. * Hide each data when the chart appears.<br><br>
  436. * If true specified, all of data will be hidden. If multiple ids specified as an array, those will be hidden.
  437. * @name data․hide
  438. * @memberof Options
  439. * @type {boolean|Array}
  440. * @default false
  441. * @example
  442. * data: {
  443. * // all of data will be hidden
  444. * hide: true
  445. *
  446. * // specified data will be hidden
  447. * hide: ["data1", ...]
  448. * }
  449. */
  450. data_hide: <string[] | boolean>false,
  451. /**
  452. * Filter values to be shown
  453. * The data value is the same as the returned by `.data()`.
  454. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
  455. * @name data․filter
  456. * @memberof Options
  457. * @type {Function}
  458. * @default undefined
  459. * @example
  460. * data: {
  461. * // filter for id value
  462. * filter: function(v) {
  463. * // v: [{id: "data1", id_org: "data1", values: [
  464. * // {x: 0, value: 130, id: "data2", index: 0}, ...]
  465. * // }, ...]
  466. * return v.id !== "data1";
  467. * }
  468. */
  469. data_filter: <(() => boolean) | undefined>undefined,
  470. /**
  471. * Set a callback for click event on each data point.<br><br>
  472. * This callback will be called when each data point clicked and will receive `d` and element as the arguments.
  473. * - `d` is the data clicked and element is the element clicked.
  474. * - `element` is the current interacting svg element.
  475. * - In this callback, `this` will be the Chart object.
  476. * @name data․onclick
  477. * @memberof Options
  478. * @type {Function}
  479. * @default function() {}
  480. * @example
  481. * data: {
  482. * onclick: function(d, element) {
  483. * // d - ex) {x: 4, value: 150, id: "data1", index: 4, name: "data1"}
  484. * // element - <circle>
  485. * ...
  486. * }
  487. * }
  488. */
  489. data_onclick: () => {},
  490. /**
  491. * Set a callback for mouse/touch over event on each data point.<br><br>
  492. * This callback will be called when mouse cursor or via touch moves onto each data point and will receive `d` and `element` as the argument.
  493. * - `d` is the data where mouse cursor moves onto.
  494. * - `element` is the current interacting svg element.
  495. * - In this callback, `this` will be the Chart object.
  496. * @name data․onover
  497. * @memberof Options
  498. * @type {Function}
  499. * @default function() {}
  500. * @example
  501. * data: {
  502. * onover: function(d, element) {
  503. * // d - ex) {x: 4, value: 150, id: "data1", index: 4}
  504. * // element - <circle>
  505. * ...
  506. * }
  507. * }
  508. */
  509. data_onover: () => {},
  510. /**
  511. * Set a callback for mouse/touch out event on each data point.<br><br>
  512. * This callback will be called when mouse cursor or via touch moves out each data point and will receive `d` as the argument.
  513. * - `d` is the data where mouse cursor moves out.
  514. * - `element` is the current interacting svg element.
  515. * - In this callback, `this` will be the Chart object.
  516. * @name data․onout
  517. * @memberof Options
  518. * @type {Function}
  519. * @default function() {}
  520. * @example
  521. * data: {
  522. * onout: function(d, element) {
  523. * // d - ex) {x: 4, value: 150, id: "data1", index: 4}
  524. * // element - <circle>
  525. * ...
  526. * }
  527. * }
  528. */
  529. data_onout: () => {},
  530. /**
  531. * Set a callback for when data is shown.<br>
  532. * The callback will receive shown data ids in array.
  533. * @name data․onshown
  534. * @memberof Options
  535. * @type {Function}
  536. * @default undefined
  537. * @example
  538. * data: {
  539. * onshown: function(ids) {
  540. * // ids - ["data1", "data2", ...]
  541. * ...
  542. * }
  543. * }
  544. */
  545. data_onshown: <Function | undefined>undefined,
  546. /**
  547. * Set a callback for when data is hidden.<br>
  548. * The callback will receive hidden data ids in array.
  549. * @name data․onhidden
  550. * @memberof Options
  551. * @type {Function}
  552. * @default undefined
  553. * @example
  554. * data: {
  555. * onhidden: function(ids) {
  556. * // ids - ["data1", "data2", ...]
  557. * ...
  558. * }
  559. * }
  560. */
  561. data_onhidden: <Function | undefined>undefined,
  562. /**
  563. * Set a callback for minimum data
  564. * - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
  565. * @name data․onmin
  566. * @memberof Options
  567. * @type {Function}
  568. * @default undefined
  569. * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.OnMinMaxCallback)
  570. * @example
  571. * onmin: function(data) {
  572. * // data - ex) [{x: 3, value: 400, id: "data1", index: 3}, ... ]
  573. * ...
  574. * }
  575. */
  576. data_onmin: <Function | undefined>undefined,
  577. /**
  578. * Set a callback for maximum data
  579. * - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
  580. * @name data․onmax
  581. * @memberof Options
  582. * @type {Function}
  583. * @default undefined
  584. * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.OnMinMaxCallback)
  585. * @example
  586. * onmax: function(data) {
  587. * // data - ex) [{x: 3, value: 400, id: "data1", index: 3}, ... ]
  588. * ...
  589. * }
  590. */
  591. data_onmax: <Function | undefined>undefined,
  592. /**
  593. * Load a CSV or JSON file from a URL. NOTE that this will not work if loading via the "file://" protocol as the most browsers will block XMLHTTPRequests.
  594. * @name data․url
  595. * @memberof Options
  596. * @type {string}
  597. * @default undefined
  598. * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.LoadData)
  599. * @example
  600. * data: {
  601. * url: "/data/test.csv"
  602. * }
  603. */
  604. data_url: <string | undefined>undefined,
  605. /**
  606. * XHR header value
  607. * - **NOTE:** Should be used with `data.url` option
  608. * @name data․headers
  609. * @memberof Options
  610. * @type {string}
  611. * @default undefined
  612. * @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader
  613. * @example
  614. * data: {
  615. * url: "/data/test.csv",
  616. * headers: {
  617. * "Content-Type": "text/xml",
  618. * ...
  619. * }
  620. * }
  621. */
  622. data_headers: <object | undefined>undefined,
  623. /**
  624. * Parse a JSON object for data. See also data.keys.
  625. * @name data․json
  626. * @memberof Options
  627. * @type {Array}
  628. * @default undefined
  629. * @see [data․keys](#.data%25E2%2580%25A4keys)
  630. * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.JSONData)
  631. * @example
  632. * data: {
  633. * json: [
  634. * {name: "www.site1.com", upload: 200, download: 200, total: 400},
  635. * {name: "www.site2.com", upload: 100, download: 300, total: 400},
  636. * {name: "www.site3.com", upload: 300, download: 200, total: 500},
  637. * {name: "www.site4.com", upload: 400, download: 100, total: 500}
  638. * ],
  639. * keys: {
  640. * // case 1: specify 'x' key for category axis
  641. * x: "name", // 'name' key will be used as category x axis values
  642. * value: ["upload", "download"]
  643. *
  644. * // case 2: without 'x' key for non-category axis
  645. * value: ["upload", "download"]
  646. * }
  647. * }
  648. */
  649. data_json: <object[] | undefined>undefined,
  650. /**
  651. * Load data from a multidimensional array, with the first element containing the data names, the following containing related data in that order.
  652. * @name data․rows
  653. * @memberof Options
  654. * @type {Array}
  655. * @default undefined
  656. * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.RowOrientedData)
  657. * @example
  658. * data: {
  659. * rows: [
  660. * ["A", "B", "C"],
  661. * [90, 120, 300],
  662. * [40, 160, 240],
  663. * [50, 200, 290],
  664. * [120, 160, 230],
  665. * [80, 130, 300],
  666. * [90, 220, 320]
  667. * ]
  668. * }
  669. *
  670. * // for 'bar' type, data can contain:
  671. * // - an array of [start, end] data following the order
  672. * data: {
  673. * rows: [
  674. * ["data1", "data2"],
  675. * [[100, 150], 120],
  676. * [[200, 300], 55],
  677. * [[-400, 500], 60]
  678. * ],
  679. * type: "bar"
  680. * }
  681. *
  682. * // for 'range' types('area-line-range' or 'area-step-range' or 'area-spline-range'), data should contain:
  683. * // - an array of [high, mid, low] data following the order
  684. * // - or an object with 'high', 'mid' and 'low' key value
  685. * data: {
  686. * rows: [
  687. * ["data1", "data2"],
  688. * [
  689. * // or {high:150, mid: 140, low: 110}, 120
  690. * [150, 140, 110], 120
  691. * ],
  692. * [[155, 130, 115], 55],
  693. * [[160, 135, 120], 60]
  694. * ],
  695. * types: {
  696. * data1: "area-line-range",
  697. * data2: "line"
  698. * }
  699. * }
  700. *
  701. * // for 'bubble' type, data can contain dimension value:
  702. * // - an array of [y, z] data following the order
  703. * // - or an object with 'y' and 'z' key value
  704. * // 'y' is for y axis coordination and 'z' is the bubble radius value
  705. * data: {
  706. * rows: [
  707. * ["data1", "data2"],
  708. * [
  709. * // or {y:10, z: 140}, 120
  710. * [10, 140], 120
  711. * ],
  712. * [[100, 30], 55],
  713. * [[50, 100], 60]
  714. * ],
  715. * types: {
  716. * data1: "bubble",
  717. * data2: "line"
  718. * }
  719. * }
  720. *
  721. * // for 'canlestick' type, data should contain:
  722. * // - an array of [open, high, low, close, volume(optional)] data following the order
  723. * // - or an object with 'open', 'high', 'low', 'close' and 'value'(optional) key value
  724. * data: {
  725. * rows: [
  726. * ["data1", "data2"],
  727. * [
  728. * // open, high, low, close, volume (optional)
  729. * {open: 1300, high: 1369, low: 1200, close: 1339, volume: 100},
  730. * [1000, 1100, 850, 870]
  731. * ],
  732. * [
  733. * {open: 1348, high: 1371, low: 1271, close: 1320},
  734. * [870, 1250, 830, 1200, 50]
  735. * ]
  736. * ],
  737. * type: "candlestick"
  738. * }
  739. */
  740. data_rows: <(string | number)[][] | undefined>undefined,
  741. /**
  742. * Load data from a multidimensional array, with each element containing an array consisting of a datum name and associated data values.
  743. * @name data․columns
  744. * @memberof Options
  745. * @type {Array}
  746. * @default undefined
  747. * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.ColumnOrientedData)
  748. * @example
  749. * data: {
  750. * columns: [
  751. * ["data1", 30, 20, 50, 40, 60, 50],
  752. * ["data2", 200, 130, 90, 240, 130, 220],
  753. * ["data3", 300, 200, 160, 400, 250, 250]
  754. * ]
  755. * }
  756. *
  757. * // for 'bar' type, data can contain:
  758. * // - an array of [start, end] data following the order
  759. * data: {
  760. * columns: [
  761. * ["data1", -100, 50, [100, 200], [200, 300]],
  762. * ["data2", -200, 300, [-100, 100], [-50, -30]],
  763. * ],
  764. * type: "bar"
  765. * }
  766. *
  767. * // for 'range' types('area-line-range' or 'area-step-range' or 'area-spline-range'), data should contain:
  768. * // - an array of [high, mid, low] data following the order
  769. * // - or an object with 'high', 'mid' and 'low' key value
  770. * data: {
  771. * columns: [
  772. * ["data1",
  773. * [150, 140, 110], // or {high:150, mid: 140, low: 110}
  774. * [150, 140, 110],
  775. * [150, 140, 110]
  776. * ]
  777. * ],
  778. * type: "area-line-range"
  779. * }
  780. *
  781. * // for 'bubble' type, data can contain dimension value:
  782. * // - an array of [y, z] data following the order
  783. * // - or an object with 'y' and 'z' key value
  784. * // 'y' is for y axis coordination and 'z' is the bubble radius value
  785. * data: {
  786. * columns: [
  787. * ["data1",
  788. * [10, 140], // or {y:10, z: 140}
  789. * [100, 30],
  790. * [50, 100]
  791. * ]
  792. * ],
  793. * type: "bubble"
  794. * }
  795. *
  796. * // for 'canlestick' type, data should contain:
  797. * // - an array of [open, high, low, close, volume(optional)] data following the order
  798. * // - or an object with 'open', 'high', 'low', 'close' and 'value'(optional) key value
  799. * data: {
  800. * columns: [
  801. * ["data1",
  802. * [1000, 1100, 850, 870, 100], // or {open:1000, high: 1100, low: 870, volume: 100}
  803. * [870, 1250, 830, 1200] // 'volume' can be omitted
  804. * ]
  805. * ],
  806. * type: "candlestick"
  807. * }
  808. */
  809. data_columns: <(string | number)[][] | undefined>undefined,
  810. /**
  811. * Used if loading JSON via data.url.
  812. * - **Available Values:**
  813. * - json
  814. * - csv
  815. * - tsv
  816. * @name data․mimeType
  817. * @memberof Options
  818. * @type {string}
  819. * @default csv
  820. * @example
  821. * data: {
  822. * mimeType: "json"
  823. * }
  824. */
  825. data_mimeType: <"csv" | "json" | "tsv">"csv",
  826. /**
  827. * Choose which JSON object keys correspond to desired data.
  828. * - **NOTE:** Only for JSON object given as array.
  829. * @name data․keys
  830. * @memberof Options
  831. * @type {string}
  832. * @default undefined
  833. * @example
  834. * data: {
  835. * json: [
  836. * {name: "www.site1.com", upload: 200, download: 200, total: 400},
  837. * {name: "www.site2.com", upload: 100, download: 300, total: 400},
  838. * {name: "www.site3.com", upload: 300, download: 200, total: 500},
  839. * {name: "www.site4.com", upload: 400, download: 100, total: 500}
  840. * ],
  841. * keys: {
  842. * // case 1: specify 'x' key for category axis
  843. * x: "name", // 'name' key will be used as category x axis values
  844. * value: ["upload", "download"]
  845. *
  846. * // case 2: without 'x' key for non-category axis
  847. * value: ["upload", "download"]
  848. * }
  849. * }
  850. */
  851. data_keys: <{x?: string, value?: string[]} | undefined>undefined,
  852. /**
  853. * Set text label to be displayed when there's no data to show.
  854. * - ex. Toggling all visible data to not be shown, unloading all current data, etc.
  855. * @name data․empty․label․text
  856. * @memberof Options
  857. * @type {string}
  858. * @default ""
  859. * @example
  860. * data: {
  861. * empty: {
  862. * label: {
  863. * text: "No Data"
  864. * }
  865. * }
  866. * }
  867. */
  868. data_empty_label_text: ""
  869. };