billboard.js 3.14.1 → 3.14.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 (51) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +74 -37
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +9 -9
  5. package/dist/billboard.pkgd.js +74 -37
  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 +9 -3
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +9 -3
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +9 -3
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +4 -4
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +9 -3
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  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 +9 -3
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +2 -2
  21. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +9 -3
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +7 -7
  23. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +9 -3
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +2 -2
  25. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +9 -3
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +2 -2
  27. package/dist/theme/dark.css +1 -1
  28. package/dist/theme/dark.min.css +1 -1
  29. package/dist/theme/datalab.css +1 -1
  30. package/dist/theme/datalab.min.css +1 -1
  31. package/dist/theme/graph.css +1 -1
  32. package/dist/theme/graph.min.css +1 -1
  33. package/dist/theme/insight.css +1 -1
  34. package/dist/theme/insight.min.css +1 -1
  35. package/dist/theme/modern.css +1 -1
  36. package/dist/theme/modern.min.css +1 -1
  37. package/dist-esm/billboard.js +88 -49
  38. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  39. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +77 -4
  40. package/dist-esm/plugin/billboardjs-plugin-stanford.js +77 -4
  41. package/dist-esm/plugin/billboardjs-plugin-tableview.js +77 -4
  42. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +66 -3
  43. package/package.json +1 -1
  44. package/src/ChartInternal/Axis/Axis.ts +23 -0
  45. package/src/ChartInternal/data/data.ts +4 -3
  46. package/src/ChartInternal/interactions/subchart.ts +2 -25
  47. package/src/ChartInternal/interactions/zoom.ts +21 -0
  48. package/src/ChartInternal/internals/tooltip.ts +25 -15
  49. package/src/config/Options/axis/x.ts +2 -1
  50. package/src/module/util.ts +10 -2
  51. package/types/axis.d.ts +2 -2
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.14.1
8
+ * @version 3.14.2
9
9
  */
10
10
  /*-- Chart --*/
