billboard.js 3.16.0-next.1 → 3.16.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 (70) hide show
  1. package/dist/billboard.css +2 -1
  2. package/dist/billboard.js +122 -76
  3. package/dist/billboard.min.css +2 -2
  4. package/dist/billboard.min.js +9 -9
  5. package/dist/billboard.pkgd.js +122 -76
  6. package/dist/billboard.pkgd.min.js +17 -17
  7. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-sparkline.js +23 -9
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
  11. package/dist/plugin/billboardjs-plugin-stanford.js +23 -9
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +5 -5
  13. package/dist/plugin/billboardjs-plugin-tableview.js +18 -7
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +4 -4
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +18 -7
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -4
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
  19. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +23 -9
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +3 -3
  21. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +23 -9
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +4 -4
  23. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +18 -7
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +4 -4
  25. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +18 -7
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +5 -5
  27. package/dist/theme/dark.css +2 -1
  28. package/dist/theme/dark.min.css +2 -2
  29. package/dist/theme/datalab.css +2 -1
  30. package/dist/theme/datalab.min.css +2 -2
  31. package/dist/theme/graph.css +2 -1
  32. package/dist/theme/graph.min.css +2 -2
  33. package/dist/theme/insight.css +2 -1
  34. package/dist/theme/insight.min.css +2 -2
  35. package/dist/theme/modern.css +2 -1
  36. package/dist/theme/modern.min.css +2 -2
  37. package/dist-esm/billboard.js +169 -98
  38. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  39. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +7 -4
  40. package/dist-esm/plugin/billboardjs-plugin-stanford.js +7 -4
  41. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  42. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  43. package/package.json +1 -1
  44. package/src/Chart/api/export.ts +11 -4
  45. package/src/ChartInternal/Axis/Axis.ts +18 -5
  46. package/src/ChartInternal/Axis/AxisRenderer.ts +15 -3
  47. package/src/ChartInternal/Axis/AxisRendererHelper.ts +2 -2
  48. package/src/ChartInternal/data/convert.ts +17 -4
  49. package/src/ChartInternal/data/data.ts +17 -38
  50. package/src/ChartInternal/interactions/eventrect.ts +8 -3
  51. package/src/ChartInternal/interactions/interaction.ts +2 -1
  52. package/src/ChartInternal/internals/domain.ts +1 -1
  53. package/src/ChartInternal/internals/grid.ts +1 -1
  54. package/src/ChartInternal/internals/size.ts +16 -5
  55. package/src/ChartInternal/internals/text.ts +30 -17
  56. package/src/ChartInternal/internals/tooltip.ts +2 -1
  57. package/src/ChartInternal/shape/arc.ts +2 -4
  58. package/src/ChartInternal/shape/point.ts +3 -2
  59. package/src/ChartInternal/shape/radar.ts +2 -1
  60. package/src/ChartInternal/shape/shape.ts +2 -1
  61. package/src/config/Options/axis/axis.ts +19 -5
  62. package/src/config/Options/common/main.ts +1 -1
  63. package/src/config/classes.ts +5 -2
  64. package/src/module/util.ts +45 -20
  65. package/src/scss/billboard.scss +1 -0
  66. package/src/scss/theme/dark.scss +1 -0
  67. package/src/scss/theme/datalab.scss +1 -0
  68. package/src/scss/theme/graph.scss +1 -0
  69. package/src/scss/theme/insight.scss +1 -0
  70. package/src/scss/theme/modern.scss +1 -0
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.16.0-next.1
8
+ * @version 3.16.0-next.2
9
9
  */
10
10
  /*-- Chart --*/
