billboard.js 3.11.2 → 3.12.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/README.md +2 -6
  2. package/dist/billboard.css +5 -1
  3. package/dist/billboard.js +19431 -24292
  4. package/dist/billboard.min.css +2 -2
  5. package/dist/billboard.min.js +26 -3
  6. package/dist/billboard.pkgd.js +22301 -29057
  7. package/dist/billboard.pkgd.min.js +33 -3
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +77 -175
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -3
  10. package/dist/plugin/billboardjs-plugin-sparkline.js +423 -1134
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -3
  12. package/dist/plugin/billboardjs-plugin-stanford.js +660 -1524
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +15 -3
  14. package/dist/plugin/billboardjs-plugin-tableview.js +503 -1175
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +30 -3
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +351 -1055
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -3
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +339 -1324
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -3
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +1701 -3424
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -3
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2385 -4462
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -3
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +1783 -3467
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +33 -3
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2031 -3979
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -3
  28. package/dist/theme/dark.css +5 -1
  29. package/dist/theme/dark.min.css +2 -2
  30. package/dist/theme/datalab.css +5 -1
  31. package/dist/theme/datalab.min.css +2 -2
  32. package/dist/theme/graph.css +5 -1
  33. package/dist/theme/graph.min.css +2 -2
  34. package/dist/theme/insight.css +5 -1
  35. package/dist/theme/insight.min.css +2 -2
  36. package/dist/theme/modern.css +5 -1
  37. package/dist/theme/modern.min.css +3 -4
  38. package/dist-esm/billboard.js +9051 -8666
  39. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +19 -25
  40. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +149 -148
  41. package/dist-esm/plugin/billboardjs-plugin-stanford.js +295 -286
  42. package/dist-esm/plugin/billboardjs-plugin-tableview.js +235 -234
  43. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +40 -41
  44. package/package.json +26 -46
  45. package/src/Chart/api/axis.ts +6 -13
  46. package/src/Chart/api/chart.ts +12 -11
  47. package/src/Chart/api/data.ts +8 -7
  48. package/src/Chart/api/export.ts +28 -21
  49. package/src/Chart/api/flow.ts +4 -2
  50. package/src/Chart/api/grid.ts +1 -5
  51. package/src/Chart/api/load.ts +2 -2
  52. package/src/Chart/api/regions.ts +29 -5
  53. package/src/Chart/api/selection.ts +2 -2
  54. package/src/Chart/api/show.ts +2 -3
  55. package/src/Chart/api/subchart.ts +2 -2
  56. package/src/Chart/api/tooltip.ts +5 -7
  57. package/src/Chart/api/x.ts +2 -2
  58. package/src/Chart/api/zoom.ts +2 -2
  59. package/src/ChartInternal/Axis/Axis.ts +119 -44
  60. package/src/ChartInternal/Axis/AxisRenderer.ts +53 -38
  61. package/src/ChartInternal/Axis/AxisRendererHelper.ts +2 -2
  62. package/src/ChartInternal/ChartInternal.ts +79 -51
  63. package/src/ChartInternal/data/IData.ts +22 -29
  64. package/src/ChartInternal/data/convert.helper.ts +66 -68
  65. package/src/ChartInternal/data/convert.ts +11 -11
  66. package/src/ChartInternal/data/data.ts +40 -23
  67. package/src/ChartInternal/data/load.ts +7 -6
  68. package/src/ChartInternal/interactions/drag.ts +2 -1
  69. package/src/ChartInternal/interactions/eventrect.ts +54 -25
  70. package/src/ChartInternal/interactions/flow.ts +14 -4
  71. package/src/ChartInternal/interactions/interaction.ts +34 -12
  72. package/src/ChartInternal/interactions/subchart.ts +27 -25
  73. package/src/ChartInternal/interactions/zoom.ts +29 -18
  74. package/src/ChartInternal/internals/category.ts +1 -1
  75. package/src/ChartInternal/internals/class.ts +5 -5
  76. package/src/ChartInternal/internals/clip.ts +9 -10
  77. package/src/ChartInternal/internals/color.ts +70 -42
  78. package/src/ChartInternal/internals/domain.ts +59 -28
  79. package/src/ChartInternal/internals/format.ts +5 -5
  80. package/src/ChartInternal/internals/grid.ts +130 -47
  81. package/src/ChartInternal/internals/legend.ts +99 -66
  82. package/src/ChartInternal/internals/redraw.ts +3 -2
  83. package/src/ChartInternal/internals/region.ts +5 -3
  84. package/src/ChartInternal/internals/scale.ts +28 -15
  85. package/src/ChartInternal/internals/selection.ts +14 -13
  86. package/src/ChartInternal/internals/size.axis.ts +18 -10
  87. package/src/ChartInternal/internals/size.ts +97 -66
  88. package/src/ChartInternal/internals/style.ts +21 -19
  89. package/src/ChartInternal/internals/text.ts +64 -39
  90. package/src/ChartInternal/internals/title.ts +2 -2
  91. package/src/ChartInternal/internals/tooltip.ts +83 -34
  92. package/src/ChartInternal/internals/transform.ts +2 -2
  93. package/src/ChartInternal/internals/type.ts +12 -12
  94. package/src/ChartInternal/shape/arc.ts +78 -44
  95. package/src/ChartInternal/shape/area.ts +19 -22
  96. package/src/ChartInternal/shape/bar.ts +41 -31
  97. package/src/ChartInternal/shape/bubble.ts +5 -5
  98. package/src/ChartInternal/shape/candlestick.ts +15 -13
  99. package/src/ChartInternal/shape/gauge.ts +16 -9
  100. package/src/ChartInternal/shape/line.ts +62 -46
  101. package/src/ChartInternal/shape/point.common.ts +1 -4
  102. package/src/ChartInternal/shape/point.ts +52 -32
  103. package/src/ChartInternal/shape/polar.ts +4 -2
  104. package/src/ChartInternal/shape/radar.ts +40 -22
  105. package/src/ChartInternal/shape/shape.ts +84 -58
  106. package/src/ChartInternal/shape/treemap.ts +29 -20
  107. package/src/Plugin/bubblecompare/index.ts +1 -3
  108. package/src/Plugin/sparkline/index.ts +3 -4
  109. package/src/Plugin/stanford/ColorScale.ts +3 -2
  110. package/src/Plugin/stanford/Elements.ts +15 -6
  111. package/src/Plugin/stanford/Options.ts +5 -5
  112. package/src/Plugin/stanford/index.ts +13 -9
  113. package/src/Plugin/tableview/Options.ts +1 -1
  114. package/src/Plugin/tableview/const.ts +1 -4
  115. package/src/Plugin/tableview/index.ts +11 -9
  116. package/src/Plugin/textoverlap/index.ts +4 -6
  117. package/src/config/Options/Options.ts +3 -3
  118. package/src/config/Options/axis/axis.ts +36 -0
  119. package/src/config/Options/axis/x.ts +12 -13
  120. package/src/config/Options/axis/y.ts +13 -13
  121. package/src/config/Options/axis/y2.ts +23 -10
  122. package/src/config/Options/common/color.ts +4 -4
  123. package/src/config/Options/common/grid.ts +4 -4
  124. package/src/config/Options/common/legend.ts +13 -14
  125. package/src/config/Options/common/main.ts +23 -23
  126. package/src/config/Options/common/point.ts +17 -18
  127. package/src/config/Options/common/title.ts +2 -2
  128. package/src/config/Options/common/tooltip.ts +13 -11
  129. package/src/config/Options/data/axis.ts +2 -2
  130. package/src/config/Options/data/data.ts +45 -45
  131. package/src/config/Options/interaction/interaction.ts +1 -1
  132. package/src/config/Options/interaction/subchart.ts +2 -2
  133. package/src/config/Options/interaction/zoom.ts +9 -9
  134. package/src/config/Options/shape/arc.ts +10 -13
  135. package/src/config/Options/shape/area.ts +5 -7
  136. package/src/config/Options/shape/bar.ts +8 -10
  137. package/src/config/Options/shape/bubble.ts +1 -1
  138. package/src/config/Options/shape/candlestick.ts +2 -2
  139. package/src/config/Options/shape/donut.ts +4 -4
  140. package/src/config/Options/shape/gauge.ts +6 -6
  141. package/src/config/Options/shape/line.ts +3 -3
  142. package/src/config/Options/shape/pie.ts +5 -5
  143. package/src/config/Options/shape/polar.ts +3 -3
  144. package/src/config/Options/shape/radar.ts +2 -2
  145. package/src/config/Options/shape/scatter.ts +1 -1
  146. package/src/config/Options/shape/treemap.ts +1 -1
  147. package/src/config/Store/Element.ts +8 -5
  148. package/src/config/Store/State.ts +19 -13
  149. package/src/config/classes.ts +6 -4
  150. package/src/config/config.ts +1 -1
  151. package/src/config/resolver/axis.ts +4 -4
  152. package/src/config/resolver/interaction.ts +3 -7
  153. package/src/config/resolver/shape.ts +11 -12
  154. package/src/core.ts +2 -3
  155. package/src/index.esm.ts +2 -6
  156. package/src/index.ts +2 -2
  157. package/src/module/Cache.ts +2 -3
  158. package/src/module/browser.ts +15 -10
  159. package/src/module/error.ts +9 -8
  160. package/src/module/generator.ts +3 -5
  161. package/src/module/util.ts +60 -37
  162. package/src/module/worker.ts +14 -11
  163. package/src/scss/billboard.scss +6 -0
  164. package/src/scss/theme/dark.scss +6 -0
  165. package/src/scss/theme/datalab.scss +6 -0
  166. package/src/scss/theme/graph.scss +6 -0
  167. package/src/scss/theme/insight.scss +6 -0
  168. package/src/scss/theme/modern.scss +6 -0
  169. package/types/axis.d.ts +7 -0
  170. package/types/options.d.ts +7 -0
  171. package/types/options.shape.d.ts +7 -0
