billboard.js 3.11.3 → 3.12.0-next.2

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 (177) hide show
  1. package/README.md +1 -5
  2. package/dist/billboard.css +13 -1
  3. package/dist/billboard.js +19672 -24210
  4. package/dist/billboard.min.css +2 -2
  5. package/dist/billboard.min.js +26 -3
  6. package/dist/billboard.pkgd.js +24515 -30430
  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 +429 -1134
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -3
  12. package/dist/plugin/billboardjs-plugin-stanford.js +666 -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 +1387 -1854
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -3
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2760 -3959
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -3
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +3504 -5057
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -3
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2906 -4072
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +33 -3
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +3076 -4506
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -3
  28. package/dist/theme/dark.css +12 -1
  29. package/dist/theme/dark.min.css +2 -2
  30. package/dist/theme/datalab.css +12 -1
  31. package/dist/theme/datalab.min.css +2 -2
  32. package/dist/theme/graph.css +12 -1
  33. package/dist/theme/graph.min.css +2 -2
  34. package/dist/theme/insight.css +12 -1
  35. package/dist/theme/insight.min.css +2 -2
  36. package/dist/theme/modern.css +12 -1
  37. package/dist/theme/modern.min.css +3 -4
  38. package/dist-esm/billboard.js +9297 -8527
  39. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +20 -27
  40. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +155 -149
  41. package/dist-esm/plugin/billboardjs-plugin-stanford.js +302 -289
  42. package/dist-esm/plugin/billboardjs-plugin-tableview.js +236 -236
  43. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +41 -43
  44. package/package.json +29 -49
  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 +8 -9
  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 +87 -55
  63. package/src/ChartInternal/data/IData.ts +31 -31
  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 +51 -27
  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 +84 -32
  70. package/src/ChartInternal/interactions/flow.ts +14 -4
  71. package/src/ChartInternal/interactions/interaction.ts +51 -22
  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 +6 -6
  76. package/src/ChartInternal/internals/clip.ts +8 -4
  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 +131 -47
  81. package/src/ChartInternal/internals/legend.ts +93 -61
  82. package/src/ChartInternal/internals/redraw.ts +6 -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 +98 -67
  88. package/src/ChartInternal/internals/style.ts +21 -19
  89. package/src/ChartInternal/internals/text.ts +79 -43
  90. package/src/ChartInternal/internals/title.ts +2 -2
  91. package/src/ChartInternal/internals/tooltip.ts +78 -32
  92. package/src/ChartInternal/internals/transform.ts +4 -4
  93. package/src/ChartInternal/internals/type.ts +17 -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/funnel.ts +317 -0
  100. package/src/ChartInternal/shape/gauge.ts +16 -9
  101. package/src/ChartInternal/shape/line.ts +62 -46
  102. package/src/ChartInternal/shape/point.common.ts +1 -4
  103. package/src/ChartInternal/shape/point.ts +54 -34
  104. package/src/ChartInternal/shape/polar.ts +4 -2
  105. package/src/ChartInternal/shape/radar.ts +40 -22
  106. package/src/ChartInternal/shape/shape.ts +84 -58
  107. package/src/ChartInternal/shape/treemap.ts +31 -20
  108. package/src/Plugin/bubblecompare/index.ts +1 -3
  109. package/src/Plugin/sparkline/index.ts +3 -4
  110. package/src/Plugin/stanford/ColorScale.ts +3 -2
  111. package/src/Plugin/stanford/Elements.ts +15 -6
  112. package/src/Plugin/stanford/Options.ts +5 -5
  113. package/src/Plugin/stanford/index.ts +13 -9
  114. package/src/Plugin/tableview/Options.ts +1 -1
  115. package/src/Plugin/tableview/const.ts +1 -4
  116. package/src/Plugin/tableview/index.ts +11 -9
  117. package/src/Plugin/textoverlap/index.ts +4 -6
  118. package/src/config/Options/Options.ts +3 -3
  119. package/src/config/Options/axis/axis.ts +36 -0
  120. package/src/config/Options/axis/x.ts +34 -14
  121. package/src/config/Options/axis/y.ts +13 -13
  122. package/src/config/Options/axis/y2.ts +23 -10
  123. package/src/config/Options/common/color.ts +4 -4
  124. package/src/config/Options/common/grid.ts +4 -4
  125. package/src/config/Options/common/legend.ts +12 -13
  126. package/src/config/Options/common/main.ts +23 -23
  127. package/src/config/Options/common/point.ts +17 -18
  128. package/src/config/Options/common/title.ts +2 -2
  129. package/src/config/Options/common/tooltip.ts +13 -11
  130. package/src/config/Options/data/axis.ts +2 -2
  131. package/src/config/Options/data/data.ts +48 -45
  132. package/src/config/Options/interaction/interaction.ts +1 -1
  133. package/src/config/Options/interaction/subchart.ts +2 -2
  134. package/src/config/Options/interaction/zoom.ts +9 -9
  135. package/src/config/Options/shape/arc.ts +10 -13
  136. package/src/config/Options/shape/area.ts +5 -7
  137. package/src/config/Options/shape/bar.ts +8 -10
  138. package/src/config/Options/shape/bubble.ts +1 -1
  139. package/src/config/Options/shape/candlestick.ts +2 -2
  140. package/src/config/Options/shape/donut.ts +4 -4
  141. package/src/config/Options/shape/funnel.ts +38 -0
  142. package/src/config/Options/shape/gauge.ts +6 -6
  143. package/src/config/Options/shape/line.ts +3 -3
  144. package/src/config/Options/shape/pie.ts +5 -5
  145. package/src/config/Options/shape/polar.ts +3 -3
  146. package/src/config/Options/shape/radar.ts +2 -2
  147. package/src/config/Options/shape/scatter.ts +1 -1
  148. package/src/config/Options/shape/treemap.ts +1 -1
  149. package/src/config/Store/Element.ts +8 -5
  150. package/src/config/Store/State.ts +20 -13
  151. package/src/config/classes.ts +14 -4
  152. package/src/config/config.ts +1 -1
  153. package/src/config/const.ts +2 -0
  154. package/src/config/resolver/axis.ts +4 -4
  155. package/src/config/resolver/interaction.ts +3 -7
  156. package/src/config/resolver/shape.ts +17 -12
  157. package/src/core.ts +2 -3
  158. package/src/index.esm.ts +3 -6
  159. package/src/index.ts +2 -2
  160. package/src/module/Cache.ts +2 -3
  161. package/src/module/browser.ts +15 -10
  162. package/src/module/error.ts +9 -8
  163. package/src/module/generator.ts +3 -5
  164. package/src/module/util.ts +62 -39
  165. package/src/module/worker.ts +14 -11
  166. package/src/scss/billboard.scss +18 -0
  167. package/src/scss/theme/dark.scss +17 -0
  168. package/src/scss/theme/datalab.scss +17 -0
  169. package/src/scss/theme/graph.scss +17 -0
  170. package/src/scss/theme/insight.scss +17 -0
  171. package/src/scss/theme/modern.scss +17 -0
  172. package/types/axis.d.ts +17 -0
  173. package/types/bb.d.ts +1 -0
  174. package/types/index.d.ts +1 -0
  175. package/types/options.d.ts +9 -0
  176. package/types/options.shape.d.ts +26 -1
  177. package/types/types.d.ts +1 -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,15 +186,16 @@ 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
 
