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
@@ -2,31 +2,42 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
+ import {select as d3Select} from "d3-selection";
5
6
  import {
6
- curveStepBefore as d3CurveStepBefore,
7
- curveStepAfter as d3CurveStepAfter,
7
+ curveBasis as d3CurveBasis,
8
8
  curveBasisClosed as d3CurveBasisClosed,
9
9
  curveBasisOpen as d3CurveBasisOpen,
10
- curveBasis as d3CurveBasis,
11
10
  curveBundle as d3CurveBundle,
11
+ curveCardinal as d3CurveCardinal,
12
12
  curveCardinalClosed as d3CurveCardinalClosed,
13
13
  curveCardinalOpen as d3CurveCardinalOpen,
14
- curveCardinal as d3CurveCardinal,
14
+ curveCatmullRom as d3CurveCatmullRom,
15
15
  curveCatmullRomClosed as d3CurveCatmullRomClosed,
16
16
  curveCatmullRomOpen as d3CurveCatmullRomOpen,
17
- curveCatmullRom as d3CurveCatmullRom,
18
- curveLinearClosed as d3CurveLinearClosed,
19
17
  curveLinear as d3CurveLinear,
18
+ curveLinearClosed as d3CurveLinearClosed,
20
19
  curveMonotoneX as d3CurveMonotoneX,
21
20
  curveMonotoneY as d3CurveMonotoneY,
22
21
  curveNatural as d3CurveNatural,
23
- curveStep as d3CurveStep
22
+ curveStep as d3CurveStep,
23
+ curveStepAfter as d3CurveStepAfter,
24
+ curveStepBefore as d3CurveStepBefore
24
25
  } from "d3-shape";
25
- import {select as d3Select} from "d3-selection";
26
26
  import type {d3Selection} from "../../../types/types";
27
27
  import CLASS from "../../config/classes";
28
- import {capitalize, getPointer, getRectSegList, getUnique, isObjectType, isNumber, isValue, isUndefined, notEmpty, parseDate} from "../../module/util";
29
- import type {IDataRow, IDataIndice, TIndices} from "../data/IData";
28
+ import {
29
+ capitalize,
30
+ getPointer,
31
+ getRectSegList,
32
+ getUnique,
33
+ isNumber,
34
+ isObjectType,
35
+ isUndefined,
36
+ isValue,
37
+ notEmpty,
38
+ parseDate
39
+ } from "../../module/util";
40
+ import type {IDataIndice, IDataRow, TIndices} from "../data/IData";
30
41
 
31
42
  /**
32
43
  * Get grouped data point function for y coordinate
@@ -50,7 +61,7 @@ function getGroupedDataPointsFn(d) {
50
61
 
51
62
  export interface IOffset {
52
63
  _$width: number;
53
- _$total: number[]
64
+ _$total: number[];
54
65
  }
55
66
 
56
67
  export default {
@@ -60,11 +71,7 @@ export default {
60
71
  * @private
61
72
  */