@@ -3,22 +3,34 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  * @ignore
5
5
  */
6
+ import {select as d3Select} from "d3-selection";
6
7
  import {
7
- timeParse as d3TimeParse,
8
8
  timeFormat as d3TimeFormat,
9
- utcParse as d3UtcParse,
10
- utcFormat as d3UtcFormat
9
+ timeParse as d3TimeParse,
10
+ utcFormat as d3UtcFormat,
11
+ utcParse as d3UtcParse
11
12
  } from "d3-time-format";
12
- import {select as d3Select} from "d3-selection";
13
13
  import type {d3Selection} from "../../types/types";
14
- import {checkModuleImport} from "../module/error";
15
- import {$COMMON, $CIRCLE, $TEXT} from "../config/classes";
16
- import Store from "../config/Store/Store";
14
+ import {$CIRCLE, $COMMON, $TEXT} from "../config/classes";
17
15
  import Options from "../config/Options/Options";
16
+ import Store from "../config/Store/Store";
18
17
  import {document, window} from "../module/browser";
19
18
  import Cache from "../module/Cache";
19
+ import {checkModuleImport} from "../module/error";
20
20
  import {generateResize} from "../module/generator";
21
- import {capitalize, extend, notEmpty, convertInputType, getOption, getRandom, isFunction, isObject, isString, callFn, sortValue} from "../module/util";
21
+ import {
22
+ callFn,
23
+ capitalize,
24
+ convertInputType,
25
+ extend,
26
+ getOption,
27
+ getRandom,
28
+ isFunction,
29
+ isObject,
30
+ isString,
31
+ notEmpty,
32
+ sortValue
33
+ } from "../module/util";
22
34
 
