billboard.js 3.9.0-next.1 → 3.9.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 (46) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +65 -15
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +65 -15
  6. package/dist/billboard.pkgd.min.js +2 -2
  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 +2 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +2 -2
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +2 -2
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +2 -2
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +2 -2
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +2 -2
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +2 -2
  22. package/dist/theme/dark.css +1 -1
  23. package/dist/theme/dark.min.css +1 -1
  24. package/dist/theme/datalab.css +1 -1
  25. package/dist/theme/datalab.min.css +1 -1
  26. package/dist/theme/graph.css +1 -1
  27. package/dist/theme/graph.min.css +1 -1
  28. package/dist/theme/insight.css +1 -1
  29. package/dist/theme/insight.min.css +1 -1
  30. package/dist-esm/billboard.js +63 -18
  31. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  32. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  33. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  34. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  35. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  36. package/package.json +6 -6
  37. package/src/ChartInternal/ChartInternal.ts +9 -3
  38. package/src/ChartInternal/data/IData.ts +5 -0
  39. package/src/ChartInternal/data/data.ts +21 -8
  40. package/src/ChartInternal/shape/bar.ts +7 -3
  41. package/src/ChartInternal/shape/bubble.ts +0 -1
  42. package/src/ChartInternal/shape/point.ts +2 -0
  43. package/src/config/Options/common/point.ts +30 -2
  44. package/src/config/Options/shape/bar.ts +7 -1
  45. package/types/options.d.ts +7 -2
  46. package/types/options.shape.d.ts +9 -4
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.9.0-next.1
8
+ * @version 3.9.0-next.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.9.0-next.1
8
+ * @version 3.9.0-next.2
9
9
  */
