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
@@ -2,14 +2,19 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
- import {
6
- select as d3Select,
7
- namespaces as d3Namespaces
8
- } from "d3-selection";
9
- import {document} from "../../module/browser";
5
+ import {namespaces as d3Namespaces, select as d3Select} from "d3-selection";
10
6
  import {$FOCUS, $GAUGE, $LEGEND} from "../../config/classes";
7
+ import {document} from "../../module/browser";
11
8
  import {KEY} from "../../module/Cache";
12
- import {callFn, isDefined, getOption, isEmpty, isFunction, notEmpty, tplProcess} from "../../module/util";
9
+ import {
10
+ callFn,
11
+ getOption,
12
+ isDefined,
13
+ isEmpty,
14
+ isFunction,
15
+ notEmpty,
16
+ tplProcess
17
+ } from "../../module/util";
13
18
 
14
19
  /**
15
20
  * Get color string for given data id
@@ -20,9 +25,7 @@ import {callFn, isDefined, getOption, isEmpty, isFunction, notEmpty, tplProcess}
20
25
  function getLegendColor(id: string): string {
21
26
  const $$ = this;
22
27
  const data = $$.getDataById(id);
23
- const color = $$.levelColor ?
24
- $$.levelColor(data.values[0].value) :
25
- $$.color(data);
28
+ const color = $$.levelColor ? $$.levelColor(data.values[0].value) : $$.color(data);
26
29
 
27
30
  return color;
28
31
  }
@@ -153,7 +156,9 @@ export default {
153
156
  });
154
157
 
155
158
  const legendItem = wrapper.html(html)
156
- .selectAll(function() { return this.childNodes; })
159
+ .selectAll(function() {
160
+ return this.childNodes;
161
+ })
157
162
  .data(ids);
158
163
 
159
164
  $$.setLegendItem(legendItem);
@@ -169,27 +174,42 @@ export default {
169
174
  */
170
175
  updateSizeForLegend(size): void {
171
176
  const $$ = this;
172
- const {config, state: {
173
- isLegendTop, isLegendLeft, isLegendRight, isLegendInset, current
174
- }} = $$;
177
+ const {
178
+ config,
179
+ state: {
180
+ isLegendTop,
181
+ isLegendLeft,
182
+ isLegendRight,
183
+ isLegendInset,
184
+ current
185
+ }
186
+ } = $$;
175
187
  const {width, height} = size;
176
188
 
177
189
  const insetLegendPosition = {
178
190
  top: isLegendTop ?
179
191
  $$.getCurrentPaddingByDirection("top") + config.legend_inset_y + 5.5 :
180
- current.height - height - $$.getCurrentPaddingByDirection("bottom") - config.legend_inset_y,
192
+ current.height - height - $$.getCurrentPaddingByDirection("bottom") -
193
+ config.legend_inset_y,
181
194
  left: isLegendLeft ?
182
195
  $$.getCurrentPaddingByDirection("left") + config.legend_inset_x + 0.5 :
183
- current.width - width - $$.getCurrentPaddingByDirection("right") - config.legend_inset_x + 0.5
196
+ current.width - width - $$.getCurrentPaddingByDirection("right") -
197
+ config.legend_inset_x + 0.5
184
198
  };
185
199
 
186
200
  $$.state.margin3 = {
187
201
  top: isLegendRight ?
188
- 0 : isLegendInset ? insetLegendPosition.top : current.height - height,
202
+ 0 :
203
+ isLegendInset ?
204
+ insetLegendPosition.top :
205
+ current.height - height,
189
206
  right: NaN,
190
207
  bottom: 0,
191
208
  left: isLegendRight ?
192
- current.width - width : isLegendInset ? insetLegendPosition.left : 0
209
+ current.width - width :
210
+ isLegendInset ?
211
+ insetLegendPosition.left :
212
+ 0
193
213
  };
194
214
  },
195
215
 