23
35
  // data
24
36
  import dataConvert from "./data/convert";
@@ -29,15 +41,14 @@ import dataLoad from "./data/load";
29
41
  import interaction from "./interactions/interaction";
30
42
 
31
43
  // internals
32
- import classModule from "./internals/class";
33
44
  import category from "./internals/category"; // used to retrieve radar Axis name
45
+ import classModule from "./internals/class";
34
46
  import color from "./internals/color";
35
47
  import domain from "./internals/domain";
36
48
  import format from "./internals/format";
37
49
  import legend from "./internals/legend";
38
50
  import redraw from "./internals/redraw";
39
51
  import scale from "./internals/scale";
40
- import shape from "./shape/shape";
41
52
  import size from "./internals/size";
42
53
  import style from "./internals/style";
43
54
  import text from "./internals/text";
@@ -45,6 +56,7 @@ import title from "./internals/title";
45
56
  import tooltip from "./internals/tooltip";
46
57
  import transform from "./internals/transform";
47
58
  import typeInternals from "./internals/type";
59
+ import shape from "./shape/shape";
48
60
 
49
61
  /**
50
62
  * Internal chart class.
@@ -54,7 +66,7 @@ import typeInternals from "./internals/type";
54
66
  * @private
55
67
  */
56
68
  export default class ChartInternal {
57
- public api; // API interface
69
+ public api; // API interface
58
70
  public config; // config object
59
71
  public cache; // cache instance
60
72
  public $el; // elements
@@ -174,7 +186,7 @@ export default class ChartInternal {
174
186
  }
175
187
 
176
188
  init(): void {
177
- const $$ = <any> this;
189
+ const $$ = <any>this;
178
190
  const {config, state, $el} = $$;
179
191
  const useCssRule = config.boost_useCssRule;
180
192
 
@@ -216,7 +228,8 @@ export default class ChartInternal {
216
228
 
217
229
  // select bind element
218
230
  $el.chart = isFunction(bindto.element.node) ?
219
- config.bindto.element : d3Select(bindto.element || []);
231
+ config.bindto.element :
232
+ d3Select(bindto.element || []);
220
233
 
221
234
  if ($el.chart.empty()) {
222
235
  $el.chart = d3Select(document.body.appendChild(document.createElement("div")));
@@ -237,9 +250,10 @@ export default class ChartInternal {
237
250
  * @private
238
251
  */
239
252
  initToRender(forced?: boolean): void {
240
- const $$ = <any> this;
253
+ const $$ = <any>this;
241
254
  const {config, state, $el: {chart}} = $$;
242
- const isHidden = () => chart.style("display") === "none" || chart.style("visibility") === "hidden";
255
+ const isHidden = () =>
256
+ chart.style("display") === "none" || chart.style("visibility") === "hidden";
243
257
 
244
258
  const isLazy = config.render.lazy || isHidden();
245
259
  const MutationObserver = window.MutationObserver;
@@ -265,7 +279,7 @@ export default class ChartInternal {
265
279
  }
266
280
 
267
281
  initParams(): void {
268
- const $$ = <any> this;
282
+ const $$ = <any>this;
269
283
  const {config, format, state} = $$;
270
284
  const isRotated = config.axis_rotated;
271
285
 
@@ -296,7 +310,8 @@ export default class ChartInternal {
296
310
 
297
311
  format.defaultAxisTime = d => {
298
312
  const {x, zoom} = $$.scale;
299
- const isZoomed = isDragZoom ? zoom :
313
+ const isZoomed = isDragZoom ?
314
+ zoom :
300
315
  zoom && x.orgDomain().toString() !== zoom.domain().toString();
301
316
 
302
317
  const specifier: string = (d.getMilliseconds() && ".%L") ||
@@ -304,7 +319,7 @@ export default class ChartInternal {
304
319
  (d.getMinutes() && "%I:%M") ||
305
320
  (d.getHours() && "%I %p") ||
306
321
  (d.getDate() !== 1 && "%b %d") ||
307
- (isZoomed && d.getDate() === 1 && "%b\'%y") ||
322
+ (isZoomed && d.getDate() === 1 && "%b'%y") ||
308
323
  (d.getMonth() && "%-m/%-d") || "%Y";
309
324
 
310
325
  return format.axisTime(specifier)(d);
@@ -330,11 +345,12 @@ export default class ChartInternal {
330
345
  }
331
346
 
332
347
  initWithData(data): void {
333
- const $$ = <any> this;
348
+ const $$ = <any>this;
334
349
  const {config, scale, state, $el, org} = $$;
335
350
  const {hasAxis, hasTreemap} = state;
336
351
  const hasInteraction = config.interaction_enabled;
337
352
  const hasPolar = $$.hasType("polar");
353
+ const labelsBGColor = config.data_labels_backgroundColors;
338
354
 
339
355
  // for arc type, set axes to not be shown
340
356
  // $$.hasArcType() && ["x", "y", "y2"].forEach(id => (config[`axis_${id}_show`] = false));
@@ -355,15 +371,13 @@ export default class ChartInternal {
355
371
  // Set targets to hide if needed
356
372
  if (config.data_hide) {
357
373
  $$.addHiddenTargetIds(
358
- config.data_hide === true ?
359
- $$.mapToIds($$.data.targets) : config.data_hide
374
+ config.data_hide === true ? $$.mapToIds($$.data.targets) : config.data_hide
360
375
  );
361
376
  }
362
377
 
363
378
  if (config.legend_hide) {
364
379
  $$.addHiddenLegendIds(
365
- config.legend_hide === true ?
366
- $$.mapToIds($$.data.targets) : config.legend_hide
380
+ config.legend_hide === true ? $$.mapToIds($$.data.targets) : config.legend_hide
367
381
  );
368
382
  }
369
383
 
@@ -413,20 +427,22 @@ export default class ChartInternal {
413
427
  config.svg_classname && $el.svg.attr("class", config.svg_classname);
414
428
 
415
429
  // Define defs
416
- const hasColorPatterns = (isFunction(config.color_tiles) && $$.patterns);
430
+ const hasColorPatterns = isFunction(config.color_tiles) && $$.patterns;
417
431
 
418
- if (hasAxis || hasColorPatterns || hasPolar || hasTreemap ||
419
- config.data_labels_backgroundColors || $$.hasLegendDefsPoint?.()) {
432
+ if (
433
+ hasAxis || hasColorPatterns || hasPolar || hasTreemap ||
434
+ labelsBGColor || $$.hasLegendDefsPoint?.()
435
+ ) {
420
436
  $el.defs = $el.svg.append("defs");
421
437
 
422
438
  if (hasAxis) {
423
- ["id", "idXAxis", "idYAxis", "idGrid"].forEach(v => {
439
+ ["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach(v => {
424
440
  $$.appendClip($el.defs, state.clip[v]);
425
441
  });
426
442
  }
427
443
 
428
444
  // Append data background color filter definition
429
- $$.generateDataLabelBackgroundColorFilter();
445
+ $$.generateTextBGColorFilter(labelsBGColor);
430
446
 
431
447
  // set color patterns
432
448
  if (hasColorPatterns) {
@@ -530,7 +546,7 @@ export default class ChartInternal {
530
546
  * @private
531
547
  */
532
548
  initChartElements(): void {
533
- const $$ = <any> this;
549
+ const $$ = <any>this;
534
550
  const {hasAxis, hasRadar, hasTreemap} = $$.state;
535
551
  const types: string[] = [];
536
552
 
@@ -579,16 +595,26 @@ export default class ChartInternal {
579
595
  */
580
596
  setChartElements(): void {
581
597
  const $$ = this;
582
- const {$el: {
583
- chart, svg, defs, main, tooltip, legend, title, grid, needle,
584
- arcs: arc,
585
- circle: circles,
586
- bar: bars,
587
- candlestick,
588
- line: lines,
589
- area: areas,
590
- text: texts,
591
- }} = $$;
598
+ const {
599
+ $el: {
600
+ chart,
601
+ svg,
602
+ defs,
603
+ main,
604
+ tooltip,
605
+ legend,
606
+ title,
607
+ grid,
608
+ needle,
609
+ arcs: arc,
610
+ circle: circles,
611
+ bar: bars,
612
+ candlestick,
613
+ line: lines,
614
+ area: areas,
615
+ text: texts
616
+ }
617
+ } = $$;
592
618
 
593
619
  // public
594
620
  $$.api.$ = {
@@ -643,11 +669,12 @@ export default class ChartInternal {
643
669
  * @private
644
670
  */
645
671
  updateTargets(targets): void {
646
- const $$ = <any> this;
672
+ const $$ = <any>this;
647
673
  const {hasAxis, hasRadar, hasTreemap} = $$.state;
648
- const helper = type => $$[`updateTargetsFor${type}`](
649
- targets.filter($$[`is${type}Type`].bind($$))
650
- );
674
+ const helper = type =>
675
+ $$[`updateTargetsFor${type}`](
676
+ targets.filter($$[`is${type}Type`].bind($$))
677
+ );
651
678
 
652
679
  // Text
653
680
  $$.updateTargetsForText(targets);
@@ -665,7 +692,7 @@ export default class ChartInternal {
665
692
  $$.updateTargetsForSubchart &&
666
693
  $$.updateTargetsForSubchart(targets);
667
694
 
668
- // Arc, Polar, Radar
695
+ // Arc, Polar, Radar
669
696
  } else if ($$.hasArcType(targets)) {
670
697
  let type = "Arc";
671
698
 
@@ -676,7 +703,7 @@ export default class ChartInternal {
676
703
  }
677
704
 
678
705
  helper(type);
679
- // Arc, Polar, Radar
706
+ // Arc, Polar, Radar
680
707
  } else if (hasTreemap) {
681
708
  helper("Treemap");
682
709
  }
@@ -698,7 +725,7 @@ export default class ChartInternal {
698
725
  * @private
699
726
  */
700
727
  filterTargetsToShowAtInit(hasPointType: boolean = false): void {
701
- const $$ = <any> this;
728
+ const $$ = <any>this;
702
729
  const {$el: {svg}, $T} = $$;
703
730
  let selector = `.${$COMMON.target}`;
704
731
 
@@ -707,8 +734,7 @@ export default class ChartInternal {
707
734
  }
708
735
 
709
736
  $T(svg.selectAll(selector)
710
- .filter(d => $$.isTargetToShow(d.id))
711
- ).style("opacity", null);
737
+ .filter(d => $$.isTargetToShow(d.id))).style("opacity", null);
712
738
  }
713
739
 
714
740
  getWithOption(options) {
@@ -742,17 +768,19 @@ export default class ChartInternal {
742
768
  }
743
769
 
744
770
  initialOpacity(d): null | "0" {
745
- const $$ = <any> this;
771
+ const $$ = <any>this;
746
772
  const {withoutFadeIn} = $$.state;
747
773
 
748
774
  const r = $$.getBaseValue(d) !== null &&
749
- withoutFadeIn[d.id] ? null : "0";
775
+ withoutFadeIn[d.id] ?
776
+ null :
777
+ "0";
750
778
 
751
779
  return r;
752
780
  }
753
781
 
754
782
  bindResize(): void {
755
- const $$ = <any> this;
783
+ const $$ = <any>this;
756
784
  const {config, state} = $$;
757
785
  const resizeFunction = generateResize(config.resize_timer);
758
786
  const list: Function[] = [];
@@ -3,62 +3,55 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  * @ignore
5
5
  */
6
- type TDataRow = {
7
- value: number | null;
8
- id: string;
9
- index: number;
10
- name?: string;
11
- };
6
+ type TDataRow = {value: number | null, id: string, index: number, name?: string};
12
7
 
13
8
  export type TDomain = Date | number;
14
9
  export type TDomainRange = [TDomain, TDomain];
15
10
 
16
11
  export interface ITreemapData {
17
- name: string;
18
- id?: string; // for compatibility
19
- value?: number;
20
- ratio?: number;
21
- children?: ITreemapData[];
12
+ name: string;
13
+ id?: string; // for compatibility
14
+ value?: number;
15
+ ratio?: number;
16
+ children?: ITreemapData[];
22
17
  }
23
18
 
24
19
  export interface IDataRow extends TDataRow {
25
- x: TDomain & string;
20
+ x: TDomain & string;
26
21
  }
27
22
 
28
23
  export interface IDataPoint extends IDataRow {
29
- r: number;
24
+ r: number;
30
25
  }
31
26
 
32
27
  export interface IArcDataRow extends TDataRow {
33
- ratio: number;
28
+ ratio: number;
34
29
  }
35
30
 
36
31
  export interface IData {
37
- id: string;
38
- id_org: string;
39
- values: IDataRow[];
32
+ id: string;
33
+ id_org: string;
34
+ values: IDataRow[];
40
35
  }
41
36
 
42
37
  export interface IArcData {
43
- data: IData;
44
- index: number;
45
- padAngle: number;
46
- startAngle: number;
47
- endAngle: number;
48
- value: number | null;
38
+ data: IData;
39
+ index: number;
40
+ padAngle: number;
41
+ startAngle: number;
42
+ endAngle: number;
43
+ value: number | null;
49
44
  }
50
45
 
51
46
  export interface IGridData {
52
- axis?: string;
47
+ axis?: string;
53
48
  text: string;
54
49
  value: number;
55
50
  }
56
51
 
57
52
  export interface IDataIndice {
58
- [key: string]: number;
59
- __max__: number;
53
+ [key: string]: number;
54
+ __max__: number;
60
55
  }
61
56
 
62
- export type TIndices = {} | {
63
- [key:string]: IDataIndice
64
- };
57
+ export type TIndices = {} | {[key: string]: IDataIndice};
@@ -6,12 +6,12 @@
6
6
  /* eslint-disable */
7
7
  import {
8
8
  csvParse as d3CsvParse,
9
- tsvParse as d3TsvParse,
10
9
  csvParseRows as d3CsvParseRows,
11
- tsvParseRows as d3TsvParseRows,
10
+ tsvParse as d3TsvParse,
11
+ tsvParseRows as d3TsvParseRows
12
12
  } from "d3-dsv";
13
13
 
14
- export {columns, json, rows, url, csv, tsv};
14
+ export {columns, csv, json, rows, tsv, url};
15
15
 
16
16
  /***** Functions to be executed on Web Worker *****
17
17
  * NOTE: Don't allowed to use
@@ -84,66 +84,65 @@ function rows(rows) {
84
84
  * @private
85
85
  */
86
86
  function json(json, keysParam) {
87
- const newRows: string[][] = [];
88
- let targetKeys: string[];
89
- let data;
87
+ const newRows: string[][] = [];
88
+ let targetKeys: string[];
89
+ let data;
90
90
 
91
- if (Array.isArray(json)) {
91
+ if (Array.isArray(json)) {
92
92
  const findValueInJson = function(object, path) {
93
93
  if (object[path] !== undefined) {
94
94
  return object[path];
95
95
  }
96
-
96
+
97
97
  const convertedPath = path.replace(/\[(\w+)\]/g, ".$1"); // convert indexes to properties (replace [] with .)
98
98
  const pathArray = convertedPath.replace(/^\./, "").split("."); // strip a leading dot
99
99
  let target = object;
100
-
100
+
101
101
  pathArray.some(function(k) {
102
102
  return !(
103
- target = target && k in target ?
104
- target[k] : undefined
103
+ target = target && k in target ? target[k] : undefined
105
104
  );
106
105
  });
107
-
106
+
108
107
  return target;
109
108
  };
110
109
 
111
- if (keysParam.x) {
112
- targetKeys = keysParam.value.concat(keysParam.x);
113
- } else {
114
- targetKeys = keysParam.value;
115
- }
110
+ if (keysParam.x) {
111
+ targetKeys = keysParam.value.concat(keysParam.x);
112
+ } else {
113
+ targetKeys = keysParam.value;
114
+ }
116
115
 
117
- newRows.push(targetKeys);
116
+ newRows.push(targetKeys);
118
117
 
119
- json.forEach(function(o) {
120
- const newRow = targetKeys.map(function(key) {
121
- // convert undefined to null because undefined data will be removed in convertDataToTargets()
122
- let v = findValueInJson(o, key);
118
+ json.forEach(function(o) {
119
+ const newRow = targetKeys.map(function(key) {
120
+ // convert undefined to null because undefined data will be removed in convertDataToTargets()
121
+ let v = findValueInJson(o, key);
123
122
 
124
- if (typeof v === "undefined") {
125
- v = null;
126
- }
123
+ if (typeof v === "undefined") {
124
+ v = null;
125
+ }
127
126
 
128
- return v;
129
- });
127
+ return v;
128
+ });
130
129
 
131
- newRows.push(newRow);
132
- });
130
+ newRows.push(newRow);
131
+ });
133
132
 
134
- data = rows(newRows);
135
- } else {
136
- Object.keys(json).forEach(function(key) {
137
- const tmp = json[key].concat();
133
+ data = rows(newRows);
134
+ } else {
135
+ Object.keys(json).forEach(function(key) {
136
+ const tmp = json[key].concat();
138
137
 
139
- tmp.unshift?.(key);
140
- newRows.push(tmp);
141
- });
138
+ tmp.unshift?.(key);
139
+ newRows.push(tmp);
140
+ });
142
141
 
143
- data = columns(newRows);
144
- }
142
+ data = columns(newRows);
143
+ }
145
144
 
146
- return data;
145
+ return data;
147
146
  }
148
147
 
149
148
  /***** Functions can't be executed on Web Worker *****/
@@ -157,34 +156,33 @@ function json(json, keysParam) {
157
156
  * @private
158
157
  */
159
158
  function url(url: string, mimeType = "csv", headers: object, keys: object, done: Function): void {
160
- const req = new XMLHttpRequest();
161
- const converter = {csv, tsv, json};
162
-
163
- req.open("GET", url);
164
-
165
- if (headers) {
166
- Object.keys(headers).forEach(function(key) {
167
- req.setRequestHeader(key, headers[key]);
168
- });
169
- }
170
-
171
- req.onreadystatechange = function() {
172
- if (req.readyState === 4) {
173
- if (req.status === 200) {
174
- const response = req.responseText;
175
-
176
- response && done.call(this,
177
- converter[mimeType](
178
- mimeType === "json" ? JSON.parse(response) : response,
179
- keys
180
- ));
181
- } else {
182
- throw new Error(`${url}: Something went wrong loading!`);
183
- }
184
- }
185
- };
186
-
187
- req.send();
159
+ const req = new XMLHttpRequest();
160
+ const converter = {csv, tsv, json};
161
+
162
+ req.open("GET", url);
163
+
164
+ if (headers) {
165
+ Object.keys(headers).forEach(function(key) {
166
+ req.setRequestHeader(key, headers[key]);
167
+ });
168
+ }
169
+
170
+ req.onreadystatechange = function() {
171
+ if (req.readyState === 4) {
172
+ if (req.status === 200) {
173
+ const response = req.responseText;
174
+
175
+ response && done.call(this, converter[mimeType](
176
+ mimeType === "json" ? JSON.parse(response) : response,
177
+ keys
178
+ ));
179
+ } else {
180
+ throw new Error(`${url}: Something went wrong loading!`);
181
+ }
182
+ }
183
+ };
184
+
185
+ req.send();
188
186
  }
189
187
 
190
188
  /**
@@ -194,7 +192,7 @@ function url(url: string, mimeType = "csv", headers: object, keys: object, done:
194
192
  * @returns {object}
195
193
  * @private
196
194
  */
197
- function convertCsvTsvToData(parser, xsv) {
195
+ function convertCsvTsvToData(parser, xsv) {
198
196
  const rows = parser.rows(xsv);
199
197
  let d;
200
198
 
@@ -2,10 +2,10 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
- import {isUndefined, isDefined, isObject, isValue, notEmpty, isArray} from "../../module/util";
5
+ import {isArray, isDefined, isObject, isUndefined, isValue, notEmpty} from "../../module/util";
6
6
  import {runWorker} from "../../module/worker";
7
- import {columns, json, rows, url} from "./convert.helper";
8
7
  import type {IData} from "../data/IData";
8
+ import {columns, json, rows, url} from "./convert.helper";
9
9
 
10
10
  /**
11
11
  * Get data key for JSON
@@ -55,10 +55,8 @@ export default {
55
55
  }
56
56
 
57
57
  if (data.url && callback) {
58
- url(data.url, data.mimeType, data.headers,
59
- getDataKeyForJson(data.keys, config),
60
- callback
61
- );
58
+ url(data.url, data.mimeType, data.headers, getDataKeyForJson(data.keys, config),
59
+ callback);
62
60
  } else if (data.json) {
63
61
  runWorker(useWorker, json, callback, [columns, rows])(
64
62
  data.json,
@@ -73,7 +71,7 @@ export default {
73
71
  }
74
72
  },
75
73
 
76
- convertDataToTargets(data: {[key:string]: number|null}[], appendXs: boolean): IData[] {
74
+ convertDataToTargets(data: {[key: string]: number | null}[], appendXs: boolean): IData[] {
77
75
  const $$ = this;
78
76
  const {axis, config, state} = $$;
79
77
  const chartType = config.data_type;
@@ -139,8 +137,7 @@ export default {
139
137
  // when .load() with 'append' option is used for indexed axis
140
138
  // @ts-ignore
141
139
  const isDataAppend = data.__append__;
142
- const xIndex = xKey === null && isDataAppend ?
143
- $$.api.data.values(id).length : 0;
140
+ const xIndex = xKey === null && isDataAppend ? $$.api.data.values(id).length : 0;
144
141
 
145
142
  return {
146
143
  id: convertedId,
@@ -151,7 +148,8 @@ export default {
151
148
  let x;
152
149
 
153
150
  value = value !== null && !isNaN(value) && !isObject(value) ?
154
- +value : (isArray(value) || isObject(value) ? value : null);
151
+ +value :
152
+ (isArray(value) || isObject(value) ? value : null);
155
153
 
156
154
  // use x as categories if custom x and categorized
157
155
  if ((isCategory || state.hasRadar) && index === 0 && !isUndefined(rawX)) {
@@ -210,7 +208,9 @@ export default {
210
208
  // set target types
211
209
  if (chartType && $$.isValidChartType(chartType)) {
212
210
  const targetIds = $$.mapToIds(targets)
213
- .filter(id => !(id in config.data_types) || !$$.isValidChartType(config.data_types[id]));
211
+ .filter(id =>
212
+ !(id in config.data_types) || !$$.isValidChartType(config.data_types[id])
213
+ );
214
214
 
215
215
  $$.setTargetType(targetIds, chartType);
216
216
  }