billboard.js 3.4.0-next.1 → 3.4.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 (42) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +121 -41
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +121 -41
  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/datalab.css +1 -1
  23. package/dist/theme/datalab.min.css +1 -1
  24. package/dist/theme/graph.css +1 -1
  25. package/dist/theme/graph.min.css +1 -1
  26. package/dist/theme/insight.css +1 -1
  27. package/dist/theme/insight.min.css +1 -1
  28. package/dist-esm/billboard.js +105 -36
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  31. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  32. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  33. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  34. package/package.json +6 -6
  35. package/src/Chart/api/axis.ts +90 -25
  36. package/src/ChartInternal/ChartInternal.ts +6 -3
  37. package/src/ChartInternal/interactions/flow.ts +1 -1
  38. package/src/config/Options/common/main.ts +19 -2
  39. package/src/module/generator.ts +12 -4
  40. package/types/chart.d.ts +8 -8
  41. package/types/options.d.ts +7 -2
  42. package/types/types.d.ts +2 -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.4.0-next.1
8
+ * @version 3.4.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.4.0-next.1
8
+ * @version 3.4.0-next.2
9
9
  */
10
10
  (function webpackUniversalModuleDefinition(root, factory) {
11
11
  if(typeof exports === 'object' && typeof module === 'object')
@@ -1806,6 +1806,21 @@ var Store = /*#__PURE__*/function () {
1806
1806
  */
1807
1807
  resize_auto: !0,
1808
1808
 
1809
+ /**
1810
+ * Set a callback to execute when the chart is clicked.
1811
+ * @name onclick
1812
+ * @memberof Options
1813
+ * @type {Function}
1814
+ * @default undefined
1815
+ * @example
1816
+ * onclick: function(event) {
1817
+ * this; // chart instance itself
1818
+ * event; // native event object
1819
+ * ...
1820
+ * }
1821
+ */
1822
+ onclick: undefined,
1823
+
1809
1824
  /**
1810
1825
  * Set a callback to execute when mouse/touch enters the chart.
1811
1826
  * @name onover
@@ -1813,8 +1828,9 @@ var Store = /*#__PURE__*/function () {
1813
1828
  * @type {Function}
1814
1829
  * @default undefined
1815
1830
  * @example
1816
- * onover: function() {
1831
+ * onover: function(event) {
1817
1832
  * this; // chart instance itself
1833
+ * event; // native event object
1818
1834
  * ...
1819
1835
  * }
1820
1836
  */
@@ -1827,8 +1843,9 @@ var Store = /*#__PURE__*/function () {
1827
1843
  * @type {Function}
1828
1844
  * @default undefined
1829
1845
  * @example
1830
- * onout: function() {
1846
+ * onout: function(event) {
1831
1847
  * this; // chart instance itself
1848
+ * event; // native event object
1832
1849
  * ...
1833
1850
  * }
1834
1851
  */
@@ -3591,28 +3608,32 @@ function generateResize() {
3591
3608
 
3592
3609
  return callResizeFn;
3593
3610
  }
3611
+
3594
3612
  /**
3595
3613
  * Generate transition queue function
3596
3614
  * @returns {Function}
3597
3615
  * @private
3598
3616
  */
3599
-
3600
3617
  function generateWait() {
3601
3618
  var transitionsToWait = [],
3602
- f = function (t, callback) {
3603
- var timer; // eslint-disable-next-line
3619
+ f = function (selection, callback) {
3620
+ var timer;
3621
+ /**
3622
+ * Check if transition is complete
3623
+ * @private
3624
+ */
3604
3625
 
3605
3626
  function loop() {
3606
3627
  var done = 0;
3607
3628
 
3608
- for (var i = 0, _t; _t = transitionsToWait[i]; i++) {
3609
- if (_t === !0 || _t.empty != null && _t.empty()) {
3629
+ for (var i = 0, t; t = transitionsToWait[i]; i++) {
3630
+ if (t === !0 || t.empty != null && t.empty()) {
3610
3631
  done++;
3611
3632
  continue;
3612
3633
  }
3613
3634
 
3614
3635
  try {
3615
- _t.transition();
3636
+ t.transition();
3616
3637
  } catch (e) {
3617
3638
  done++;
3618
3639
  }
@@ -3628,7 +3649,8 @@ function generateWait() {
3628
3649
  }
3629
3650
 
3630
3651
  loop();
3631
- };
3652
+ }; // 'f' is called as selection.call(f, ...);
3653
+
3632
3654
 
3633
3655
  f.add = function (t) {
3634
3656
  isArray(t) ? transitionsToWait = transitionsToWait.concat(t) : transitionsToWait.push(t);
@@ -9754,10 +9776,9 @@ var ChartInternal = /*#__PURE__*/function () {
9754
9776
 
9755
9777
  _proto.initParams = function initParams() {
9756
9778
  var $$ = this,
9757
- _ref = $$,
9758
- config = _ref.config,
9759
- format = _ref.format,
9760
- state = _ref.state,
9779
+ config = $$.config,
9780
+ format = $$.format,
9781
+ state = $$.state,
9761
9782
  isRotated = config.axis_rotated;
9762
9783
  // datetime to be used for uniqueness
9763
9784
  state.datetimeId = "bb-" + +new Date() * getRandom();
@@ -9861,12 +9882,16 @@ var ChartInternal = /*#__PURE__*/function () {
9861
9882
  $el.svg = $el.chart.append("svg").style("overflow", "hidden").style("display", "block");
9862
9883
 
9863
9884
  if (hasInteraction && state.inputType) {
9864
- var isTouch = state.inputType === "touch";
9865
- $el.svg.on(isTouch ? "touchstart" : "mouseenter", function () {
9866
- return callFn(config.onover, $$.api);
9867
- }).on(isTouch ? "touchend" : "mouseleave", function () {
9868
- return callFn(config.onout, $$.api);
9869
- });
9885
+ var _onclick,
9886
+ _onover,
9887
+ _onout,
9888
+ isTouch = state.inputType === "touch",
9889
+ _config = config,
9890
+ onclick = _config.onclick,
9891
+ onover = _config.onover,
9892
+ onout = _config.onout;
9893
+
9894
+ $el.svg.on("click", ((_onclick = onclick) == null ? void 0 : _onclick.bind($$.api)) || null).on(isTouch ? "touchstart" : "mouseenter", ((_onover = onover) == null ? void 0 : _onover.bind($$.api)) || null).on(isTouch ? "touchend" : "mouseleave", ((_onout = onout) == null ? void 0 : _onout.bind($$.api)) || null);
9870
9895
  }
9871
9896
 
9872
9897
  config.svg_classname && $el.svg.attr("class", config.svg_classname); // Define defs
@@ -11618,6 +11643,7 @@ extend(Chart.prototype, [chart, api_color, api_data, api_export, api_focus, api_
11618
11643
  * billboard.js project is licensed under the MIT license
11619
11644
  */
11620
11645
 
11646
+
11621
11647
  /**
11622
11648
  * Set the min/max value
11623
11649
  * @param {Chart} $$ Chart instance
@@ -11625,20 +11651,26 @@ extend(Chart.prototype, [chart, api_color, api_data, api_export, api_focus, api_
11625
11651
  * @param {object} value Value to be set
11626
11652
  * @private
11627
11653
  */
11628
-
11629
11654
  function setMinMax($$, type, value) {
11630
11655
  var config = $$.config,
11631
- axisY = "axis_y_" + type,
11632
- axisY2 = "axis_y2_" + type;
11656
+ helper = function (key, value) {
11657
+ var v = isNumber(value) ? value : value === !1 ? undefined : null;
11658
+
11659
+ if (v !== null) {
11660
+ config["axis_" + key + "_" + type] = v;
11661
+ }
11662
+ };
11633
11663
 
11634
11664
  if (isDefined(value)) {
11635
11665
  if (isObjectType(value)) {
11636
- isValue(value.x) && (config["axis_x_" + type] = value.x);
11637
- isValue(value.y) && (config[axisY] = value.y);
11638
- isValue(value.y2) && (config[axisY2] = value.y2);
11639
- } else {
11640
- config[axisY] = value;
11641
- config[axisY2] = value;
11666
+ Object.keys(value).forEach(function (key) {
11667
+ helper(key, value[key]);
11668
+ });
11669
+ } else if (isNumber(value) || value === !1) {
11670
+ // shorthand values affects only y and y2.
11671
+ ["y", "y2"].forEach(function (key) {
11672
+ helper(key, value);
11673
+ });
11642
11674
  }
11643
11675
 
11644
11676
  $$.redraw({
@@ -11724,8 +11756,9 @@ var axis = {
11724
11756
  * @instance
11725
11757
  * @memberof Chart
11726
11758
  * @param {object} min If min is given, specified axis' min value will be updated.<br>
11727
- * If no argument is given, the min values set on generating option for each axis will be returned.
11728
- * If not set any min values on generation, it will return `undefined`.
11759
+ * If no argument is given, the min values set on generating option for each axis will be returned.
11760
+ * If not set any min values on generation, it will return `undefined`.<br>
11761
+ * To unset specific axis max, set `false` to each of them.
11729
11762
  * @returns {object|undefined}
11730
11763
  * @example
11731
11764
  * // Update axis' min
@@ -11734,10 +11767,21 @@ var axis = {
11734
11767
  * y: 1000,
11735
11768
  * y2: 100
11736
11769
  * });
11770
+ *
11771
+ * // To unset specific axis min, set false to each of them.
11772
+ * chart.axis.min({
11773
+ * x: false,
11774
+ * y: false,
11775
+ * y2: false
11776
+ * });
11777
+ *
11778
+ * // shorthand (only affects y and y2 axis)
11779
+ * chart.axis.min(-50);
11780
+ * chart.axis.min(false);
11737
11781
  */
11738
11782
  min: function min(_min) {
11739
11783
  var $$ = this.internal;
11740
- return isValue(_min) ? setMinMax($$, "min", _min) : axis_getMinMax($$, "min");
11784
+ return isValue(_min) || _min === !1 ? setMinMax($$, "min", _min) : axis_getMinMax($$, "min");
11741
11785
  },
11742
11786
 
11743
11787
  /**
@@ -11746,8 +11790,9 @@ var axis = {
11746
11790
  * @instance
11747
11791
  * @memberof Chart
11748
11792
  * @param {object} max If max is given, specified axis' max value will be updated.<br>
11749
- * If no argument is given, the max values set on generating option for each axis will be returned.
11750
- * If not set any max values on generation, it will return `undefined`.
11793
+ * If no argument is given, the max values set on generating option for each axis will be returned.
11794
+ * If not set any max values on generation, it will return `undefined`.<br>
11795
+ * To unset specific axis max, set `false` to each of them.
11751
11796
  * @returns {object|undefined}
11752
11797
  * @example
11753
11798
  * // Update axis' label
@@ -11756,10 +11801,21 @@ var axis = {
11756
11801
  * y: 1000,
11757
11802
  * y2: 10000
11758
11803
  * });
11804
+ *
11805
+ * // To unset specific axis max, set false to each of them.
11806
+ * chart.axis.max({
11807
+ * x: false,
11808
+ * y: false,
11809
+ * y2: false
11810
+ * });
11811
+ *
11812
+ * // shorthand (only affects y and y2 axis)
11813
+ * chart.axis.max(10);
11814
+ * chart.axis.max(false);
11759
11815
  */
11760
11816
  max: function max(_max) {
11761
11817
  var $$ = this.internal;
11762
- return arguments.length ? setMinMax($$, "max", _max) : axis_getMinMax($$, "max");
11818
+ return isValue(_max) || _max === !1 ? setMinMax($$, "max", _max) : axis_getMinMax($$, "max");
11763
11819
  },
11764
11820
 
11765
11821
  /**
@@ -11767,7 +11823,9 @@ var axis = {
11767
11823
  * @function axis․range
11768
11824
  * @instance
11769
11825
  * @memberof Chart
11770
- * @param {object} range If range is given, specified axis' min and max value will be updated. If no argument is given, the current min and max values for each axis will be returned.
11826
+ * @param {object} range If range is given, specified axis' min and max value will be updated.
11827
+ * If no argument is given, the current min and max values for each axis will be returned.<br>
11828
+ * To unset specific axis max, set `false` to each of them.
11771
11829
  * @returns {object|undefined}
11772
11830
  * @example
11773
11831
  * // Update axis' label
@@ -11783,13 +11841,33 @@ var axis = {
11783
11841
  * y2: 10000
11784
11842
  * },
11785
11843
  * });
11844
+ *
11845
+ * // To unset specific axis max, set false to each of them.
11846
+ * chart.axis.range({
11847
+ * min: {
11848
+ * x: false,
11849
+ * y: false,
11850
+ * y2: false
11851
+ * },
11852
+ * max: {
11853
+ * x: false,
11854
+ * y: false,
11855
+ * y2: false
11856
+ * },
11857
+ * });
11858
+ *
11859
+ * // shorthand (only affects y and y2 axis)
11860
+ * chart.axis.range({ min: -50, max: 1000 });
11861
+ * chart.axis.range({ min: false, max: false });
11786
11862
  */
11787
11863
  range: function range(_range) {
11788
11864
  var axis = this.axis;
11789
11865
 
11790
11866
  if (arguments.length) {
11791
- isDefined(_range.max) && axis.max(_range.max);
11792
- isDefined(_range.min) && axis.min(_range.min);
11867
+ var min = _range.min,
11868
+ max = _range.max;
11869
+ isDefined(max) && axis.max(max);
11870
+ isDefined(min) && axis.min(min);
11793
11871
  } else {
11794
11872
  return {
11795
11873
  max: axis.max(),
@@ -14764,7 +14842,9 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
14764
14842
  } else if (orgDataCount === 1 || ((_flowStart = flowStart) == null ? void 0 : _flowStart.x) === ((_flowEnd = flowEnd) == null ? void 0 : _flowEnd.x)) {
14765
14843
  translateX = x(orgDomain[0]) - x(domain[0]);
14766
14844
  } else {
14767
- translateX = $$.axis.isTimeSeries() ? x(orgDomain[0]) - x(domain[0]) : x(flowStart.x) - x(flowEnd.x);
14845
+ var _flowStart2;
14846
+
14847
+ translateX = $$.axis.isTimeSeries() ? x(orgDomain[0]) - x(domain[0]) : x(((_flowStart2 = flowStart) == null ? void 0 : _flowStart2.x) || 0) - x(flowEnd.x);
14768
14848
  }
14769
14849
 
14770
14850
  var scaleX = diffDomain(orgDomain) / diffDomain(domain);
@@ -23328,7 +23408,7 @@ var _defaults = {},
23328
23408
  * bb.version; // "1.0.0"
23329
23409
  * @memberof bb
23330
23410
  */
23331
- version: "3.4.0-next.1",
23411
+ version: "3.4.0-next.2",
23332
23412
 
23333
23413
  /**
23334
23414
  * Generate chart
@@ -23463,7 +23543,7 @@ var _defaults = {},
23463
23543
  };
23464
23544
  /**
23465
23545
  * @namespace bb
23466
- * @version 3.4.0-next.1
23546
+ * @version 3.4.0-next.2
23467
23547
  */
23468
23548
  ;// CONCATENATED MODULE: ./src/index.ts
23469
23549
  /**
@@ -5,5 +5,5 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.4.0-next.1
8
+ * @version 3.4.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-bars path,.bb-event-rect,.bb-legend-item-tile,.bb-xgrid-focus,.bb-ygrid,.bb-ygrid-focus{shape-rendering:crispEdges}.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-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-tooltip-container{user-select:none;z-index:10}.bb-tooltip{background-color:#fff;border-collapse:collapse;border-spacing:0;-webkit-box-shadow:7px 7px 12px -9px #777;-moz-box-shadow:7px 7px 12px -9px #777;box-shadow:7px 7px 12px -9px #777;empty-cells:show;opacity:.9}.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}