11
11
  .bb svg {
@@ -184,6 +184,7 @@
184
184
  .bb-tooltip-container {
185
185
  z-index: 10;
186
186
  user-select: none;
187
+ transform: translateZ(0);
187
188
  }
188
189
 
189
190
  .bb-tooltip {
package/dist/billboard.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.16.0-next.1
8
+ * @version 3.16.0-next.2
9
9
  */
10
10
  (function webpackUniversalModuleDefinition(root, factory) {
11
11
  if(typeof exports === 'object' && typeof module === 'object')
@@ -235,7 +235,8 @@ const $COMMON = {
235
235
  empty: "bb-empty",
236
236
  main: "bb-main",
237
237
  target: "bb-target",
238
- EXPANDED: "_expanded_"
238
+ EXPANDED: "_expanded_",
239
+ dummy: "_dummy_"
239
240
  };
240
241
  const $ARC = {
241
242
  arc: "bb-arc",
@@ -262,7 +263,9 @@ const $AXIS = {
262
263
  axisYLabel: "bb-axis-y-label",
263
264
  axisXTooltip: "bb-axis-x-tooltip",
264
265
  axisYTooltip: "bb-axis-y-tooltip",
265
- axisY2Tooltip: "bb-axis-y2-tooltip"
266
+ axisY2Tooltip: "bb-axis-y2-tooltip",
267
+ axisTooltipX: "bb-axis-tooltip-x",
268
+ axisTooltipY: "bb-axis-tooltip-y"
266
269
  };
267
270
  const $BAR = {
268
271
  bar: "bb-bar",
@@ -859,7 +862,7 @@ const $ZOOM = {
859
862
  * }
860
863
  */
861
864
  resize_auto: true,
862
- resize_timer: false,
865
+ resize_timer: true,
863
866
  /**
864
867
  * Set a callback to execute when the chart is clicked.
865
868
  * @name onclick
@@ -2416,7 +2419,7 @@ function getRectSegList(path) {
2416
2419
  ];
2417
2420
  }
2418
2421
  function getPathBox(path) {
2419
- const { width, height } = path.getBoundingClientRect();
2422
+ const { width, height } = getBoundingRect(path);
2420
2423
  const items = getRectSegList(path);
2421
2424
  const x = items[0].x;
2422
2425
  const y = Math.min(items[0].y, items[1].y);
@@ -2448,9 +2451,20 @@ function getBrushSelection(ctx) {
2448
2451
  }
2449
2452
  return selection;
2450
2453
  }
2451
- function getBoundingRect(node) {
2452
- const needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +node.getAttribute("width");
2453
- return needEvaluate ? node.rect = node.getBoundingClientRect() : node.rect;
2454
+ function getRect(relativeViewport, node, forceEval = false) {
2455
+ const _ = (n) => n[relativeViewport ? "getBoundingClientRect" : "getBBox"]();
2456
+ if (forceEval) {
2457
+ return _(node);
2458
+ } else {
2459
+ const needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +(node.getAttribute("width") || 0);
2460
+ return needEvaluate ? node.rect = _(node) : node.rect;
2461
+ }
2462
+ }
2463
+ function getBoundingRect(node, forceEval = false) {
2464
+ return getRect(true, node, forceEval);
2465
+ }
2466
+ function getBBox(node, forceEval = false) {
2467
+ return getRect(false, node, forceEval);
2454
2468
  }
2455
2469
  function getRandom(asStr = true, min = 0, max = 1e4) {
2456
2470
  const crpt = win.crypto || win.msCrypto;
@@ -2546,7 +2560,7 @@ function getTransformCTM(node, x = 0, y = 0, inverse = true) {
2546
2560
  inverse ? screen == null ? void 0 : screen.inverse() : screen
2547
2561
  );
2548
2562
  if (inverse === false) {
2549
- const rect = node.getBoundingClientRect();
2563
+ const rect = getBoundingRect(node);
2550
2564
  res.x -= rect.x;
2551
2565
  res.y -= rect.y;
2552
2566
  }
@@ -3577,8 +3591,14 @@ function getDataKeyForJson(keysParam, config) {
3577
3591
  isCustomX = axis.isCustomX();
3578
3592
  }
3579
3593
  const dataKeys = Object.keys(data[0] || {});
3580
- const ids = dataKeys.length ? dataKeys.filter($$.isNotX, $$) : [];
3581
- const xs = dataKeys.length ? dataKeys.filter($$.isX, $$) : [];
3594
+ const { ids, xs } = dataKeys.length ? dataKeys.reduce((acc, key) => {
3595
+ if ($$.isX.call($$, key)) {
3596
+ acc.xs.push(key);
3597
+ } else if ($$.isNotX.call($$, key)) {
3598
+ acc.ids.push(key);
3599
+ }
3600
+ return acc;
3601
+ }, { ids: [], xs: [] }) : { ids: [], xs: [] };
3582
3602
  let xsData;
3583
3603
  ids.forEach((id) => {
3584
3604
  const xKey = this.getXKey(id);
@@ -3606,7 +3626,10 @@ function getDataKeyForJson(keysParam, config) {
3606
3626
  const convertedId = config.data_idConverter.bind($$.api)(id);
3607
3627
  const xKey = $$.getXKey(id);
3608
3628
  const isCategory = isCustomX && isCategorized;
3609
- const hasCategory = isCategory && data.map((v) => v.x).every((v) => config.axis_x_categories.indexOf(v) > -1);
3629
+ const hasCategory = isCategory && (() => {
3630
+ const categorySet = new Set(config.axis_x_categories);
3631
+ return data.every((v) => categorySet.has(v.x));
3632
+ })();
3610
3633
  const isDataAppend = data.__append__;
3611
3634
  const xIndex = xKey === null && isDataAppend ? $$.api.data.values(id).length : 0;
3612
3635
  return {
@@ -3870,9 +3893,10 @@ function getDataKeyForJson(keysParam, config) {
3870
3893
  const minMax = $$.getMinMaxValue(data);
3871
3894
  let min = [];
3872
3895
  let max = [];
3896
+ const { min: minVal, max: maxVal } = minMax;
3873
3897
  data.forEach((v) => {
3874
- const minData = $$.getFilteredDataByValue(v, minMax.min);
3875
- const maxData = $$.getFilteredDataByValue(v, minMax.max);
3898
+ const minData = $$.getFilteredDataByValue(v, minVal);
3899
+ const maxData = $$.getFilteredDataByValue(v, maxVal);
3876
3900
  if (minData.length) {
3877
3901
  min = min.concat(minData);
3878
3902
  }
@@ -3900,7 +3924,7 @@ function getDataKeyForJson(keysParam, config) {
3900
3924
  if (!sum[i]) {
3901
3925
  sum[i] = 0;
3902
3926
  }
3903
- sum[i] += isNumber(v.value) ? v.value : 0;
3927
+ sum[i] += ~~v.value;
3904
3928
  });
3905
3929
  });
3906
3930
  }
@@ -3917,8 +3941,9 @@ function getDataKeyForJson(keysParam, config) {
3917
3941
  const cacheKey = KEY.dataTotalSum;
3918
3942
  let total = $$.cache.get(cacheKey);
3919
3943
  if (!isNumber(total)) {
3920
- const sum = mergeArray($$.data.targets.map((t) => t.values)).map((v) => v.value);
3921
- total = sum.length ? sum.reduce((p, c) => p + c) : 0;
3944
+ total = $$.data.targets.reduce((acc, t) => {
3945
+ return acc + t.values.reduce((sum, v) => sum + ~~v.value, 0);
3946
+ }, 0);
3922
3947
  $$.cache.add(cacheKey, total);
3923
3948
  }
3924
3949
  if (subtractHidden) {
@@ -4082,17 +4107,7 @@ function getDataKeyForJson(keysParam, config) {
4082
4107
  return ys;
4083
4108
  },
4084
4109
  checkValueInTargets(targets, checker) {
4085
- const ids = Object.keys(targets);
4086
- let values;
4087
- for (let i = 0; i < ids.length; i++) {
4088
- values = targets[ids[i]].values;
4089
- for (let j = 0; j < values.length; j++) {
4090
- if (checker(values[j].value)) {
4091
- return true;
4092
- }
4093
- }
4094
- }
4095
- return false;
4110
+ return Object.keys(targets).some((id) => targets[id].values.some((v) => checker(v.value)));
4096
4111
  },
4097
4112
  hasMultiTargets() {
4098
4113
  return this.filterTargetsToShow().length > 1;
@@ -4219,13 +4234,12 @@ function getDataKeyForJson(keysParam, config) {
4219
4234
  return index;
4220
4235
  },
4221
4236
  getDataLabelLength(min, max, key) {
4237
+ var _a;
4222
4238
  const $$ = this;
4223
- const lengths = [0, 0];
4224
4239
  const paddingCoef = 1.3;
4225
- $$.$el.chart.select("svg").selectAll(".dummy").data([min, max]).enter().append("text").text((d) => $$.dataLabelFormat(d.id)(d)).each(function(d, i) {
4226
- lengths[i] = this.getBoundingClientRect()[key] * paddingCoef;
4227
- }).remove();
4228
- return lengths;
4240
+ return ((_a = $$.getTextRect(
4241
+ [min, max].map((v) => $$.dataLabelFormat()(v))
4242
+ )) == null ? void 0 : _a.map((rect) => rect[key] * paddingCoef)) || [0, 0];
4229
4243
  },
4230
4244
  isNoneArc(d) {
4231
4245
  return this.hasTarget(this.data.targets, d.id);
@@ -4407,9 +4421,7 @@ function getDataKeyForJson(keysParam, config) {
4407
4421
  if (state.hiddenTargetIds.length) {
4408
4422
  let hiddenSum = dataValues(state.hiddenTargetIds, false);
4409
4423
  if (hiddenSum.length) {
4410
- hiddenSum = hiddenSum.reduce(
4411
- (acc, curr) => acc.map((v, i) => (isNumber(v) ? v : 0) + curr[i])
4412
- );
4424
+ hiddenSum = hiddenSum.reduce((acc, curr) => acc.map((v, i) => ~~v + curr[i]));
4413
4425
  total = total.map((v, i) => v - hiddenSum[i]);
4414
4426
  }
4415
4427
  }
@@ -4470,7 +4482,7 @@ function getDataKeyForJson(keysParam, config) {
4470
4482
  isBarRangeType(d) {
4471
4483
  const $$ = this;
4472
4484
  const { value } = d;
4473
- return $$.isBarType(d) && isArray(value) && value.length >= 2 && value.every((v) => isNumber(v));
4485
+ return $$.isBarType(d) && isArray(value) && value.length >= 2 && value.every(isNumber);
4474
4486
  },
4475
4487
  /**
4476
4488
  * Get data object by id
@@ -4750,7 +4762,7 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
4750
4762
  if (element) {
4751
4763
  const isMultipleX = $$.isMultipleX();
4752
4764
  const isRotated = config.axis_rotated;
4753
- let { width, left, top } = element.getBoundingClientRect();
4765
+ let { width, left, top } = getBoundingRect(element);
4754
4766
  if (hasAxis && !hasRadar && !isMultipleX) {
4755
4767
  const coords = eventReceiver.coords[index];
4756
4768
  if (coords) {
@@ -6645,7 +6657,7 @@ function getScale(type = "linear", min, max) {
6645
6657
  let v = 0;
6646
6658
  while (v < 30 && parent && parent.tagName !== "BODY") {
6647
6659
  try {
6648
- v = parent.getBoundingClientRect()[key];
6660
+ v = getBoundingRect(parent, true)[key];
6649
6661
  } catch (e) {
6650
6662
  if (offsetName in parent) {
6651
6663
  v = parent[offsetName];
@@ -6680,11 +6692,11 @@ function getScale(type = "linear", min, max) {
6680
6692
  if (hasAxis && (isString(leftLabel) || isString(leftLabel.text) || /^inner-/.test(leftLabel == null ? void 0 : leftLabel.position))) {
6681
6693
  const label = $el.main.select(`.${leftAxisClass}-label`);
6682
6694
  if (!label.empty()) {
6683
- labelWidth = label.node().getBoundingClientRect().left;
6695
+ labelWidth = getBoundingRect(label.node()).left;
6684
6696
  }
6685
6697
  }
6686
- const svgRect = leftAxis && hasLeftAxisRect ? leftAxis.getBoundingClientRect() : { right: 0 };
6687
- const chartRectLeft = $el.chart.node().getBoundingClientRect().left + labelWidth;
6698
+ const svgRect = leftAxis && hasLeftAxisRect ? getBoundingRect(leftAxis, !withoutRecompute) : { right: 0 };
6699
+ const chartRectLeft = getBoundingRect($el.chart.node(), !withoutRecompute).left + labelWidth;
6688
6700
  const hasArc = $$.hasArcType();
6689
6701
  const svgLeft = svgRect.right - chartRectLeft - (hasArc ? 0 : $$.getCurrentPaddingByDirection("left", withoutRecompute));
6690
6702
  return svgLeft > 0 ? svgLeft : 0;
@@ -7167,27 +7179,35 @@ function getTextPos(d, type) {
7167
7179
  },
7168
7180
  /**
7169
7181
  * Gets the getBoundingClientRect value of the element
7170
- * @param {HTMLElement|d3.selection} element Target element
7182
+ * @param {HTMLElement|d3.selection|Array} source Target element
7171
7183
  * @param {string} className Class name
7172
7184
  * @returns {object} value of element.getBoundingClientRect()
7173
7185
  * @private
7174
7186
  */
7175
- getTextRect(element, className) {
7187
+ getTextRect(source, className) {
7188
+ var _a, _b;
7176
7189
  const $$ = this;
7177
- let base = element.node ? element.node() : element;
7178
- if (!/text/i.test(base.tagName)) {
7179
- base = base.querySelector("text");
7190
+ let cacheKey;
7191
+ let base;
7192
+ let text;
7193
+ if (Array.isArray(source)) {
7194
+ cacheKey = `${KEY.textRect}-${source.join("_")}`;
7195
+ } else {
7196
+ base = (_b = (_a = source.node) == null ? void 0 : _a.call(source)) != null ? _b : source;
7197
+ if (!/text/i.test(base.tagName)) {
7198
+ base = base.querySelector("text");
7199
+ }
7200
+ text = base.textContent;
7201
+ cacheKey = `${KEY.textRect}-${text.replace(/\W/g, "_")}`;
7180
7202
  }
7181
- const text = base.textContent;
7182
- const cacheKey = `${KEY.textRect}-${text.replace(/\W/g, "_")}`;
7183
- let rect = $$.cache.get(cacheKey);
7184
- if (!rect) {
7185
- $$.$el.svg.append("text").style("visibility", "hidden").style("font", (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(base).style("font")).classed(className, true).text(text).call((v) => {
7186
- rect = getBoundingRect(v.node());
7203
+ const rect = $$.cache.get(cacheKey) || [];
7204
+ if (rect.length === 0) {
7205
+ ($$.$el.svg || $$.$el.chart.select("svg")).selectAll(`.${$COMMON.dummy}`).data(text ? [text] : source).enter().append("text").style("visibility", "hidden").style("font", base ? (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(base).style("font") : null).classed(className || $COMMON.dummy, true).text((d) => d).each(function(v, i) {
7206
+ rect[i] = getBoundingRect(this);
7187
7207
  }).remove();
7188
7208
  $$.cache.add(cacheKey, rect);
7189
7209
  }
7190
- return rect;
7210
+ return rect.length > 1 ? rect : rect[0];
7191
7211
  },
7192
7212
  /**
7193
7213
  * Gets the x or y coordinate of the text
@@ -7717,7 +7737,7 @@ function getTextXPos(pos = "left", width) {
7717
7737
  y = isRotated ? currPos.xAxis : y;
7718
7738
  }
7719
7739
  const ctm = getTransformCTM(target, x, y, false);
7720
- const rect = target.getBoundingClientRect();
7740
+ const rect = getBoundingRect(target);
7721
7741
  const size = getTransformCTM(target, 20, 0, false).x;
7722
7742
  let top = ctm.y;
7723
7743
  let left = ctm.x + tWidth / 2 + size;
@@ -8670,7 +8690,7 @@ function getGroupedDataPointsFn(d) {
8670
8690
  const x = Math.min(seg0.x, seg1.x);
8671
8691
  const y = Math.min(seg0.y, seg1.y);
8672
8692
  const offset = this.config.bar_sensitivity;
8673
- const { width, height } = that.getBBox();
8693
+ const { width, height } = getBBox(that, true);
8674
8694
  const sx = x - offset;
8675
8695
  const ex = x + width + offset;
8676
8696
  const sy = y + height + offset;
@@ -9693,9 +9713,9 @@ function nodeToSvgDataUrl(node, option, orgSize) {
9693
9713
  }
9694
9714
  function getCoords(elem, svgOffset) {
9695
9715
  const { top, left } = svgOffset;
9696
- const { x, y } = elem.getBBox();
9716
+ const { x, y } = getBBox(elem, true);
9697
9717
  const { a, b, c, d, e, f } = elem.getScreenCTM();
9698
- const { width, height } = elem.getBoundingClientRect();
9718
+ const { width, height } = getBoundingRect(elem, true);
9699
9719
  return {
9700
9720
  x: a * x + c * y + e - left,
9701
9721
  y: b * x + d * y + f - top + (height - Math.round(height / 4)),
@@ -9704,7 +9724,7 @@ function getCoords(elem, svgOffset) {
9704
9724
  };
9705
9725
  }
9706
9726
  function getGlyph(svg) {
9707
- const { left, top } = svg.getBoundingClientRect();
9727
+ const { left, top } = getBoundingRect(svg);
9708
9728
  const filterFn = (t) => t.textContent || t.childElementCount;
9709
9729
  const glyph = [];
9710
9730
  toArray(svg.querySelectorAll("text")).filter(filterFn).forEach((t) => {
@@ -12822,7 +12842,7 @@ class AxisRendererHelper {
12822
12842
  };
12823
12843
  !text.empty() && text.text("0").call((el) => {
12824
12844
  try {
12825
- const { width, height } = el.node().getBBox();
12845
+ const { width, height } = getBBox(el.node(), true);
12826
12846
  if (width && height) {
12827
12847
  size.w = width;
12828
12848
  size.h = height;
@@ -12923,6 +12943,7 @@ var AxisRenderer_publicField = (obj, key, value) => AxisRenderer_defNormalProp(o
12923
12943
 
12924
12944
 
12925
12945
 
12946
+
12926
12947
  class AxisRenderer {
12927
12948
  constructor(params = {}) {
12928
12949
  AxisRenderer_publicField(this, "helper");
@@ -13002,8 +13023,17 @@ class AxisRenderer {
13002
13023
  tickShow.tick && tickEnter.append("line");
13003
13024
  tickShow.text && tickEnter.append("text");
13004
13025
  const tickText = tick.select("text");
13005
- const sizeFor1Char = isFunction(evalTextSize) ? evalTextSize.bind(ctx.params.owner.api)(tickText.node()) : AxisRendererHelper.getSizeFor1Char(tickText, evalTextSize);
13006
13026
  const counts = [];
13027
+ let sizeFor1Char;
13028
+ if (isFunction(evalTextSize)) {
13029
+ sizeFor1Char = evalTextSize.bind(ctx.params.owner.api)(tickText.node(), id);
13030
+ if (this.classList.contains($COMMON.dummy)) {
13031
+ this.sizeFor1Char = sizeFor1Char;
13032
+ }
13033
+ }
13034
+ if (!sizeFor1Char) {
13035
+ sizeFor1Char = AxisRendererHelper.getSizeFor1Char(tickText, !!evalTextSize);
13036
+ }
13007
13037
  let tspan = tickText.selectAll("tspan").data((d, index) => {
13008
13038
  const split = params.tickMultiline ? splitTickText(d, scale1, ticks, isLeftRight, sizeFor1Char.w) : isArray(helper.textFormatted(d)) ? helper.textFormatted(d).concat() : [helper.textFormatted(d)];
13009
13039
  counts[index] = split.length;
@@ -13739,14 +13769,14 @@ class Axis_Axis {
13739
13769
  */
13740
13770
  getMaxTickSize(id, withoutRecompute) {
13741
13771
  const $$ = this.owner;
13742
- const { config, state: { current }, $el: { svg, chart } } = $$;
13772
+ const { config, state: { current, resizing }, $el: { svg, chart } } = $$;
13743
13773
  const currentTickMax = current.maxTickSize[id];
13744
13774
  const configPrefix = `axis_${id}`;
13745
13775
  const max = {
13746
13776
  width: 0,
13747
13777
  height: 0
13748
13778
  };
13749
- if (withoutRecompute || !config[`${configPrefix}_show`] || currentTickMax.width > 0 && $$.filterTargetsToShow().length === 0) {
13779
+ if (resizing || withoutRecompute || !config[`${configPrefix}_show`] || currentTickMax.width > 0 && $$.filterTargetsToShow().length === 0) {
13750
13780
  return currentTickMax;
13751
13781
  }
13752
13782
  if (svg) {
@@ -13781,9 +13811,14 @@ class Axis_Axis {
13781
13811
  }
13782
13812
  !isYAxis && this.updateXAxisTickValues(targetsToShow, axis);
13783
13813
  const dummy = chart.append("svg").style("visibility", "hidden").style("position", "fixed").style("top", "0").style("left", "0");
13784
- axis.create(dummy);
13814
+ const g = dummy.append("g").attr("class", `${$AXIS[`axis${capitalize(id)}`]} ${$COMMON.dummy}`);
13815
+ axis.create(g);
13816
+ const { sizeFor1Char } = g.node();
13785
13817
  dummy.selectAll("text").attr("transform", isNumber(tickRotate) ? `rotate(${tickRotate})` : null).each(function(d, i) {
13786
- const { width, height } = this.getBoundingClientRect();
13818
+ const { width, height } = sizeFor1Char ? {
13819
+ width: this.textContent.length * sizeFor1Char.w,
13820
+ height: sizeFor1Char.h
13821
+ } : getBoundingRect(this, true);
13787
13822
  max.width = Math.max(max.width, width);
13788
13823
  max.height = Math.max(max.height, height);
13789
13824
  if (!isYAxis) {
@@ -14228,7 +14263,7 @@ class Axis_Axis {
14228
14263
  const updateClientRect = () => {
14229
14264
  if (eventReceiver) {
14230
14265
  const scrollPos = getScrollPosition($el.chart.node());
14231
- eventReceiver.rect = rectElement.node().getBoundingClientRect().toJSON();
14266
+ eventReceiver.rect = getBoundingRect(rectElement.node(), true).toJSON();
14232
14267
  eventReceiver.rect.top += scrollPos.y;
14233
14268
  eventReceiver.rect.left += scrollPos.x;
14234
14269
  }
@@ -15058,7 +15093,7 @@ function smoothLines(el, type) {
15058
15093
  hideAxisGridFocus() {
15059
15094
  const $$ = this;
15060
15095
  $$.$el.main.selectAll(
15061
- `line.bb-axis-tooltip-x, line.bb-axis-tooltip-y`
15096
+ `line.${$AXIS.axisTooltipX}, line.${$AXIS.axisTooltipY}`
15062
15097
  ).style("visibility", "hidden");
15063
15098
  Object.values($$.$el.axisTooltip).forEach((v) => v == null ? void 0 : v.style("display", "none"));
15064
15099
  },
@@ -17176,23 +17211,34 @@ var axis_spreadValues = (a, b) => {
17176
17211
  * @memberof Options
17177
17212
  * @type {boolean|Function}
17178
17213
  * @default true
17214
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.AxisEvalTextSize)
17179
17215
  * @example
17180
17216
  * axis: {
17181
17217
  * // will evaluate getting text size every time.
17182
17218
  * evalTextSize: false.
17183
17219
  *
17184
17220
  * // set a custom evaluator
17185
- * evalTextSize: function(textElement) {
17221
+ * evalTextSize: function(textElement, axisId) {
17186
17222
  * // set some character to be evaluated
17187
- * text.textContent = "0";
17223
+ * // NOTE: The dummy textElement is a descendant of given axisId('x', 'y' or 'y2').
17224
+ * textElement.textContent = "0";
17188
17225
  *
17189
17226
  * // get the size
17190
- * const box = text.getBBox();
17227
+ * const box = textElement.getBBox();
17191
17228
  *
17192
17229
  * // clear text
17193
- * text.textContent = "";
17230
+ * textElement.textContent = "";
17194
17231
  *
17195
17232
  * return { w: 7, h: 12};
17233
+ * },
17234
+ *
17235
+ * // set a custom evaluator by returning fixed value
17236
+ * evalTextSize: function(textElement, axisId) {
17237
+ * return {
17238
+ * x: {w: 7, h: 12},
17239
+ * y: {w: 15.75, h: 30},
17240
+ * y2: {w: 9.5, h: 18}
17241
+ * }[axisId];
17196
17242
  * }
17197
17243
  * }
17198
17244
  */
@@ -18052,7 +18098,7 @@ function getAttrTweenFn(fn) {
18052
18098
  value = config.arc_needle_value;
18053
18099
  }
18054
18100
  return tplProcess(title, {
18055
- NEEDLE_VALUE: isNumber(value) ? value : 0
18101
+ NEEDLE_VALUE: ~~value
18056
18102
  });
18057
18103
  }
18058
18104
  return false;
@@ -19887,7 +19933,7 @@ const getTransitionName = () => getRandom();
19887
19933
  if (this.tagName === "circle") {
19888
19934
  point.attr("r", r);
19889
19935
  } else {
19890
- const { width, height } = this.getBBox();
19936
+ const { width, height } = getBBox(this);
19891
19937
  const x = ratio * (+point.attr("x") + width / 2);
19892
19938
  const y = ratio * (+point.attr("y") + height / 2);
19893
19939
  point.attr("transform", `translate(${x} ${y}) scale(${scale})`);
@@ -20020,7 +20066,7 @@ const getTransitionName = () => getRandom();
20020
20066
  },
20021
20067
  update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
20022
20068
  const $$ = this;
20023
- const { width, height } = element.node().getBBox();
20069
+ const { width, height } = getBBox(element.node());
20024
20070
  const xPosFn2 = (d) => isValue(d.value) ? xPosFn(d) - width / 2 : 0;
20025
20071
  const yPosFn2 = (d) => isValue(d.value) ? yPosFn(d) - height / 2 : 0;
20026
20072
  let mainCircles = element;
@@ -20428,7 +20474,7 @@ const cacheKeyTextWidth = KEY.radarTextWidth;
20428
20474
  });
20429
20475
  }).datum((d, i) => ({ index: i })).attr("transform", function(d) {
20430
20476
  if (isUndefined(this.width)) {
20431
- this.width = this.getBoundingClientRect().width / 2;
20477
+ this.width = getBoundingRect(this, true).width / 2;
20432
20478
  }
20433
20479
  let posX = $$.getRadarPosition("x", d.index, void 0, 1);
20434
20480
  let posY = Math.round($$.getRadarPosition("y", d.index, void 0, 1));
@@ -22091,7 +22137,7 @@ const bb = {
22091
22137
  * bb.version; // "1.0.0"
22092
22138
  * @memberof bb
22093
22139
  */
22094
- version: "3.16.0-next.1",
22140
+ version: "3.16.0-next.2",
22095
22141
  /**
22096
22142
  * Generate chart
22097
22143
  * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
@@ -5,5 +5,5 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.16.0-next.1
9
- */.bb svg{font:10px sans-serif;-webkit-tap-highlight-color:rgba(0,0,0,0)}.bb path,.bb line{fill:none;stroke:#000}.bb text,.bb .bb-button{-webkit-user-select:none;-moz-user-select:none;user-select:none}.bb-legend-item-tile,.bb-xgrid-focus,.bb-ygrid-focus,.bb-ygrid{shape-rendering:crispEdges}.bb-chart-arcs .bb-needle,.bb-chart-arc .bb-gauge-value{fill:#000}.bb-chart-arc path{stroke:#fff}.bb-chart-arc rect{stroke:#fff;stroke-width:1}.bb-chart-arc text{fill:#fff;font-size:13px}.bb-chart-funnels path{stroke-width:0}.bb-chart-funnels+.bb-chart-texts text{font-size:13px;fill:#fff}.bb-axis{shape-rendering:crispEdges}.bb-axis .bb-axis-x-tooltip,.bb-axis .bb-axis-y-tooltip,.bb-axis .bb-axis-y2-tooltip{font-size:1em;fill:#fff;white-space:nowrap}.bb-grid{pointer-events:none}.bb-grid line{stroke:#aaa}.bb-grid text{fill:#aaa}.bb-xgrid,.bb-ygrid{stroke-dasharray:3 3}.bb-text.bb-empty{fill:gray;font-size:2em}.bb-line{stroke-width:1px}.bb-circle._expanded_{stroke-width:1px;stroke:#fff}.bb-selected-circle{fill:#fff;stroke-width:2px}.bb-bar{stroke-width:0}.bb-bar._expanded_{fill-opacity:.75}.bb-candlestick{stroke-width:1px}.bb-candlestick._expanded_{fill-opacity:.75}.bb-target.bb-focused,.bb-circles.bb-focused{opacity:1}.bb-target.bb-focused path.bb-line,.bb-target.bb-focused path.bb-step,.bb-circles.bb-focused path.bb-line,.bb-circles.bb-focused path.bb-step{stroke-width:2px}.bb-target.bb-defocused,.bb-circles.bb-defocused{opacity:.3!important}.bb-target.bb-defocused .text-overlapping,.bb-circles.bb-defocused .text-overlapping{opacity:.05!important}.bb-region{fill:#4682b4}.bb-region rect{fill-opacity:.1}.bb-zoom-brush,.bb-brush .extent{fill-opacity:.1}.bb-legend-item{font-size:12px;user-select:none}.bb-legend-item-hidden{opacity:.15}.bb-legend-background{opacity:.75;fill:#fff;stroke:#d3d3d3;stroke-width:1}.bb-title{font:14px sans-serif}.bb-chart-treemaps rect{stroke:#fff;stroke-width:1px}.bb-tooltip-container{z-index:10;user-select:none}.bb-tooltip{border-collapse:collapse;border-spacing:0;background-color:#fff;empty-cells:show;opacity:.9;box-shadow:7px 7px 12px -9px #777;white-space:nowrap}.bb-tooltip tr{border:1px solid #CCC}.bb-tooltip th{background-color:#aaa;font-size:14px;padding:2px 5px;text-align:left;color:#fff}.bb-tooltip td{font-size:13px;padding:3px 6px;background-color:#fff;border-left:1px dotted #999}.bb-tooltip td>span,.bb-tooltip td>svg{display:inline-block;width:10px;height:10px;margin-right:6px}.bb-tooltip.value{text-align:right}.bb-area{stroke-width:0;opacity:.2}.bb-chart-arcs-title{dominant-baseline:middle;font-size:1.3em}text.bb-chart-arcs-gauge-title{dominant-baseline:middle;font-size:2.7em}.bb-chart-arcs .bb-chart-arcs-background{fill:#e0e0e0;stroke:#fff}.bb-chart-arcs .bb-chart-arcs-gauge-unit{fill:#000;font-size:16px}.bb-chart-arcs .bb-chart-arcs-gauge-max,.bb-chart-arcs .bb-chart-arcs-gauge-min{fill:#777}.bb-chart-arcs .bb-levels circle{fill:none;stroke:#848282;stroke-width:.5px}.bb-chart-arcs .bb-levels text{fill:#848282}.bb-chart-radars .bb-levels polygon{fill:none;stroke:#848282;stroke-width:.5px}.bb-chart-radars .bb-levels text{fill:#848282}.bb-chart-radars .bb-axis line{stroke:#848282;stroke-width:.5px}.bb-chart-radars .bb-axis text{font-size:1.15em;cursor:default}.bb-chart-radars .bb-shapes polygon{fill-opacity:.2;stroke-width:1px}.bb-button{position:absolute;top:10px;right:10px}.bb-button .bb-zoom-reset{font-size:11px;border:solid 1px #ccc;background-color:#fff;padding:5px;border-radius:5px;cursor:pointer}
8
+ * @version 3.16.0-next.2
9
+ */.bb svg{font:10px sans-serif;-webkit-tap-highlight-color:rgba(0,0,0,0)}.bb path,.bb line{fill:none;stroke:#000}.bb text,.bb .bb-button{-webkit-user-select:none;-moz-user-select:none;user-select:none}.bb-legend-item-tile,.bb-xgrid-focus,.bb-ygrid-focus,.bb-ygrid{shape-rendering:crispEdges}.bb-chart-arcs .bb-needle,.bb-chart-arc .bb-gauge-value{fill:#000}.bb-chart-arc path{stroke:#fff}.bb-chart-arc rect{stroke:#fff;stroke-width:1}.bb-chart-arc text{fill:#fff;font-size:13px}.bb-chart-funnels path{stroke-width:0}.bb-chart-funnels+.bb-chart-texts text{font-size:13px;fill:#fff}.bb-axis{shape-rendering:crispEdges}.bb-axis .bb-axis-x-tooltip,.bb-axis .bb-axis-y-tooltip,.bb-axis .bb-axis-y2-tooltip{font-size:1em;fill:#fff;white-space:nowrap}.bb-grid{pointer-events:none}.bb-grid line{stroke:#aaa}.bb-grid text{fill:#aaa}.bb-xgrid,.bb-ygrid{stroke-dasharray:3 3}.bb-text.bb-empty{fill:gray;font-size:2em}.bb-line{stroke-width:1px}.bb-circle._expanded_{stroke-width:1px;stroke:#fff}.bb-selected-circle{fill:#fff;stroke-width:2px}.bb-bar{stroke-width:0}.bb-bar._expanded_{fill-opacity:.75}.bb-candlestick{stroke-width:1px}.bb-candlestick._expanded_{fill-opacity:.75}.bb-target.bb-focused,.bb-circles.bb-focused{opacity:1}.bb-target.bb-focused path.bb-line,.bb-target.bb-focused path.bb-step,.bb-circles.bb-focused path.bb-line,.bb-circles.bb-focused path.bb-step{stroke-width:2px}.bb-target.bb-defocused,.bb-circles.bb-defocused{opacity:.3!important}.bb-target.bb-defocused .text-overlapping,.bb-circles.bb-defocused .text-overlapping{opacity:.05!important}.bb-region{fill:#4682b4}.bb-region rect{fill-opacity:.1}.bb-zoom-brush,.bb-brush .extent{fill-opacity:.1}.bb-legend-item{font-size:12px;user-select:none}.bb-legend-item-hidden{opacity:.15}.bb-legend-background{opacity:.75;fill:#fff;stroke:#d3d3d3;stroke-width:1}.bb-title{font:14px sans-serif}.bb-chart-treemaps rect{stroke:#fff;stroke-width:1px}.bb-tooltip-container{z-index:10;user-select:none;transform:translateZ(0)}.bb-tooltip{border-collapse:collapse;border-spacing:0;background-color:#fff;empty-cells:show;opacity:.9;box-shadow:7px 7px 12px -9px #777;white-space:nowrap}.bb-tooltip tr{border:1px solid #CCC}.bb-tooltip th{background-color:#aaa;font-size:14px;padding:2px 5px;text-align:left;color:#fff}.bb-tooltip td{font-size:13px;padding:3px 6px;background-color:#fff;border-left:1px dotted #999}.bb-tooltip td>span,.bb-tooltip td>svg{display:inline-block;width:10px;height:10px;margin-right:6px}.bb-tooltip.value{text-align:right}.bb-area{stroke-width:0;opacity:.2}.bb-chart-arcs-title{dominant-baseline:middle;font-size:1.3em}text.bb-chart-arcs-gauge-title{dominant-baseline:middle;font-size:2.7em}.bb-chart-arcs .bb-chart-arcs-background{fill:#e0e0e0;stroke:#fff}.bb-chart-arcs .bb-chart-arcs-gauge-unit{fill:#000;font-size:16px}.bb-chart-arcs .bb-chart-arcs-gauge-max,.bb-chart-arcs .bb-chart-arcs-gauge-min{fill:#777}.bb-chart-arcs .bb-levels circle{fill:none;stroke:#848282;stroke-width:.5px}.bb-chart-arcs .bb-levels text{fill:#848282}.bb-chart-radars .bb-levels polygon{fill:none;stroke:#848282;stroke-width:.5px}.bb-chart-radars .bb-levels text{fill:#848282}.bb-chart-radars .bb-axis line{stroke:#848282;stroke-width:.5px}.bb-chart-radars .bb-axis text{font-size:1.15em;cursor:default}.bb-chart-radars .bb-shapes polygon{fill-opacity:.2;stroke-width:1px}.bb-button{position:absolute;top:10px;right:10px}.bb-button .bb-zoom-reset{font-size:11px;border:solid 1px #ccc;background-color:#fff;padding:5px;border-radius:5px;cursor:pointer}