11
11
  .bb svg {
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.14.1
8
+ * @version 3.14.2
9
9
  */
10
10
  (function webpackUniversalModuleDefinition(root, factory) {
11
11
  if(typeof exports === 'object' && typeof module === 'object')
@@ -2520,9 +2520,15 @@ function getScrollPosition(node) {
2520
2520
  function getTransformCTM(node, x = 0, y = 0, inverse = true) {
2521
2521
  const point = new DOMPoint(x, y);
2522
2522
  const screen = node.getScreenCTM();
2523
- return point.matrixTransform(
2523
+ const res = point.matrixTransform(
2524
2524
  inverse ? screen == null ? void 0 : screen.inverse() : screen
2525
2525
  );
2526
+ if (inverse === false) {
2527
+ const rect = node.getBoundingClientRect();
2528
+ res.x -= rect.x;
2529
+ res.y -= rect.y;
2530
+ }
2531
+ return res;
2526
2532
  }
2527
2533
  function getTranslation(node) {
2528
2534
  const transform = node ? node.transform : null;
@@ -4162,11 +4168,13 @@ function getDataKeyForJson(keysParam, config) {
4162
4168
  const isRotated = config.axis_rotated;
4163
4169
  const scrollPos = getScrollPosition($el.chart.node());
4164
4170
  const e = inputType === "touch" && event.changedTouches ? event.changedTouches[0] : event;
4165
- let point = isRotated ? e.clientY + scrollPos.y - rect.top : e.clientX + scrollPos.x - rect.left;
4171
+ let point = isRotated ? e.clientY + scrollPos.y : e.clientX + scrollPos.x;
4166
4172
  if (hasViewBox($el.svg)) {
4167
4173
  const pos = [point, 0];
4168
4174
  isRotated && pos.reverse();
4169
4175
  point = getTransformCTM($el.svg.node(), ...pos)[isRotated ? "y" : "x"];
4176
+ } else {
4177
+ point -= isRotated ? rect.top : rect.left;
4170
4178
  }
4171
4179
  index = findIndex(
4172
4180
  coords,
@@ -7654,32 +7662,44 @@ function getTextXPos(pos = "left", width) {
7654
7662
  });
7655
7663
  }
7656
7664
  },
7665
+ /**
7666
+ * Get tooltip position when svg has vieBox attribute
7667
+ * @param {number} tWidth Tooltip width value
7668
+ * @param {number} tHeight Tooltip height value
7669
+ * @param {object} currPos Current event position value from SVG coordinate
7670
+ * @returns {object} top, left value
7671
+ */
7657
7672
  getTooltipPositionViewBox(tWidth, tHeight, currPos) {
7658
7673
  var _a, _b;
7659
7674
  const $$ = this;
7660
- const { $el: { eventRect, main }, config, state } = $$;
7675
+ const { $el: { eventRect, svg }, config, state } = $$;
7661
7676
  const isRotated = config.axis_rotated;
7662
- const hasArcType = $$.hasArcType(void 0, ["radar"]) || state.hasFunnel || state.hasTreemap;
7663
- const target = (_b = (_a = state.hasRadar ? main : eventRect) == null ? void 0 : _a.node()) != null ? _b : state.event.target;
7664
- const size = 38;
7677
+ const hasArcType = $$.hasArcType() || state.hasFunnel || state.hasTreemap;
7678
+ const target = (_b = (_a = hasArcType ? svg : eventRect) == null ? void 0 : _a.node()) != null ? _b : state.event.target;
7665
7679
  let { x, y } = currPos;
7666
7680
  if (state.hasAxis) {
7667
7681
  x = isRotated ? x : currPos.xAxis;
7668
7682
  y = isRotated ? currPos.xAxis : y;
7669
7683
  }
7670
7684
  const ctm = getTransformCTM(target, x, y, false);
7685
+ const rect = target.getBoundingClientRect();
7686
+ const size = getTransformCTM(target, 20, 0, false).x;
7671
7687
  let top = ctm.y;
7672
- let left = ctm.x + size;
7688
+ let left = ctm.x + tWidth / 2 + size;
7673
7689
  if (hasArcType) {
7674
- top += tHeight;
7675
- left -= size;
7690
+ if (state.hasFunnel || state.hasTreemap || state.hasRadar) {
7691
+ left -= tWidth / 2 + size;
7692
+ top += tHeight;
7693
+ } else {
7694
+ top += rect.height / 2;
7695
+ left += rect.width / 2 - (tWidth - size);
7696
+ }
7676
7697
  }
7677
- const rect = (hasArcType ? main.node() : target).getBoundingClientRect();
7678
- if (left + tWidth > rect.right) {
7679
- left = rect.right - tWidth - size;
7698
+ if (left + tWidth > rect.width) {
7699
+ left = rect.width - tWidth - size;
7680
7700
  }
7681
- if (top + tHeight > rect.bottom) {
7682
- top -= tHeight + size;
7701
+ if (top + tHeight > rect.height) {
7702
+ top -= tHeight * 2;
7683
7703
  }
7684
7704
  return {
7685
7705
  top,
@@ -10907,7 +10927,7 @@ extend(zoom, {
10907
10927
  };
10908
10928
  $$.brush.scale = function(scale2) {
10909
10929
  const h = config.subchart_size_height;
10910
- let extent = $$.getExtent();
10930
+ let extent = $$.axis.getExtent();
10911
10931
  if (!extent && scale2.range) {
10912
10932
  extent = [[0, 0], [scale2.range()[1], h]];
10913
10933
  } else if (isArray(extent)) {
@@ -11088,25 +11108,6 @@ extend(zoom, {
11088
11108
  const subXAxis = (transitions == null ? void 0 : transitions.axisSubX) ? transitions.axisSubX : $T(subchart.main.select(`.${classes.axisX}`), withTransition);
11089
11109
  subchart.main.attr("transform", $$.getTranslate("context"));
11090
11110
  subXAxis.attr("transform", $$.getTranslate("subX"));
11091
- },
11092
- /**
11093
- * Get extent value
11094
- * @returns {Array} default extent
11095
- * @private
11096
- */
11097
- getExtent() {
11098
- const $$ = this;
11099
- const { config, scale } = $$;
11100
- let extent = config.axis_x_extent;
11101
- if (extent) {
11102
- if (isFunction(extent)) {
11103
- extent = extent.bind($$.api)($$.getXDomain($$.data.targets), scale.subX);
11104
- } else if ($$.axis.isTimeSeries() && extent.every(isNaN)) {
11105
- const fn = parseDate.bind($$);
11106
- extent = extent.map((v) => scale.subX(fn(v)));
11107
- }
11108
- }
11109
- return extent;
11110
11111
  }
11111
11112
  });
11112
11113
 
@@ -11348,12 +11349,14 @@ extend(zoom, {
11348
11349
  let start = 0;
11349
11350
  let end = 0;
11350
11351
  let zoomRect;
11352
+ let extent;
11351
11353
  const prop = {
11352
11354
  axis: isRotated ? "y" : "x",
11353
11355
  attr: isRotated ? "height" : "width",
11354
11356
  index: isRotated ? 1 : 0
11355
11357
  };
11356
11358
  $$.zoomBehaviour = (0,external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_.drag)().clickDistance(4).on("start", function(event) {
11359
+ extent = $$.scale.zoom ? null : $$.axis.getExtent();
11357
11360
  state.event = event;
11358
11361
  $$.setDragStatus(true);
11359
11362
  $$.unselectRect();
@@ -11361,11 +11364,25 @@ extend(zoom, {
11361
11364
  zoomRect = $$.$el.main.append("rect").attr("clip-path", state.clip.path).attr("class", $ZOOM.zoomBrush).attr("width", isRotated ? state.width : 0).attr("height", isRotated ? 0 : state.height);
11362
11365
  }
11363
11366
  start = getPointer(event, this)[prop.index];
11367
+ if (extent) {
11368
+ if (start < extent[0]) {
11369
+ start = extent[0];
11370
+ } else if (start > extent[1]) {
11371
+ start = extent[1];
11372
+ }
11373
+ }
11364
11374
  end = start;
11365
11375
  zoomRect.attr(prop.axis, start).attr(prop.attr, 0);
11366
11376
  $$.onZoomStart(event);
11367
11377
  }).on("drag", function(event) {
11368
11378
  end = getPointer(event, this)[prop.index];
11379
+ if (extent) {
11380
+ if (end > extent[1]) {
11381
+ end = extent[1];
11382
+ } else if (end < extent[0]) {
11383
+ end = extent[0];
11384
+ }
11385
+ }
11369
11386
  zoomRect.attr(prop.axis, Math.min(start, end)).attr(prop.attr, Math.abs(end - start));
11370
11387
  }).on("end", (event) => {
11371
11388
  const scale = $$.scale.zoom || $$.scale.x;
@@ -13291,6 +13308,25 @@ class Axis_Axis {
13291
13308
  }
13292
13309
  return type;
13293
13310
  }
13311
+ /**
13312
+ * Get extent value
13313
+ * @returns {Array} default extent
13314
+ * @private
13315
+ */
13316
+ getExtent() {
13317
+ const $$ = this.owner;
13318
+ const { config, scale } = $$;
13319
+ let extent = config.axis_x_extent;
13320
+ if (extent) {
13321
+ if (isFunction(extent)) {
13322
+ extent = extent.bind($$.api)($$.getXDomain($$.data.targets), scale.subX);
13323
+ } else if (this.isTimeSeries() && extent.every(isNaN)) {
13324
+ const fn = parseDate.bind($$);
13325
+ extent = extent.map((v) => scale.subX(fn(v)));
13326
+ }
13327
+ }
13328
+ return extent;
13329
+ }
13294
13330
  init() {
13295
13331
  const $$ = this.owner;
13296
13332
  const { config, $el: { main, axis }, state: { clip } } = $$;
@@ -15939,7 +15975,8 @@ function smoothLines(el, type) {
15939
15975
  */
15940
15976
  axis_x_height: void 0,
15941
15977
  /**
15942
- * Set default extent for subchart and zoom. This can be an array or function that returns an array.
15978
+ * Set extent for subchart and zoom(drag only). This can be an array or function that returns an array.
15979
+ * - **NOTE:** Specifying value, will limit the zoom scope selection within.
15943
15980
  * @name axis․x․extent
15944
15981
  * @memberof Options
15945
15982
  * @type {Array|Function}
@@ -21825,7 +21862,7 @@ const bb = {
21825
21862
  * bb.version; // "1.0.0"
21826
21863
  * @memberof bb
21827
21864
  */
21828
- version: "3.14.1",
21865
+ version: "3.14.2",
21829
21866
  /**
21830
21867
  * Generate chart
21831
21868
  * - **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.14.1
8
+ * @version 3.14.2
9
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}