62
73
  getDrawShape() {
63
- type TShape = {
64
- area?: any;
65
- bar?: any;
66
- line?: any;
67
- };
74
+ type TShape = {area?: any, bar?: any, line?: any};
68
75
 
69
76
  const $$ = this;
70
77
  const isRotated = $$.config.axis_rotated;
@@ -74,9 +81,12 @@ export default {
74
81
  !hasTreemap && ["bar", "candlestick", "line", "area"].forEach(v => {
75
82
  const name = capitalize(/^(bubble|scatter)$/.test(v) ? "line" : v);
76
83
 
77
- if ($$.hasType(v) || $$.hasTypeOf(name) || (
78
- v === "line" && ($$.hasType("bubble") || $$.hasType("scatter"))
79
- )) {
84
+ if (
85
+ $$.hasType(v) || $$.hasTypeOf(name) || (
86
+ v === "line" &&
87
+ ($$.hasType("bubble") || $$.hasType("scatter"))
88
+ )
89
+ ) {
80
90
  const indices = $$.getShapeIndices($$[`is${name}Type`]);
81
91
  const drawFn = $$[`generateDraw${name}`];
82
92
 
@@ -112,10 +122,10 @@ export default {
112
122
  * From the below example, indices will be:
113
123
  * ==> {data1: 0, data2: 0, data3: 1, data4: 1, __max__: 1}
114
124
  *
115
- * data1 data3 data1 data3
116
- * data2 data4 data2 data4
117
- * -------------------------
118
- * 0 1
125
+ * data1 data3 data1 data3
126
+ * data2 data4 data2 data4
127
+ * -------------------------
128
+ * 0 1
119
129
  * @param {Function} typeFilter Chart type filter function
120
130
  * @returns {object} Indices object with its position
121
131
  */
@@ -193,8 +203,7 @@ export default {
193
203
  return ind;
194
204
  }
195
205
 
196
- return notEmpty(xs) ?
197
- indices[xs[id]] : indices;
206
+ return notEmpty(xs) ? indices[xs[id]] : indices;
198
207
  },
199
208
 
200
209
  /**
@@ -208,7 +217,8 @@ export default {
208
217
  // if is multiple xs, return total sum of xs' __max__ value
209
218
  Object.keys(indices)
210
219
  .map(v => indices[v].__max__ || 0)
211
- .reduce((acc, curr) => acc + curr) : (indices as IDataIndice).__max__;
220
+ .reduce((acc, curr) => acc + curr) :
221
+ (indices as IDataIndice).__max__;
212
222
  },
213
223
 
214
224
  getShapeX(offset: IOffset, indices, isSub?: boolean): (d) => number {
@@ -236,14 +246,14 @@ export default {
236
246
  if (halfWidth) {
237
247
  const offsetWidth = offset[d.id] || offset._$width;
238
248
 
239
- x = barOverlap ?
240
- xPos - offsetWidth / 2 :
241
- xPos - offsetWidth + offset._$total.slice(0, index + 1).reduce(sum) - halfWidth;
249
+ x = barOverlap ? xPos - offsetWidth / 2 : xPos - offsetWidth +
250
+ offset._$total.slice(0, index + 1).reduce(sum) -
251
+ halfWidth;
242
252
  } else {
243
253
  x = xPos - (isNumber(offset) ? offset : offset._$width) *
244
- (targetsNum / 2 - (
245
- barOverlap ? 1 : index
246
- ));
254
+ (targetsNum / 2 - (
255
+ barOverlap ? 1 : index
256
+ ));
247
257
  }
248
258
  }
249
259
 
@@ -312,7 +322,9 @@ export default {
312
322
  */
313
323
  getShapeOffsetData(typeFilter) {
314
324
  const $$ = this;
315
- const targets = $$.orderTargets($$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)));
325
+ const targets = $$.orderTargets(
326
+ $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))
327
+ );
316
328
  const isStackNormalized = $$.isStackNormalized();
317
329
 
318
330
  const shapeOffsetTargets = targets.map(target => {
@@ -349,7 +361,9 @@ export default {
349
361
 
350
362
  getShapeOffset(typeFilter, indices, isSub?: boolean): Function {
351
363
  const $$ = this;
352
- const {shapeOffsetTargets, indexMapByTargetId} = $$.getShapeOffsetData(typeFilter);
364
+ const {shapeOffsetTargets, indexMapByTargetId} = $$.getShapeOffsetData(
365
+ typeFilter
366
+ );
353
367
  const groupsZeroAs = $$.config.data_groupsZeroAs;
354
368
 
355
369
  return (d, idx) => {
@@ -369,7 +383,12 @@ export default {
369
383
  shapeOffsetTargets
370
384
  .filter(t => t.id !== id && ind[t.id] === ind[id])
371
385
  .forEach(t => {
372
- const {id: tid, rowValueMapByXValue, rowValues, values: tvalues} = t;
386
+ const {
387
+ id: tid,
388
+ rowValueMapByXValue,
389
+ rowValues,
390
+ values: tvalues
391
+ } = t;
373
392
 
374
393
  // for same stacked group (ind[tid] === ind[id])
375
394
  if (indexMapByTargetId[tid] < indexMapByTargetId[id]) {
@@ -382,10 +401,13 @@ export default {
382
401
  }
383
402
 
384
403
  if (row?.value * value >= 0 && isNumber(rValue)) {
385
- const addOffset = value === 0 ? (
386
- (groupsZeroAs === "positive" && rValue > 0) ||
387
- (groupsZeroAs === "negative" && rValue < 0)
388
- ) : true;
404
+ const addOffset = value === 0 ?
405
+ (
406
+ (groupsZeroAs === "positive" &&
407
+ rValue > 0) ||
408
+ (groupsZeroAs === "negative" && rValue < 0)
409
+ ) :
410
+ true;
389
411
 
390
412
  if (addOffset) {
391
413
  offset += scale(rValue) - y0;
@@ -414,9 +436,7 @@ export default {
414
436
  points = getGroupedDataPointsFn.bind($$)(d);
415
437
  }
416
438
 
417
- return points ?
418
- points(d, i)[0][1] :
419
- $$.getYScaleById(id)($$.getBaseValue(d));
439
+ return points ? points(d, i)[0][1] : $$.getYScaleById(id)($$.getBaseValue(d));
420
440
  },
421
441
 
422
442
  getBarW(type, axis, targetsNum: number): number | IOffset {
@@ -448,7 +468,8 @@ export default {
448
468
  const ratio = id ? width.ratio : config[`${configName}_ratio`];
449
469
  const max = id ? width.max : config[`${configName}_max`];
450
470
  const w = isNumber(width) ?
451
- width : targetsNum ? (tickInterval * ratio) / targetsNum : 0;
471
+ width :
472
+ (targetsNum ? (tickInterval * ratio) / targetsNum : 0);
452
473
 
453
474
  return max && w > max ? max : w;
454
475
  };
@@ -480,7 +501,7 @@ export default {
480
501
  getShapeByIndex(shapeName: string, i: number, id?: string): d3Selection {
481
502
  const $$ = this;
482
503
  const {$el} = $$;
483
- const suffix = (isValue(i) ? `-${i}` : ``);
504
+ const suffix = isValue(i) ? `-${i}` : ``;
484
505
  let shape = $el[shapeName];
485
506
 
486
507
  // filter from shape reference if has
@@ -489,8 +510,12 @@ export default {
489
510
  .filter(d => (id ? d.id === id : true))
490
511
  .filter(d => (isValue(i) ? d.index === i : true));
491
512
  } else {
492
- shape = (id ? $el.main
493
- .selectAll(`.${CLASS[`${shapeName}s`]}${$$.getTargetSelectorSuffix(id)}`) : $el.main)
513
+ shape = (id ?
514
+ $el.main
515
+ .selectAll(
516
+ `.${CLASS[`${shapeName}s`]}${$$.getTargetSelectorSuffix(id)}`
517
+ ) :
518
+ $el.main)
494
519
  .selectAll(`.${CLASS[shapeName]}${suffix}`);
495
520
  }
496
521
 
@@ -507,7 +532,10 @@ export default {
507
532
  } else if ($$.hasValidPointType?.(that.nodeName)) {
508
533
  isWithin = $$.isStepType(d) ?
509
534
  $$.isWithinStep(that, $$.getYScaleById(d.id)(d.value)) :
510
- $$.isWithinCircle(that, $$.isBubbleType(d) ? $$.pointSelectR(d) * 1.5 : 0);
535
+ $$.isWithinCircle(
536
+ that,
537
+ $$.isBubbleType(d) ? $$.pointSelectR(d) * 1.5 : 0
538
+ );
511
539
  } else if (that.nodeName === "path") {
512
540
  isWithin = shape.classed(CLASS.bar) ? $$.isWithinBar(that) : true;
513
541
  }
@@ -520,11 +548,11 @@ export default {
520
548
  const interpolation = $$.getInterpolateType(d);
521
549
 
522
550
  return {
523
- "basis": d3CurveBasis,
551
+ basis: d3CurveBasis,
524
552
  "basis-closed": d3CurveBasisClosed,
525
553
  "basis-open": d3CurveBasisOpen,
526
- "bundle": d3CurveBundle,
527
- "cardinal": d3CurveCardinal,
554
+ bundle: d3CurveBundle,
555
+ cardinal: d3CurveCardinal,
528
556
  "cardinal-closed": d3CurveCardinalClosed,
529
557
  "cardinal-open": d3CurveCardinalOpen,
530
558
  "catmull-rom": d3CurveCatmullRom,
@@ -532,10 +560,10 @@ export default {
532
560
  "catmull-rom-open": d3CurveCatmullRomOpen,
533
561
  "monotone-x": d3CurveMonotoneX,
534
562
  "monotone-y": d3CurveMonotoneY,
535
- "natural": d3CurveNatural,
563
+ natural: d3CurveNatural,
536
564
  "linear-closed": d3CurveLinearClosed,
537
- "linear": d3CurveLinear,
538
- "step": d3CurveStep,
565
+ linear: d3CurveLinear,
566
+ step: d3CurveStep,
539
567
  "step-after": d3CurveStepAfter,
540
568
  "step-before": d3CurveStepBefore
541
569
  }[interpolation];
@@ -547,11 +575,9 @@ export default {
547
575
  const type = config.spline_interpolation_type;
548
576
  const interpolation = $$.isInterpolationType(type) ? type : "cardinal";
549
577
 
550
- return $$.isSplineType(d) ?
551
- interpolation : (
552
- $$.isStepType(d) ?
553
- config.line_step_type : "linear"
554
- );
578
+ return $$.isSplineType(d) ? interpolation : (
579
+ $$.isStepType(d) ? config.line_step_type : "linear"
580
+ );
555
581
  },
556
582
 
557
583
  isWithinBar(that): boolean {
@@ -7,16 +7,16 @@ import {
7
7
  treemap as d3Treemap,
8
8
  treemapBinary as d3TreemapBinary,
9
9
  treemapDice as d3TreemapDice,
10
+ treemapResquarify as d3TreemapResquarify,
10
11
  treemapSlice as d3TreemapSlice,
11
12
  treemapSliceDice as d3TreemapSliceDice,
12
- treemapSquarify as d3TreemapSquarify,
13
- treemapResquarify as d3TreemapResquarify
13
+ treemapSquarify as d3TreemapSquarify
14
14
  } from "d3-hierarchy";
15
15
  import {select as d3Select} from "d3-selection";
16
16
  import type {d3Selection} from "../../../types/types";
17
17
  import {$COMMON, $TREEMAP} from "../../config/classes";
18
- import {isFunction, getRandom} from "../../module/util";
19
- import type {ITreemapData, IData, IDataRow} from "../data/IData";
18
+ import {getRandom, isFunction} from "../../module/util";
19
+ import type {IData, IDataRow, ITreemapData} from "../data/IData";
20
20
 
21
21
  /**
22
22
  * Get treemap elements' position
@@ -34,11 +34,11 @@ function position(group, root): void {
34
34
  ))
35
35
  .select("rect")
36
36
  .attr("width", d => (
37
- d === root ? width : x(d.x1) - x(d.x0))
38
- )
37
+ d === root ? width : x(d.x1) - x(d.x0)
38
+ ))
39
39
  .attr("height", d => (
40
- d === root ? 0 : y(d.y1) - y(d.y0))
41
- );
40
+ d === root ? 0 : y(d.y1) - y(d.y0)
41
+ ));
42
42
  }
43
43
 
44
44
  /**
@@ -66,9 +66,14 @@ function convertDataToTreemapData(data: IData[]): ITreemapData[] {
66
66
  export default {
67
67
  initTreemap(): void {
68
68
  const $$ = this;
69
- const {$el, state: {
70
- current: {width, height}, clip, datetimeId
71
- }} = $$;
69
+ const {
70
+ $el,
71
+ state: {
72
+ current: {width, height},
73
+ clip,
74
+ datetimeId
75
+ }
76
+ } = $$;
72
77
 
73
78
  clip.id = `${datetimeId}-clip`;
74
79
 
@@ -148,12 +153,12 @@ export default {
148
153
  const $$ = this;
149
154
  const {config, state: {current: {width, height}}} = $$;
150
155
  const tile = {
151
- "binary": d3TreemapBinary,
152
- "dice": d3TreemapDice,
153
- "slice": d3TreemapSlice,
154
- "sliceDice": d3TreemapSliceDice,
155
- "squarify": d3TreemapSquarify,
156
- "resquarify": d3TreemapResquarify
156
+ binary: d3TreemapBinary,
157
+ dice: d3TreemapDice,
158
+ slice: d3TreemapSlice,
159
+ sliceDice: d3TreemapSliceDice,
160
+ squarify: d3TreemapSquarify,
161
+ resquarify: d3TreemapResquarify
157
162
  }[config.treemap_tile ?? "binary"] ?? d3TreemapBinary;
158
163
 
159
164
  return (node, x0, y0, x1, y1) => {
@@ -283,13 +288,17 @@ export default {
283
288
  const ratio = $$.getRatio("treemap", d);
284
289
  const percentValue = (ratio * 100).toFixed(2);
285
290
  const meetLabelThreshold = config.treemap_label_show && $$.meetsLabelThreshold(
286
- ratio, "treemap"
287
- ) ? null : "0";
291
+ ratio,
292
+ "treemap"
293
+ ) ?
294
+ null :
295
+ "0";
288
296
 
289
297
  return function(node) {
290
298
  node.style("opacity", meetLabelThreshold);
291
299
 
292
- return isFunction(format) ? format.bind($$.api)(value, ratio, id) :
300
+ return isFunction(format) ?
301
+ format.bind($$.api)(value, ratio, id) :
293
302
  `${id}\n${percentValue}%`;
294
303
  };
295
304
  }
@@ -111,8 +111,6 @@ export default class BubbleCompare extends Plugin {
111
111
  }
112
112
 
113
113
  getZData(d): number {
114
- return this.$$.isBubbleZType(d) ?
115
- this.$$.getBubbleZData(d.value, "z") :
116
- d.value;
114
+ return this.$$.isBubbleZType(d) ? this.$$.getBubbleZData(d.value, "z") : d.value;
117
115
  }
118
116
  }
@@ -2,11 +2,11 @@
2
2
  * Copyright (c) 2021 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
+ import type {IData} from "../../ChartInternal/data/IData";
5
6
  import {$COMMON} from "../../config/classes";
7
+ import {loadConfig} from "../../config/config";
6
8
  import Plugin from "../Plugin";
7
9
  import Options from "./Options";
8
- import type {IData} from "../../ChartInternal/data/IData";
9
- import {loadConfig} from "../../config/config";
10
10
 
11
11
  /**
12
12
  * Sparkline plugin.<br>
@@ -235,8 +235,7 @@ export default class Sparkline extends Plugin {
235
235
 
236
236
  $$.state.event = e;
237
237
 
238
- $$.isPointFocusOnly() ?
239
- $$.hideCircleFocus() : $$.unexpandCircles();
238
+ $$.isPointFocusOnly() ? $$.hideCircleFocus() : $$.unexpandCircles();
240
239
 
241
240
  $$.hideTooltip();
242
241
  }
@@ -6,7 +6,7 @@ import {axisRight as d3AxisRight} from "d3-axis";
6
6
  import {format as d3Format} from "d3-format";
7
7
  import {scaleSequential as d3ScaleSequential, scaleSymlog as d3ScaleSymlog} from "d3-scale";
8
8
  import CLASS from "./classes";
9
- import {isFunction, getRange} from "./util";
9
+ import {getRange, isFunction} from "./util";
10
10
 
11
11
  /**
12
12
  * Stanford diagram plugin color scale class
@@ -89,7 +89,8 @@ export default class ColorScale {
89
89
  .text(d => Math.round(Math.log(d) / Math.LN10));
90
90
  }
91
91
 
92
- this.colorScale.attr("transform", `translate(${$$.state.current.width - this.xForColorScale()}, 0)`);
92
+ this.colorScale.attr("transform",
93
+ `translate(${$$.state.current.width - this.xForColorScale()}, 0)`);
93
94
  }
94
95
 
95
96
  xForColorScale(): number {
@@ -111,18 +111,27 @@ export default class Elements {
111
111
  .select("polygon")
112
112
  .transition()
113
113
  .duration(duration)
114
- .attr("points", d => d.points.map(value => [
115
- isRotated ? yvCustom(value, "y") : xvCustom(value, "x"),
116
- isRotated ? xvCustom(value, "x") : yvCustom(value, "y")
117
- ].join(",")).join(" "))
114
+ .attr("points", d =>
115
+ d.points.map(value =>
116
+ [
117
+ isRotated ? yvCustom(value, "y") : xvCustom(value, "x"),
118
+ isRotated ? xvCustom(value, "x") : yvCustom(value, "y")
119
+ ].join(",")
120
+ ).join(" "))
118
121
  .transition()
119
122
  .style("opacity", d => String(d.opacity ? d.opacity : 0.2));
120
123
 
121
124
  stanfordRegion.select("text")
122
125
  .transition()
123
126
  .duration(duration)
124
- .attr("x", d => (isRotated ? yvCustom(getCentroid(d.points), "y") : xvCustom(getCentroid(d.points), "x")))
125
- .attr("y", d => (isRotated ? xvCustom(getCentroid(d.points), "x") : yvCustom(getCentroid(d.points), "y")))
127
+ .attr("x",
128
+ d => (isRotated ?
129
+ yvCustom(getCentroid(d.points), "y") :
130
+ xvCustom(getCentroid(d.points), "x")))
131
+ .attr("y",
132
+ d => (isRotated ?
133
+ xvCustom(getCentroid(d.points), "x") :
134
+ yvCustom(getCentroid(d.points), "y")))
126
135
  .text(d => {
127
136
  if (d.text) {
128
137
  const {value, percentage} = countPointsInRegion(d.points);
@@ -35,7 +35,7 @@ export default class Options {
35
35
  * @example
36
36
  * epochs: [ 1, 1, 2, 2, ... ]
37
37
  */
38
- epochs: <number[]> [],
38
+ epochs: <number[]>[],
39
39
 
40
40
  /**
41
41
  * Show additional lines anywhere on the chart.
@@ -84,10 +84,10 @@ export default class Options {
84
84
  * }
85
85
  * },
86
86
  */
87
- scale_min: <number|undefined> undefined,
88
- scale_max: <number|undefined> undefined,
89
- scale_width: <number|undefined> 20,
90
- scale_format: <number|undefined> undefined,
87
+ scale_min: <number | undefined>undefined,
88
+ scale_max: <number | undefined>undefined,
89
+ scale_width: <number | undefined>20,
90
+ scale_format: <number | undefined>undefined,
91
91
 
92
92
  /**
93
93
  * The padding for color scale element
@@ -3,15 +3,15 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  // @ts-nocheck
6
- import {interpolateHslLong as d3InterpolateHslLong} from "d3-interpolate";
7
6
  import {hsl as d3Hsl} from "d3-color";
7
+ import {interpolateHslLong as d3InterpolateHslLong} from "d3-interpolate";
8
8
  import {scaleSequentialLog as d3ScaleSequentialLog} from "d3-scale";
9
9
  import {$TOOLTIP} from "../../config/classes";
10
10
  import {loadConfig} from "../../config/config";
11
11
  import Plugin from "../Plugin";
12
- import Options from "./Options";
13
- import Elements from "./Elements";
14
12
  import ColorScale from "./ColorScale";
13
+ import Elements from "./Elements";
14
+ import Options from "./Options";
15
15
  import {compareEpochs, isEmpty, isFunction, pointInRegion} from "./util";
16
16
 
17
17
  /**
@@ -90,7 +90,7 @@ import {compareEpochs, isEmpty, isFunction, pointInRegion} from "./util";
90
90
  * ]
91
91
  * });
92
92
  * @example
93
- * import {bb} from "billboard.js";
93
+ * import {bb} from "billboard.js";
94
94
  * import Stanford from "billboard.js/dist/billboardjs-plugin-stanford";
95
95
  *
96
96
  * bb.generate({
@@ -156,7 +156,6 @@ export default class Stanford extends Plugin {
156
156
  this.elements?.updateStanfordElements(duration);
157
157
  }
158
158
 
159
-
160
159
  getOptions(): Options {
161
160
  return new Options();
162
161
  }
@@ -192,7 +191,8 @@ export default class Stanford extends Plugin {
192
191
  target.maxEpochs = !isNaN(config.scale_max) ? config.scale_max : Math.max(...epochs);
193
192
 
194
193
  target.colors = isFunction(config.colors) ?
195
- config.colors : d3InterpolateHslLong(d3Hsl(250, 1, 0.5), d3Hsl(0, 1, 0.5));
194
+ config.colors :
195
+ d3InterpolateHslLong(d3Hsl(250, 1, 0.5), d3Hsl(0, 1, 0.5));
196
196
 
197
197
  target.colorscale = d3ScaleSequentialLog(target.colors)
198
198
  .domain([target.minEpochs, target.maxEpochs]);
@@ -224,7 +224,9 @@ export default class Stanford extends Plugin {
224
224
  <th class="value">${defaultValueFormat(value)}</th>
225
225
  </tr>
226
226
  <tr class="${$TOOLTIP.tooltipName}-${id}">
227
- <td class="name"><span style="background-color:${color(v)}"></span>Epochs</td>
227
+ <td class="name"><span style="background-color:${
228
+ color(v)
229
+ }"></span>Epochs</td>
228
230
  <td class="value">${defaultValueFormat(epochs)}</td>
229
231
  </tr>`;
230
232
  });
@@ -238,8 +240,10 @@ export default class Stanford extends Plugin {
238
240
  const $$ = this;
239
241
  const target = $$.data.targets[0];
240
242
 
241
- const total = target.values.reduce((accumulator, currentValue) =>
242
- accumulator + Number(currentValue.epochs), 0);
243
+ const total = target.values.reduce(
244
+ (accumulator, currentValue) => accumulator + Number(currentValue.epochs),
245
+ 0
246
+ );
243
247
 
244
248
  const value = target.values.reduce((accumulator, currentValue) => {
245
249
  if (pointInRegion(currentValue, region)) {
@@ -46,7 +46,7 @@ export default class Options {
46
46
  * @example
47
47
  * categoryFormat: "#table-holder"
48
48
  */
49
- categoryFormat: function(v: Date|number|string): string {
49
+ categoryFormat: function(v: Date | number | string): string {
50
50
  let category = v;
51
51
 
52
52
  if (this.$$.axis.isCategorized()) {
@@ -6,10 +6,7 @@
6
6
  * Constants values for plugin option
7
7
  * @ignore
8
8
  */
9
- export {
10
- defaultStyle,
11
- tpl
12
- };
9
+ export {defaultStyle, tpl};
13
10
 
14
11
  const defaultStyle = {
15
12
  id: "__tableview-style__",
@@ -2,11 +2,11 @@
2
2
  * Copyright (c) 2021 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
- import Plugin from "../Plugin";
6
- import Options from "./Options";
7
- import {defaultStyle, tpl} from "./const";
8
5
  import {loadConfig} from "../../config/config";
9
6
  import {isNumber, tplProcess} from "../../module/util";
7
+ import Plugin from "../Plugin";
8
+ import {defaultStyle, tpl} from "./const";
9
+ import Options from "./Options";
10
10
 
11
11
  /**
12
12
  * Table view plugin.<br>
@@ -115,7 +115,7 @@ export default class TableView extends Plugin {
115
115
  title: dataToShow.length ? this.config.categoryTitle : ""
116
116
  });
117
117
  let tbody = "";
118
- const rows: (number|string)[][] = [];
118
+ const rows: (number | string)[][] = [];
119
119
 
120
120
  dataToShow.forEach(v => {
121
121
  thead += tplProcess(tpl.thead, {title: v.id});
@@ -132,11 +132,13 @@ export default class TableView extends Plugin {
132
132
 
133
133
  rows.forEach(v => {
134
134
  tbody += `<tr>${
135
- v.map((d, i) => tplProcess(i ? tpl.tbody : tpl.tbodyHeader, {
136
- value: i === 0 ?
137
- config.categoryFormat.bind(this)(d) :
138
- (isNumber(d) ? d.toLocaleString() : config.nullString)
139
- })).join("")
135
+ v.map((d, i) =>
136
+ tplProcess(i ? tpl.tbody : tpl.tbodyHeader, {
137
+ value: i === 0 ?
138
+ config.categoryFormat.bind(this)(d) :
139
+ (isNumber(d) ? d.toLocaleString() : config.nullString)
140
+ })
141
+ ).join("")
140
142
  }</tr>`;
141
143
  });
142
144
 
@@ -4,10 +4,7 @@
4
4
  */
5
5
  import type {d3Selection} from "billboard.js/types/types";
6
6
  import {Delaunay as d3Delaunay} from "d3-delaunay";
7
- import {
8
- polygonCentroid as d3PolygonCentroid,
9
- polygonArea as d3PolygonArea
10
- } from "d3-polygon";
7
+ import {polygonArea as d3PolygonArea, polygonCentroid as d3PolygonCentroid} from "d3-polygon";
11
8
  import {loadConfig} from "../../config/config";
12
9
  import Plugin from "../Plugin";
13
10
  import Options from "./Options";
@@ -46,7 +43,7 @@ import Options from "./Options";
46
43
  * ]
47
44
  * });
48
45
  * @example
49
- * import {bb} from "billboard.js";
46
+ * import {bb} from "billboard.js";
50
47
  * import TextOverlap from "billboard.js/dist/billboardjs-plugin-textoverlap";
51
48
  *
52
49
  * bb.generate({
@@ -124,7 +121,8 @@ export default class TextOverlap extends Plugin {
124
121
  const yTranslate = angle === -1 ? -extent : extent + 5;
125
122
 
126
123
  const txtAnchor = Math.abs(angle) === 1 ?
127
- "middle" : (angle === 0 ? "start" : "end");
124
+ "middle" :
125
+ (angle === 0 ? "start" : "end");
128
126
 
129
127
  this.style.display = polygonArea < area ? "none" : "";
130
128
  this.setAttribute("text-anchor", txtAnchor);