@@ -255,12 +275,14 @@ export default {
255
275
  */
256
276
  getLegendWidth(): number {
257
277
  const $$ = this;
258
- const {current: {width}, isLegendRight, isLegendInset, legendItemWidth, legendStep} = $$.state;
259
-
260
- return $$.config.legend_show ? (
261
- isLegendRight || isLegendInset ?
262
- legendItemWidth * (legendStep + 1) : width
263
- ) : 0;
278
+ const {current: {width}, isLegendRight, isLegendInset, legendItemWidth, legendStep} =
279
+ $$.state;
280
+
281
+ return $$.config.legend_show ?
282
+ (
283
+ isLegendRight || isLegendInset ? legendItemWidth * (legendStep + 1) : width
284
+ ) :
285
+ 0;
264
286
  },
265
287
 
266
288
  /**
@@ -273,12 +295,13 @@ export default {
273
295
  const {current, isLegendRight, legendItemHeight, legendStep} = $$.state;
274
296
  const isFitPadding = $$.config.padding?.mode === "fit";
275
297
 
276
- return $$.config.legend_show ? (
277
- isLegendRight ?
278
- current.height : (
298
+ return $$.config.legend_show ?
299
+ (
300
+ isLegendRight ? current.height : (
279
301
  isFitPadding ? 10 : Math.max(20, legendItemHeight)
280
302
  ) * (legendStep + 1)
281
- ) : 0;
303
+ ) :
304
+ 0;
282
305
  },
283
306
 
284
307
  /**
@@ -306,8 +329,7 @@ export default {
306
329
  .filter(id => targetIdz.indexOf(id) >= 0)
307
330
  .classed($FOCUS.legendItemFocused, focus))
308
331
  .style("opacity", function() {
309
- return focus ? null :
310
- $$.opacityForUnfocusedLegend.call($$, d3Select(this));
332
+ return focus ? null : $$.opacityForUnfocusedLegend.call($$, d3Select(this));
311
333
  });
312
334
  },
313
335
 
@@ -336,9 +358,7 @@ export default {
336
358
  if (!config.legend_show) {
337
359
  config.legend_show = true;
338
360
 
339
- $el.legend ?
340
- $el.legend.style("visibility", null) :
341
- $$.initLegend();
361
+ $el.legend ? $el.legend.style("visibility", null) : $$.initLegend();
342
362
 
343
363
  !$$.state.legendHasRendered && $$.updateLegend();
344
364
  }
@@ -438,31 +458,36 @@ export default {
438
458
  }
439
459
 
440
460
  item
441
- .on(interaction.dblclick ? "dblclick" : "click", interaction || isFunction(config.legend_item_onclick) ?
442
- function(event, id) {
443
- if (!callFn(config.legend_item_onclick, api, id)) {
444
- const {altKey, target, type} = event;
445
-
446
- if (type === "dblclick" || altKey) {
447
- // when focused legend is clicked(with altKey or double clicked), reset all hiding.
448
- if (state.hiddenTargetIds.length &&
449
- target.parentNode.getAttribute("class").indexOf($LEGEND.legendItemHidden) === -1
450
- ) {
451
- api.show();
461
+ .on(interaction.dblclick ? "dblclick" : "click",
462
+ interaction || isFunction(config.legend_item_onclick) ?
463
+ function(event, id) {
464
+ if (!callFn(config.legend_item_onclick, api, id)) {
465
+ const {altKey, target, type} = event;
466
+
467
+ if (type === "dblclick" || altKey) {
468
+ // when focused legend is clicked(with altKey or double clicked), reset all hiding.
469
+ if (
470
+ state.hiddenTargetIds.length &&
471
+ target.parentNode.getAttribute("class").indexOf(
472
+ $LEGEND.legendItemHidden
473
+ ) === -1
474
+ ) {
475
+ api.show();
476
+ } else {
477
+ api.hide();
478
+ api.show(id);
479
+ }
452
480
  } else {
453
- api.hide();
454
- api.show(id);
455
- }
456
- } else {
457
- api.toggle(id);
481
+ api.toggle(id);
458
482
 
459
- d3Select(this)
460
- .classed($FOCUS.legendItemFocused, false);
483
+ d3Select(this)
484
+ .classed($FOCUS.legendItemFocused, false);
485
+ }
461
486
  }
462
- }
463
487
 
464
- isTouch && $$.hideTooltip();
465
- } : null);
488
+ isTouch && $$.hideTooltip();
489
+ } :
490
+ null);
466
491
 
467
492
  !isTouch && item
468
493
  .on("mouseout", interaction || isFunction(config.legend_item_onout) ?
@@ -476,7 +501,8 @@ export default {
476
501
 
477
502
  $$.api.revert();
478
503
  }
479
- } : null)
504
+ } :
505
+ null)
480
506
  .on("mouseover", interaction || isFunction(config.legend_item_onover) ?
481
507
  function(event, id) {
482
508
  if (!callFn(config.legend_item_onover, api, id)) {
@@ -490,7 +516,8 @@ export default {
490
516
  api.focus(id);
491
517
  }
492
518
  }
493
- } : null);
519
+ } :
520
+ null);
494
521
 
495
522
  // set cursor when has some interaction
496
523
  !item.empty() && item.on("click mouseout mouseover") &&
@@ -647,7 +674,8 @@ export default {
647
674
  const box = $$.getLegendItemTextBox(id, textElement);
648
675
 
649
676
  const itemWidth = box.width + dimension.tileWidth +
650
- (isLast && !isLegendRightOrInset ? 0 : dimension.padding.right) + config.legend_padding;
677
+ (isLast && !isLegendRightOrInset ? 0 : dimension.padding.right) +
678
+ config.legend_padding;
651
679
  const itemHeight = box.height + dimension.padding.top;
652
680
  const itemLength = isLegendRightOrInset ? itemHeight : itemWidth;
653
681
  const areaLength = isLegendRightOrInset ? $$.getLegendHeight() : $$.getLegendWidth();
@@ -702,7 +730,9 @@ export default {
702
730
 
703
731
  if (config.legend_equally) {
704
732
  Object.keys(sizes.widths).forEach(id2 => (sizes.widths[id2] = dimension.max.width));
705
- Object.keys(sizes.heights).forEach(id2 => (sizes.heights[id2] = dimension.max.height));
733
+ Object.keys(sizes.heights).forEach(
734
+ id2 => (sizes.heights[id2] = dimension.max.height)
735
+ );
706
736
  margin = (areaLength - maxLength * targetIdz.length) / 2;
707
737
 
708
738
  if (margin < dimension.posMin) {
@@ -769,7 +799,8 @@ export default {
769
799
 
770
800
  l.append(d => {
771
801
  const pattern = notEmpty(config.point_pattern) ?
772
- config.point_pattern : [config.point_type];
802
+ config.point_pattern :
803
+ [config.point_type];
773
804
 
774
805
  ids.indexOf(d) === -1 && ids.push(d);
775
806
 
@@ -779,7 +810,8 @@ export default {
779
810
  point = "rect";
780
811
  }
781
812
 
782
- return document.createElementNS(d3Namespaces.svg, ("hasValidPointType" in $$) && $$.hasValidPointType(point) ? point : "use");
813
+ return document.createElementNS(d3Namespaces.svg,
814
+ ("hasValidPointType" in $$) && $$.hasValidPointType(point) ? point : "use");
783
815
  })
784
816
  .attr("class", $LEGEND.legendItemPoint)
785
817
  .style("fill", getLegendColor.bind($$))
@@ -842,8 +874,8 @@ export default {
842
874
  let xOffset = 2;
843
875
  let yOffset = 2.5;
844
876
  let radius = null;
845
- let width = <number|null>null;
846
- let height = <number|null>null;
877
+ let width = <number | null>null;
878
+ let height = <number | null>null;
847
879
 
848
880
  if (nodeName === "circle") {
849
881
  const size = pointR * 0.2;
@@ -82,6 +82,9 @@ export default {
82
82
  // polar
83
83
  $el.polar && $$.redrawPolar();
84
84
 
85
+ // funnel
86
+ $el.funnel && $$.redrawFunnel();
87
+
85
88
  // treemap
86
89
  treemap && $$.updateTreemap(durationForExit);
87
90
  }
@@ -171,7 +174,7 @@ export default {
171
174
  },
172
175
 
173
176
  getRedrawList(shape, flow, flowFn, withTransition: boolean): Function[] {
174
- const $$ = <any> this;
177
+ const $$ = <any>this;
175
178
  const {config, state: {hasAxis, hasRadar, hasTreemap}, $el: {grid}} = $$;
176
179
  const {cx, cy, xForText, yForText} = shape.pos;
177
180
  const list: Function[] = [];
@@ -227,7 +230,8 @@ export default {
227
230
  options.withUpdateXDomain = true;
228
231
  options.withUpdateOrgXDomain = true;
229
232
  options.withTransitionForExit = false;
230
- options.withTransitionForTransform = getOption(options, "withTransitionForTransform", options.withTransition);
233
+ options.withTransitionForTransform = getOption(options, "withTransitionForTransform",
234
+ options.withTransition);
231
235
 
232
236
  // MEMO: called in updateLegend in redraw if withLegend
233
237
  if (!(options.withLegend && config.legend_show)) {
@@ -3,9 +3,9 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  import {select as d3Select} from "d3-selection"; // selection
6
+ import type {AxisType, RegionsType} from "../../../types/types";
6
7
  import {$REGION} from "../../config/classes";
7
8
  import {isValue, parseDate} from "../../module/util";
8
- import type {AxisType, RegionsType} from "../../../types/types";
9
9
 
10
10
  export default {
11
11
  initRegion(): void {
@@ -76,7 +76,9 @@ export default {
76
76
  .attr("transform", d => {
77
77
  const {x = 0, y = 0, rotated = false} = d.label ?? {};
78
78
 
79
- return `translate(${$$.regionX.bind($$)(d) + x}, ${$$.regionY.bind($$)(d) + y})${rotated ? ` rotate(-90)` : ``}`;
79
+ return `translate(${$$.regionX.bind($$)(d) + x}, ${$$.regionY.bind($$)(d) + y})${
80
+ rotated ? ` rotate(-90)` : ``
81
+ }`;
80
82
  })
81
83
  .attr("text-anchor", d => (d.label?.rotated ? "end" : null))
82
84
  .attr("dy", "1em")
@@ -167,5 +169,5 @@ export default {
167
169
 
168
170
  isRegionOnX(d: RegionsType): boolean {
169
171
  return !d.axis || d.axis === "x";
170
- },
172
+ }
171
173
  };
@@ -3,16 +3,15 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  import {
6
- scaleTime as d3ScaleTime,
7
- scaleUtc as d3ScaleUtc,
8
6
  scaleLinear as d3ScaleLinear,
9
7
  scaleLog as d3ScaleLog,
10
- scaleSymlog as d3ScaleSymlog
8
+ scaleSymlog as d3ScaleSymlog,
9
+ scaleTime as d3ScaleTime,
10
+ scaleUtc as d3ScaleUtc
11
11
  } from "d3-scale";
12
12
  import {isString, isValue, parseDate} from "../../module/util";
13
13
  import type {IDataRow, IGridData} from "../data/IData";
14
14
 
15
-
16
15
  /**
17
16
  * Get scale
18
17
  * @param {string} [type='linear'] Scale type
@@ -48,7 +47,8 @@ export default {
48
47
  */
49
48
  getXScale(min: number, max: number, domain: number[], offset: Function) {
50
49
  const $$ = this;
51
- const scale = ($$.state.loading !== "append" && $$.scale.zoom) || getScale($$.axis.getAxisType("x"), min, max);
50
+ const scale = ($$.state.loading !== "append" && $$.scale.zoom) ||
51
+ getScale($$.axis.getAxisType("x"), min, max);
52
52
 
53
53
  return $$.getCustomizedXScale(
54
54
  domain ? scale.domain(domain) : scale,
@@ -121,9 +121,7 @@ export default {
121
121
  if (!arguments.length) {
122
122
  domain = this.orgDomain();
123
123
 
124
- return isInverted ?
125
- [domain[0] + 1, domain[1]] :
126
- [domain[0], domain[1] + 1];
124
+ return isInverted ? [domain[0] + 1, domain[1]] : [domain[0], domain[1] + 1];
127
125
  }
128
126
 
129
127
  scaleValue.domain(domain);
@@ -143,7 +141,12 @@ export default {
143
141
  */
144
142
  updateScales(isInit: boolean, updateXDomain = true): void {
145
143
  const $$ = this;
146
- const {axis, config, format, org, scale,
144
+ const {
145
+ axis,
146
+ config,
147
+ format,
148
+ org,
149
+ scale,
147
150
  state: {current, width, height, width2, height2, hasAxis, hasTreemap}
148
151
  } = $$;
149
152
 
@@ -173,8 +176,8 @@ export default {
173
176
 
174
177
  scale.x = $$.getXScale(min.x, max.x, xDomain, () => axis.x.tickOffset());
175
178
  scale.subX = $$.getXScale(min.x, max.x, xSubDomain, d => (
176
- d % 1 ? 0 : (axis.subX ?? axis.x).tickOffset())
177
- );
179
+ d % 1 ? 0 : (axis.subX ?? axis.x).tickOffset()
180
+ ));
178
181
 
179
182
  format.xAxisTick = axis.getXAxisTickFormat();
180
183
  format.subXAxisTick = axis.getXAxisTickFormat(true);
@@ -186,17 +189,27 @@ export default {
186
189
  }
187
190
 
188
191
  // y Axis
189
- scale.y = $$.getYScale("y", min.y, max.y, scale.y ? scale.y.domain() : config.axis_y_default);
192
+ scale.y = $$.getYScale("y", min.y, max.y,
193
+ scale.y ? scale.y.domain() : config.axis_y_default);
190
194
  scale.subY = $$.getYScale(
191
- "y", min.subY, max.subY, scale.subY ? scale.subY.domain() : config.axis_y_default);
195
+ "y",
196
+ min.subY,
197
+ max.subY,
198
+ scale.subY ? scale.subY.domain() : config.axis_y_default
199
+ );
192
200
 
193
201
  axis.setAxis("y", scale.y, config.axis_y_tick_outer, isInit);
194
202
 
195
203
  // y2 Axis
196
204
  if (config.axis_y2_show) {
197
- scale.y2 = $$.getYScale("y2", min.y, max.y, scale.y2 ? scale.y2.domain() : config.axis_y2_default);
205
+ scale.y2 = $$.getYScale("y2", min.y, max.y,
206
+ scale.y2 ? scale.y2.domain() : config.axis_y2_default);
198
207
  scale.subY2 = $$.getYScale(
199
- "y2", min.subY, max.subY, scale.subY2 ? scale.subY2.domain() : config.axis_y2_default);
208
+ "y2",
209
+ min.subY,
210
+ max.subY,
211
+ scale.subY2 ? scale.subY2.domain() : config.axis_y2_default
212
+ );
200
213
 
201
214
  axis.setAxis("y2", scale.y2, config.axis_y2_tick_outer, isInit);
202
215
  }
@@ -3,9 +3,9 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  import {select as d3Select} from "d3-selection";
6
- import drag from "../interactions/drag";
7
6
  import {$SELECT, $SHAPE} from "../../config/classes";
8
7
  import {callFn} from "../../module/util";
8
+ import drag from "../interactions/drag";
9
9
 
10
10
  export default {
11
11
  ...drag,
@@ -37,8 +37,7 @@ export default {
37
37
  .attr("cx", cx)
38
38
  .attr("cy", cy)
39
39
  .attr("stroke", $$.color)
40
- .attr("r", d2 => $$.pointSelectR(d2) * 1.4)
41
- ).attr("r", r);
40
+ .attr("r", d2 => $$.pointSelectR(d2) * 1.4)).attr("r", r);
42
41
  },
43
42
 
44
43
  /**
@@ -56,8 +55,7 @@ export default {
56
55
 
57
56
  // remove selected-circle from low layer g
58
57
  $T(main.select(`.${$SELECT.selectedCircles}${$$.getTargetSelectorSuffix(d.id)}`)
59
- .selectAll(`.${$SELECT.selectedCircle}-${i}`)
60
- )
58
+ .selectAll(`.${$SELECT.selectedCircle}-${i}`))
61
59
  .attr("r", 0)
62
60
  .remove();
63
61
  },
@@ -134,12 +132,11 @@ export default {
134
132
  getToggle(that, d): Function {
135
133
  const $$ = this;
136
134
 
137
- return that.nodeName === "path" ?
138
- $$.togglePath : (
139
- $$.isStepType(d) ?
140
- () => {} : // circle is hidden in step chart, so treat as within the click area
141
- $$.togglePoint
142
- );
135
+ return that.nodeName === "path" ? $$.togglePath : (
136
+ $$.isStepType(d) ?
137
+ () => {} : // circle is hidden in step chart, so treat as within the click area
138
+ $$.togglePoint
139
+ );
143
140
  },
144
141
 
145
142
  /**
@@ -168,7 +165,11 @@ export default {
168
165
  }
169
166
 
170
167
  main.selectAll(selector)
171
- .selectAll(focusOnly ? `.${$SELECT.selectedCircle}` : `.${$SHAPE.shape}.${$SELECT.SELECTED}`)
168
+ .selectAll(
169
+ focusOnly ?
170
+ `.${$SELECT.selectedCircle}` :
171
+ `.${$SHAPE.shape}.${$SELECT.SELECTED}`
172
+ )
172
173
  .classed($SELECT.SELECTED, false)
173
174
  .each(function(d) {
174
175
  const shape = d3Select(this);
@@ -183,5 +184,5 @@ export default {
183
184
  toggle(!isSelected, shape, d, i);
184
185
  }
185
186
  }
186
- },
187
+ }
187
188
  };
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
- import {isNumber} from "../../module/util";
6
5
  import type {AxisType} from "../../../types/types";
6
+ import {isNumber} from "../../module/util";
7
7
 
8
8
  export default {
9
9
  /**
@@ -32,7 +32,9 @@ export default {
32
32
  return width + (
33
33
  $$.config.padding?.mode === "fit" ?
34
34
  position.isInner ? (10 + gap) : 10 :
35
- position.isInner ? (20 + gap) : 40
35
+ position.isInner ?
36
+ (20 + gap) :
37
+ 40
36
38
  );
37
39
  } else {
38
40
  return 40;
@@ -48,8 +50,9 @@ export default {
48
50
  const isInner = config[`axis_${id}_inner`];
49
51
  const hasLabelText = config[`axis_${id}_label`].text;
50
52
  const defaultHeight = 13;
51
- let h = config.padding?.mode === "fit" ? (isInner && !hasLabelText ? (id === "y" ? 1 : 0) : 20) : 30;
52
-
53
+ let h = config.padding?.mode === "fit" ?
54
+ (isInner && !hasLabelText ? (id === "y" ? 1 : 0) : 20) :
55
+ 30;
53
56
 
54
57
  if (id === "x" && !config.axis_x_show) {
55
58
  return 8;
@@ -61,8 +64,10 @@ export default {
61
64
 
62
65
  if (id === "y" && !config.axis_y_show) {
63
66
  return config.legend_show &&
64
- !isLegendRight &&
65
- !isLegendInset ? 10 : 1;
67
+ !isLegendRight &&
68
+ !isLegendInset ?
69
+ 10 :
70
+ 1;
66
71
  }
67
72
 
68
73
  if (id === "y2" && !config.axis_y2_show) {
@@ -75,7 +80,10 @@ export default {
75
80
  !config.axis_x_tick_autorotate || $$.needToRotateXAxisTickTexts()
76
81
  );
77
82
 
78
- if ((config.axis_x_tick_multiline || isXAxisTickRotated) && maxtickSize.height > defaultHeight) {
83
+ if (
84
+ (config.axis_x_tick_multiline || isXAxisTickRotated) &&
85
+ maxtickSize.height > defaultHeight
86
+ ) {
79
87
  h += maxtickSize.height - defaultHeight;
80
88
  }
81
89
 
@@ -130,15 +138,15 @@ export default {
130
138
  state.axis.x.tickCount = tickCount;
131
139
  }
132
140
 
133
- if ($el.svg &&
141
+ if (
142
+ $el.svg &&
134
143
  config.axis_x_tick_autorotate &&
135
144
  config.axis_x_tick_fit &&
136
145
  !config.axis_x_tick_multiline &&
137
146
  !config.axis_x_tick_culling &&
138
147
  allowedXAxisTypes
139
148
  ) {
140
- rotate = $$.needToRotateXAxisTickTexts() ?
141
- config.axis_x_tick_rotate : 0;
149
+ rotate = $$.needToRotateXAxisTickTexts() ? config.axis_x_tick_rotate : 0;
142
150
  }
143
151
  }
144
152