181
193
  checkModuleImport($$);
182
194
 
183
195
  state.hasRadar = !state.hasAxis && $$.hasType("radar");
196
+ state.hasFunnel = !state.hasAxis && $$.hasType("funnel");
184
197
  state.hasTreemap = !state.hasAxis && $$.hasType("treemap");
185
- state.hasAxis = !$$.hasArcType() && !state.hasTreemap;
198
+ state.hasAxis = !$$.hasArcType() && !state.hasFunnel && !state.hasTreemap;
186
199
 
187
200
  // datetime to be used for uniqueness
188
201
  state.datetimeId = `bb-${+new Date() * (getRandom() as number)}`;
@@ -216,7 +229,8 @@ export default class ChartInternal {
216
229
 
217
230
  // select bind element
218
231
  $el.chart = isFunction(bindto.element.node) ?
219
- config.bindto.element : d3Select(bindto.element || []);
232
+ config.bindto.element :
233
+ d3Select(bindto.element || []);
220
234
 
221
235
  if ($el.chart.empty()) {
222
236
  $el.chart = d3Select(document.body.appendChild(document.createElement("div")));
@@ -237,9 +251,10 @@ export default class ChartInternal {
237
251
  * @private
238
252
  */
239
253
  initToRender(forced?: boolean): void {
240
- const $$ = <any> this;
254
+ const $$ = <any>this;
241
255
  const {config, state, $el: {chart}} = $$;
242
- const isHidden = () => chart.style("display") === "none" || chart.style("visibility") === "hidden";
256
+ const isHidden = () =>
257
+ chart.style("display") === "none" || chart.style("visibility") === "hidden";
243
258
 
244
259
  const isLazy = config.render.lazy || isHidden();
245
260
  const MutationObserver = window.MutationObserver;
@@ -265,7 +280,7 @@ export default class ChartInternal {
265
280
  }
266
281
 
267
282
  initParams(): void {
268
- const $$ = <any> this;
283
+ const $$ = <any>this;
269
284
  const {config, format, state} = $$;
270
285
  const isRotated = config.axis_rotated;
271
286
 
@@ -296,7 +311,8 @@ export default class ChartInternal {
296
311
 
297
312
  format.defaultAxisTime = d => {
298
313
  const {x, zoom} = $$.scale;
299
- const isZoomed = isDragZoom ? zoom :
314
+ const isZoomed = isDragZoom ?
315
+ zoom :
300
316
  zoom && x.orgDomain().toString() !== zoom.domain().toString();
301
317
 
302
318
  const specifier: string = (d.getMilliseconds() && ".%L") ||
@@ -304,7 +320,7 @@ export default class ChartInternal {
304
320
  (d.getMinutes() && "%I:%M") ||
305
321
  (d.getHours() && "%I %p") ||
306
322
  (d.getDate() !== 1 && "%b %d") ||
307
- (isZoomed && d.getDate() === 1 && "%b\'%y") ||
323
+ (isZoomed && d.getDate() === 1 && "%b'%y") ||
308
324
  (d.getMonth() && "%-m/%-d") || "%Y";
309
325
 
310
326
  return format.axisTime(specifier)(d);
@@ -330,11 +346,12 @@ export default class ChartInternal {
330
346
  }
331
347
 
332
348
  initWithData(data): void {
333
- const $$ = <any> this;
349
+ const $$ = <any>this;
334
350
  const {config, scale, state, $el, org} = $$;
335
- const {hasAxis, hasTreemap} = state;
351
+ const {hasAxis, hasFunnel, hasTreemap} = state;
336
352
  const hasInteraction = config.interaction_enabled;
337
353
  const hasPolar = $$.hasType("polar");
354
+ const labelsBGColor = config.data_labels_backgroundColors;
338
355
 
339
356
  // for arc type, set axes to not be shown
340
357
  // $$.hasArcType() && ["x", "y", "y2"].forEach(id => (config[`axis_${id}_show`] = false));
@@ -355,15 +372,13 @@ export default class ChartInternal {
355
372
  // Set targets to hide if needed
356
373
  if (config.data_hide) {
357
374
  $$.addHiddenTargetIds(
358
- config.data_hide === true ?
359
- $$.mapToIds($$.data.targets) : config.data_hide
375
+ config.data_hide === true ? $$.mapToIds($$.data.targets) : config.data_hide
360
376
  );
361
377
  }
362
378
 
363
379
  if (config.legend_hide) {
364
380
  $$.addHiddenLegendIds(
365
- config.legend_hide === true ?
366
- $$.mapToIds($$.data.targets) : config.legend_hide
381
+ config.legend_hide === true ? $$.mapToIds($$.data.targets) : config.legend_hide
367
382
  );
368
383
  }
369
384
 
@@ -413,20 +428,22 @@ export default class ChartInternal {
413
428
  config.svg_classname && $el.svg.attr("class", config.svg_classname);
414
429
 
415
430
  // Define defs
416
- const hasColorPatterns = (isFunction(config.color_tiles) && $$.patterns);
431
+ const hasColorPatterns = isFunction(config.color_tiles) && $$.patterns;
417
432
 
418
- if (hasAxis || hasColorPatterns || hasPolar || hasTreemap ||
419
- config.data_labels_backgroundColors || $$.hasLegendDefsPoint?.()) {
433
+ if (
434
+ hasAxis || hasColorPatterns || hasPolar || hasTreemap ||
435
+ labelsBGColor || $$.hasLegendDefsPoint?.()
436
+ ) {
420
437
  $el.defs = $el.svg.append("defs");
421
438
 
422
439
  if (hasAxis) {
423
- ["id", "idXAxis", "idYAxis", "idGrid"].forEach(v => {
440
+ ["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach(v => {
424
441
  $$.appendClip($el.defs, state.clip[v]);
425
442
  });
426
443
  }
427
444
 
428
445
  // Append data background color filter definition
429
- $$.generateDataLabelBackgroundColorFilter();
446
+ $$.generateTextBGColorFilter(labelsBGColor);
430
447
 
431
448
  // set color patterns
432
449
  if (hasColorPatterns) {
@@ -442,7 +459,7 @@ export default class ChartInternal {
442
459
  // Define regions
443
460
  const main = $el.svg.append("g")
444
461
  .classed($COMMON.main, true)
445
- .attr("transform", hasTreemap ? null : $$.getTranslate("main"));
462
+ .attr("transform", hasFunnel || hasTreemap ? null : $$.getTranslate("main"));
446
463
 
447
464
  $el.main = main;
448
465
 
@@ -530,7 +547,7 @@ export default class ChartInternal {
530
547
  * @private
531
548
  */
532
549
  initChartElements(): void {
533
- const $$ = <any> this;
550
+ const $$ = <any>this;
534
551
  const {hasAxis, hasRadar, hasTreemap} = $$.state;
535
552
  const types: string[] = [];
536
553
 
@@ -550,6 +567,8 @@ export default class ChartInternal {
550
567
  });
551
568
  } else if (hasTreemap) {
552
569
  types.push("Treemap");
570
+ } else if ($$.hasType("funnel")) {
571
+ types.push("Funnel");
553
572
  } else {
554
573
  const hasPolar = $$.hasType("polar");
555
574
 
@@ -579,16 +598,26 @@ export default class ChartInternal {
579
598
  */
580
599
  setChartElements(): void {
581
600
  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
- }} = $$;
601
+ const {
602
+ $el: {
603
+ chart,
604
+ svg,
605
+ defs,
606
+ main,
607
+ tooltip,
608
+ legend,
609
+ title,
610
+ grid,
611
+ needle,
612
+ arcs: arc,
613
+ circle: circles,
614
+ bar: bars,
615
+ candlestick,
616
+ line: lines,
617
+ area: areas,
618
+ text: texts
619
+ }
620
+ } = $$;
592
621
 
593
622
  // public
594
623
  $$.api.$ = {
@@ -643,11 +672,12 @@ export default class ChartInternal {
643
672
  * @private
644
673
  */
645
674
  updateTargets(targets): void {
646
- const $$ = <any> this;
647
- const {hasAxis, hasRadar, hasTreemap} = $$.state;
648
- const helper = type => $$[`updateTargetsFor${type}`](
649
- targets.filter($$[`is${type}Type`].bind($$))
650
- );
675
+ const $$ = <any>this;
676
+ const {hasAxis, hasFunnel, hasRadar, hasTreemap} = $$.state;
677
+ const helper = type =>
678
+ $$[`updateTargetsFor${type}`](
679
+ targets.filter($$[`is${type}Type`].bind($$))
680
+ );
651
681
 
652
682
  // Text
653
683
  $$.updateTargetsForText(targets);
@@ -665,7 +695,7 @@ export default class ChartInternal {
665
695
  $$.updateTargetsForSubchart &&
666
696
  $$.updateTargetsForSubchart(targets);
667
697
 
668
- // Arc, Polar, Radar
698
+ // Arc, Polar, Radar
669
699
  } else if ($$.hasArcType(targets)) {
670
700
  let type = "Arc";
671
701
 
@@ -676,7 +706,8 @@ export default class ChartInternal {
676
706
  }
677
707
 
678
708
  helper(type);
679
- // Arc, Polar, Radar
709
+ } else if (hasFunnel) {
710
+ helper("Funnel");
680
711
  } else if (hasTreemap) {
681
712
  helper("Treemap");
682
713
  }
@@ -698,7 +729,7 @@ export default class ChartInternal {
698
729
  * @private
699
730
  */
700
731
  filterTargetsToShowAtInit(hasPointType: boolean = false): void {
701
- const $$ = <any> this;
732
+ const $$ = <any>this;
702
733
  const {$el: {svg}, $T} = $$;
703
734
  let selector = `.${$COMMON.target}`;
704
735
 
@@ -707,8 +738,7 @@ export default class ChartInternal {
707
738
  }
708
739
 
709
740
  $T(svg.selectAll(selector)
710
- .filter(d => $$.isTargetToShow(d.id))
711
- ).style("opacity", null);
741
+ .filter(d => $$.isTargetToShow(d.id))).style("opacity", null);
712
742
  }
713
743
 
714
744
  getWithOption(options) {
@@ -742,17 +772,19 @@ export default class ChartInternal {
742
772
  }
743
773
 
744
774
  initialOpacity(d): null | "0" {
745
- const $$ = <any> this;
775
+ const $$ = <any>this;
746
776
  const {withoutFadeIn} = $$.state;
747
777
 
748
778
  const r = $$.getBaseValue(d) !== null &&
749
- withoutFadeIn[d.id] ? null : "0";
779
+ withoutFadeIn[d.id] ?
780
+ null :
781
+ "0";
750
782
 
751
783
  return r;
752
784
  }
753
785
 
754
786
  bindResize(): void {
755
- const $$ = <any> this;
787
+ const $$ = <any>this;
756
788
  const {config, state} = $$;
757
789
  const resizeFunction = generateResize(config.resize_timer);
758
790
  const list: Function[] = [];
@@ -3,62 +3,62 @@
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
 
11
+ export interface IFunnelData {
12
+ id: string; // for compatibility
13
+ value: number;
14
+ ratio?: number;
15
+ coords?: number[][];
16
+ }
17
+
16
18
  export interface ITreemapData {
17
- name: string;
18
- id?: string; // for compatibility
19
- value?: number;
20
- ratio?: number;
21
- children?: ITreemapData[];
19
+ name: string;
20
+ id?: string; // for compatibility
21
+ value?: number;
22
+ ratio?: number;
23
+ children?: ITreemapData[];
22
24
  }
23
25
 
24
26
  export interface IDataRow extends TDataRow {
25
- x: TDomain & string;
27
+ x: TDomain & string;
26
28
  }
27
29
 
28
30
  export interface IDataPoint extends IDataRow {
29
- r: number;
31
+ r: number;
30
32
  }
31
33
 
32
34
  export interface IArcDataRow extends TDataRow {
33
- ratio: number;
35
+ ratio: number;
34
36
  }
35
37
 
36
38
  export interface IData {
37
- id: string;
38
- id_org: string;
39
- values: IDataRow[];
39
+ id: string;
40
+ id_org: string;
41
+ values: IDataRow[];
40
42
  }
41
43
 
42
44
  export interface IArcData {
43
- data: IData;
44
- index: number;
45
- padAngle: number;
46
- startAngle: number;
47
- endAngle: number;
48
- value: number | null;
45
+ data: IData;
46
+ index: number;
47
+ padAngle: number;
48
+ startAngle: number;
49
+ endAngle: number;
50
+ value: number | null;
49
51
  }
50
52
 
51
53
  export interface IGridData {
52
- axis?: string;
53
- text: string;
54
- value: number;
54
+ axis?: string;
55
+ text: string;
56
+ value: number;
55
57
  }
56
58
 
57
59
  export interface IDataIndice {
58
- [key: string]: number;
59
- __max__: number;
60
+ [key: string]: number;
61
+ __max__: number;
60
62
  }
61
63
 
62
- export type TIndices = {} | {
63
- [key:string]: IDataIndice
64
- };
64
+ 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
  }