10
10
  (function webpackUniversalModuleDefinition(root, factory) {
11
11
  if(typeof exports === 'object' && typeof module === 'object')
@@ -5088,7 +5088,17 @@ function getDataKeyForJson(keysParam, config) {
5088
5088
  _newArrowCheck(this, _this36);
5089
5089
  return v && isValue(v.value);
5090
5090
  }.bind(this)),
5091
- minDist = config.point_sensitivity,
5091
+ getSensitivity = function (d) {
5092
+ _newArrowCheck(this, _this36);
5093
+ var sensitivity = config.point_sensitivity;
5094
+ if (isFunction(sensitivity)) {
5095
+ sensitivity = sensitivity.call($$.api, d);
5096
+ } else if (sensitivity === "radius") {
5097
+ sensitivity = d.r;
5098
+ }
5099
+ return sensitivity;
5100
+ }.bind(this),
5101
+ minDist,
5092
5102
  closest;
5093
5103
  // find mouseovering bar/candlestick
5094
5104
  // https://github.com/naver/billboard.js/issues/2434
@@ -5110,6 +5120,7 @@ function getDataKeyForJson(keysParam, config) {
5110
5120
  }.bind(this)).forEach(function (v) {
5111
5121
  _newArrowCheck(this, _this36);
5112
5122
  var d = $$.dist(v, pos);
5123
+ minDist = getSensitivity(v);
5113
5124
  if (d < minDist) {
5114
5125
  minDist = d;
5115
5126
  closest = v;
@@ -5121,11 +5132,13 @@ function getDataKeyForJson(keysParam, config) {
5121
5132
  var $$ = this,
5122
5133
  isRotated = $$.config.axis_rotated,
5123
5134
  scale = $$.scale,
5124
- xIndex = isRotated ? 1 : 0,
5125
- yIndex = isRotated ? 0 : 1,
5126
5135
  y = $$.circleY(data, data.index),
5127
5136
  x = (scale.zoom || scale.x)(data.x);
5128
- return Math.sqrt(Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2));
5137
+
5138
+ // true: 1, false: 0
5139
+ // true: 0, false: 1
5140
+
5141
+ return Math.sqrt(Math.pow(x - pos[+isRotated], 2) + Math.pow(y - pos[+!isRotated], 2));
5129
5142
  },
5130
5143
  /**
5131
5144
  * Convert data for step type
@@ -10656,6 +10669,7 @@ var ChartInternal = /*#__PURE__*/function () {
10656
10669
  // Define g for chart area
10657
10670
  main.append("g").classed($COMMON.chart, !0).attr("clip-path", hasAxis ? state.clip.path : null);
10658
10671
  $$.callPluginHook("$init");
10672
+ $$.initChartElements();
10659
10673
  if (hasAxis) {
10660
10674
  var _$$$axis;
10661
10675
  // Cover whole with rects for events
@@ -10667,7 +10681,6 @@ var ChartInternal = /*#__PURE__*/function () {
10667
10681
  // Add Axis here, when clipPath is 'true'
10668
10682
  config.clipPath && ((_$$$axis = $$.axis) == null ? void 0 : _$$$axis.init());
10669
10683
  }
10670
- $$.initChartElements();
10671
10684
 
10672
10685
  // Set targets
10673
10686
  $$.updateTargets($$.data.targets);
@@ -10712,7 +10725,11 @@ var ChartInternal = /*#__PURE__*/function () {
10712
10725
  hasTreemap = _$$$state.hasTreemap,
10713
10726
  types = [];
10714
10727
  if (hasAxis) {
10715
- ["bar", "bubble", "candlestick", "line"].forEach(function (v) {
10728
+ var shapes = ["bar", "bubble", "candlestick", "line"];
10729
+ if ($$.config.bar_front) {
10730
+ shapes.push(shapes.shift());
10731
+ }
10732
+ shapes.forEach(function (v) {
10716
10733
  _newArrowCheck(this, _this5);
10717
10734
  var name = capitalize(v);
10718
10735
  if (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) {
@@ -19552,9 +19569,9 @@ function getAttrTweenFn(fn) {
19552
19569
  var $el = this.$el,
19553
19570
  config = this.config,
19554
19571
  clip = this.state.clip;
19555
- $el.bar = $el.main.select("." + $COMMON.chart)
19556
- // should positioned at the beginning of the shape node to not overlap others
19557
- .insert("g", ":first-child").attr("class", $BAR.chartBars).call(this.setCssRule(!1, "." + $BAR.chartBars, ["pointer-events:none"]));
19572
+ $el.bar = $el.main.select("." + $COMMON.chart);
19573
+ $el.bar = config.bar_front ? $el.bar.append("g") : $el.bar.insert("g", ":first-child");
19574
+ $el.bar.attr("class", $BAR.chartBars).call(this.setCssRule(!1, "." + $BAR.chartBars, ["pointer-events:none"]));
19558
19575
 
19559
19576
  // set clip-path attribute when condition meet
19560
19577
  // https://github.com/naver/billboard.js/issues/2421
@@ -20153,7 +20170,6 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
20153
20170
  if ($$.hasType("bubble")) {
20154
20171
  config.point_show = !0;
20155
20172
  config.point_type = "circle";
20156
- config.point_sensitivity = 25;
20157
20173
  }
20158
20174
  },
20159
20175
  /**
@@ -20778,6 +20794,7 @@ var getTransitionName = function () {
20778
20794
  } else if (isFunction(pointR)) {
20779
20795
  r = pointR.bind($$.api)(d);
20780
20796
  }
20797
+ d.r = r;
20781
20798
  return r;
20782
20799
  },
20783
20800
  pointExpandedR: function pointExpandedR(d) {
@@ -21767,6 +21784,7 @@ function convertDataToTreemapData(data) {
21767
21784
  * Copyright (c) 2017 ~ present NAVER Corp.
21768
21785
  * billboard.js project is licensed under the MIT license
21769
21786
  */
21787
+
21770
21788
  /**
21771
21789
  * point config options
21772
21790
  */
@@ -21788,7 +21806,20 @@ function convertDataToTreemapData(data) {
21788
21806
  * - **NOTE:**
21789
21807
  * - `null` will make to not set inline 'opacity' css prop.
21790
21808
  * - when no value(or undefined) is set, it defaults to set opacity value according its chart types.
21791
- * @property {number} [point.sensitivity=10] The senstivity value for interaction boundary.
21809
+ * @property {number|string|Function} [point.sensitivity=10] The senstivity value for interaction boundary.
21810
+ * - **Available Values:**
21811
+ * - {number}: Absolute sensitivity value which is the distance from the data point in pixel.
21812
+ * - "radius": sensitivity based on point's radius
21813
+ * - Function: callback for each point to determine the sensitivity<br>
21814
+ * ```js
21815
+ * sensitivity: function(d) {
21816
+ * // ex. of argument d:
21817
+ * // ==> {x: 2, value: 55, id: 'data3', index: 2, r: 19.820624179302296}
21818
+ *
21819
+ * // returning d.r, will make sensitivity same as point's radius value.
21820
+ * return d.r;
21821
+ * }
21822
+ * ```
21792
21823
  * @property {number} [point.select.r=point.r*4] The radius size of each point on selected.
21793
21824
  * @property {string} [point.type="circle"] The type of point to be drawn
21794
21825
  * - **NOTE:**
@@ -21809,6 +21840,7 @@ function convertDataToTreemapData(data) {
21809
21840
  * (ex. `<polygon points='2.5 0 0 5 5 5'></polygon>`)
21810
21841
  * @see [Demo: point type](https://naver.github.io/billboard.js/demo/#Point.RectanglePoints)
21811
21842
  * @see [Demo: point focus only](https://naver.github.io/billboard.js/demo/#Point.FocusOnly)
21843
+ * @see [Demo: point sensitivity](https://naver.github.io/billboard.js/demo/#Point.PointSensitivity)
21812
21844
  * @example
21813
21845
  * point: {
21814
21846
  * show: false,
@@ -21841,6 +21873,18 @@ function convertDataToTreemapData(data) {
21841
21873
  * // having lower value, means how closer to be for interaction
21842
21874
  * sensitivity: 3,
21843
21875
  *
21876
+ * // sensitivity based on point's radius
21877
+ * sensitivity: "radius",
21878
+ *
21879
+ * // callback for each point to determine the sensitivity
21880
+ * sensitivity: function(d) {
21881
+ * // ex. of argument d:
21882
+ * // ==> {x: 2, value: 55, id: 'data3', index: 2, r: 19.820624179302296}
21883
+ *
21884
+ * // returning d.r, will make sensitivity same as point's radius value.
21885
+ * return d.r;
21886
+ * }
21887
+ *
21844
21888
  * // valid values are "circle" or "rectangle"
21845
21889
  * type: "rectangle",
21846
21890
  *
@@ -21948,6 +21992,7 @@ function convertDataToTreemapData(data) {
21948
21992
  * @memberof Options
21949
21993
  * @type {object}
21950
21994
  * @property {object} bar Bar object
21995
+ * @property {boolean} [bar.front=false] Set 'bar' to be positioned over(on the top) other shapes elements.
21951
21996
  * @property {number} [bar.indices.removeNull=false] Remove nullish data on bar indices positions.
21952
21997
  * @property {number} [bar.label.threshold=0] Set threshold ratio to show/hide labels.
21953
21998
  * @property {boolean|object} [bar.linearGradient=false] Set the linear gradient on bar.<br><br>
@@ -21970,6 +22015,7 @@ function convertDataToTreemapData(data) {
21970
22015
  * @property {number} [bar.width.dataname.ratio=0.6] Change the width of bar chart by ratio.
21971
22016
  * @property {number} [bar.width.dataname.max] The maximum width value for ratio.
21972
22017
  * @property {boolean} [bar.zerobased=true] Set if min or max value will be 0 on bar chart.
22018
+ * @see [Demo: bar front](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarFront)
21973
22019
  * @see [Demo: bar indices](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarIndices)
21974
22020
  * @see [Demo: bar overlap](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarOverlap)
21975
22021
  * @see [Demo: bar padding](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarPadding)
@@ -21978,6 +22024,9 @@ function convertDataToTreemapData(data) {
21978
22024
  * @see [Demo: bar width variant](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarWidthVariant)
21979
22025
  * @example
21980
22026
  * bar: {
22027
+ * // make bar shape to be positioned over the other shape elements
22028
+ * front: true,
22029
+ *
21981
22030
  * // remove nullish data on bar indices postions
21982
22031
  * indices: {
21983
22032
  * removeNull: true
@@ -22048,9 +22097,10 @@ function convertDataToTreemapData(data) {
22048
22097
  * zerobased: false
22049
22098
  * }
22050
22099
  */
22100
+ bar_front: !1,
22101
+ bar_indices_removeNull: !1,
22051
22102
  bar_label_threshold: 0,
22052
22103
  bar_linearGradient: !1,
22053
- bar_indices_removeNull: !1,
22054
22104
  bar_overlap: !1,
22055
22105
  bar_padding: 0,
22056
22106
  bar_radius: undefined,
@@ -24993,7 +25043,7 @@ var _defaults = {};
24993
25043
 
24994
25044
  /**
24995
25045
  * @namespace bb
24996
- * @version 3.9.0-next.1
25046
+ * @version 3.9.0-next.2
24997
25047
  */
24998
25048
  var bb = {
24999
25049
  /**
@@ -25003,7 +25053,7 @@ var bb = {
25003
25053
  * bb.version; // "1.0.0"
25004
25054
  * @memberof bb
25005
25055
  */
25006
- version: "3.9.0-next.1",
25056
+ version: "3.9.0-next.2",
25007
25057
  /**
25008
25058
  * Generate chart
25009
25059
  * - **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.9.0-next.1
8
+ * @version 3.9.0-next.2
9
9
  */.bb svg{-webkit-tap-highlight-color:rgba(0,0,0,0);font:10px sans-serif}.bb line,.bb path{fill:none;stroke:#000}.bb .bb-button,.bb text{-webkit-user-select:none;-moz-user-select:none;user-select:none}.bb-legend-item-tile,.bb-xgrid-focus,.bb-ygrid,.bb-ygrid-focus{shape-rendering:crispEdges}.bb-chart-arc .bb-gauge-value,.bb-chart-arcs .bb-needle{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-axis{shape-rendering:crispEdges}.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:grey;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-circles.bb-focused,.bb-target.bb-focused{opacity:1}.bb-circles.bb-focused path.bb-line,.bb-circles.bb-focused path.bb-step,.bb-target.bb-focused path.bb-line,.bb-target.bb-focused path.bb-step{stroke-width:2px}.bb-circles.bb-defocused,.bb-target.bb-defocused{opacity:.3!important}.bb-circles.bb-defocused .text-overlapping,.bb-target.bb-defocused .text-overlapping{opacity:.05!important}.bb-region{fill:#4682b4}.bb-brush .extent,.bb-region,.bb-zoom-brush{fill-opacity:.1}.bb-legend-item{font-size:12px;user-select:none}.bb-legend-item-hidden{opacity:.15}.bb-legend-background{fill:#fff;stroke:#d3d3d3;stroke-width:1;opacity:.75}.bb-title{font:14px sans-serif}.bb-chart-treemaps rect{stroke:#fff;stroke-width:1px}.bb-tooltip-container{user-select:none;z-index:10}.bb-tooltip{background-color:#fff;border-collapse:collapse;border-spacing:0;box-shadow:7px 7px 12px -9px #777;empty-cells:show;opacity:.9;white-space:nowrap}.bb-tooltip tr{border:1px solid #ccc}.bb-tooltip th{background-color:#aaa;color:#fff;font-size:14px;padding:2px 5px;text-align:left}.bb-tooltip td{background-color:#fff;border-left:1px dotted #999;font-size:13px;padding:3px 6px}.bb-tooltip td>span,.bb-tooltip td>svg{display:inline-block;height:10px;margin-right:6px;width:10px}.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{cursor:default;font-size:1.15em}.bb-chart-radars .bb-shapes polygon{fill-opacity:.2;stroke-width:1px}.bb-button{position:absolute;right:10px;top:10px}.bb-button .bb-zoom-reset{background-color:#fff;border:1px solid #ccc;border-radius:5px;cursor:pointer;font-size:11px;padding:5px}