billboard.js 3.9.0-next.1 → 3.9.0

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 (48) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +121 -30
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +121 -30
  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 +149 -57
  31. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +3 -3
  32. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +3 -3
  33. package/dist-esm/plugin/billboardjs-plugin-stanford.js +3 -3
  34. package/dist-esm/plugin/billboardjs-plugin-tableview.js +3 -3
  35. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +3 -3
  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/internals/legend.ts +50 -34
  41. package/src/ChartInternal/shape/bar.ts +7 -3
  42. package/src/ChartInternal/shape/bubble.ts +0 -1
  43. package/src/ChartInternal/shape/point.ts +2 -0
  44. package/src/config/Options/common/legend.ts +37 -6
  45. package/src/config/Options/common/point.ts +30 -2
  46. package/src/config/Options/shape/bar.ts +7 -1
  47. package/types/options.d.ts +32 -2
  48. 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
9
9
  *
10
10
  * All-in-one packaged file for ease use of 'billboard.js' with dependant d3.js modules & polyfills.
11
11
  * - @types/d3-selection ^3.0.5
@@ -25425,17 +25425,34 @@ var data_this = undefined;
25425
25425
  * - defines the max step the legend has (e.g. If 2 set and legend has 3 legend item, the legend 2 columns).
25426
25426
  * @property {boolean} [legend.equally=false] Set to all items have same width size.
25427
25427
  * @property {number} [legend.padding=0] Set padding value
25428
+ * @property {boolean} [legend.item.interaction=true] Set legend item interaction.
25429
+ * - **NOTE:**
25430
+ * - This setting will not have effect on `.toggle()` method.
25431
+ * - `legend.item.onXXX` listener options will work if set, regardless of this option value.
25432
+ * @property {boolean} [legend.item.interaction.dblclick=false] Set legend item to interact on double click.
25433
+ * - **NOTE:**
25434
+ * - Double clicking will make focused clicked dataseries only, hiding all others.
25435
+ * - for single click case, `click + altKey(Win)/optionKey(Mac OS)` to have same effect.
25436
+ * - To return initial state(which all dataseries are showing), double click current focused legend item again.
25437
+ * - for single click case, `click + altKey(Win)/optionKey(Mac OS)` to have same effect.
25438
+ * - In this case, default `click` interaction will be disabled.
25428
25439
  * @property {Function} [legend.item.onclick=undefined] Set click event handler to the legend item.
25440
+ * - **NOTE:**
25441
+ * - When set, default `click` interaction will be disabled.
25442
+ * - When `interaction.dblclick=true` is set, will be called on double click.
25429
25443
  * @property {Function} [legend.item.onover=undefined] Set mouse/touch over event handler to the legend item.
25444
+ * - **NOTE:** When set, default `mouseover` interaction will be disabled.
25430
25445
  * @property {Function} [legend.item.onout=undefined] Set mouse/touch out event handler to the legend item.
25446
+ * - **NOTE:** When set, default `mouseout` interaction will be disabled.
25431
25447
  * @property {number} [legend.item.tile.width=10] Set width for 'rectangle' legend item tile element.
25432
- * @property {number} [legend.item.tile.height=10] ㄹ
25448
+ * @property {number} [legend.item.tile.height=10] Set height for 'rectangle' legend item tile element.
25433
25449
  * @property {number} [legend.item.tile.r=5] Set the radius for 'circle' legend item tile type.
25434
25450
  * @property {string} [legend.item.tile.type="rectangle"] Set legend item shape type.<br>
25435
25451
  * - **Available Values:**
25436
25452
  * - circle
25437
25453
  * - rectangle
25438
25454
  * @property {boolean} [legend.usePoint=false] Whether to use custom points in legend.
25455
+ * @see [Demo: item.interaction](https://naver.github.io/billboard.js/demo/#Legend.LegendItemInteraction)
25439
25456
  * @see [Demo: item.tile.type](https://naver.github.io/billboard.js/demo/#Legend.LegendItemTileType)
25440
25457
  * @see [Demo: position](https://naver.github.io/billboard.js/demo/#Legend.LegendPosition)
25441
25458
  * @see [Demo: contents.template](https://naver.github.io/billboard.js/demo/#Legend.LegendTemplate1)
@@ -25470,6 +25487,16 @@ var data_this = undefined;
25470
25487
  * equally: false,
25471
25488
  * padding: 10,
25472
25489
  * item: {
25490
+ * // will disable default interaction
25491
+ * interaction: false,
25492
+ *
25493
+ * // set legend interact on double click
25494
+ * // by double clicking, will make focused clicked dataseries only, hiding all others.
25495
+ * interaction: {
25496
+ * dblclick: true
25497
+ * }
25498
+ *
25499
+ * // when set below callback, will disable corresponding default interactions
25473
25500
  * onclick: function(id) { ... },
25474
25501
  * onover: function(id) { ... },
25475
25502
  * onout: function(id) { ... },
@@ -25490,24 +25517,26 @@ var data_this = undefined;
25490
25517
  * usePoint: true
25491
25518
  * }
25492
25519
  */
25493
- legend_show: !0,
25494
- legend_hide: !1,
25495
25520
  legend_contents_bindto: undefined,
25496
25521
  legend_contents_template: "<span style='color:#fff;padding:5px;background-color:{=COLOR}'>{=TITLE}</span>",
25497
- legend_position: "bottom",
25522
+ legend_equally: !1,
25523
+ legend_hide: !1,
25498
25524
  legend_inset_anchor: "top-left",
25499
25525
  legend_inset_x: 10,
25500
25526
  legend_inset_y: 0,
25501
25527
  legend_inset_step: undefined,
25528
+ legend_item_interaction: !0,
25529
+ legend_item_dblclick: !1,
25502
25530
  legend_item_onclick: undefined,
25503
25531
  legend_item_onover: undefined,
25504
25532
  legend_item_onout: undefined,
25505
- legend_equally: !1,
25506
- legend_padding: 0,
25507
25533
  legend_item_tile_width: 10,
25508
25534
  legend_item_tile_height: 10,
25509
25535
  legend_item_tile_r: 5,
25510
25536
  legend_item_tile_type: "rectangle",
25537
+ legend_padding: 0,
25538
+ legend_position: "bottom",
25539
+ legend_show: !0,
25511
25540
  legend_usePoint: !1
25512
25541
  });
25513
25542
  ;// CONCATENATED MODULE: ./src/config/Options/common/title.ts
@@ -27484,7 +27513,17 @@ function getDataKeyForJson(keysParam, config) {
27484
27513
  _newArrowCheck(this, _this36);
27485
27514
  return v && isValue(v.value);
27486
27515
  }.bind(this)),
27487
- minDist = config.point_sensitivity,
27516
+ getSensitivity = function (d) {
27517
+ _newArrowCheck(this, _this36);
27518
+ var sensitivity = config.point_sensitivity;
27519
+ if (isFunction(sensitivity)) {
27520
+ sensitivity = sensitivity.call($$.api, d);
27521
+ } else if (sensitivity === "radius") {
27522
+ sensitivity = d.r;
27523
+ }
27524
+ return sensitivity;
27525
+ }.bind(this),
27526
+ minDist,
27488
27527
  closest;
27489
27528
  // find mouseovering bar/candlestick
27490
27529
  // https://github.com/naver/billboard.js/issues/2434
@@ -27506,6 +27545,7 @@ function getDataKeyForJson(keysParam, config) {
27506
27545
  }.bind(this)).forEach(function (v) {
27507
27546
  _newArrowCheck(this, _this36);
27508
27547
  var d = $$.dist(v, pos);
27548
+ minDist = getSensitivity(v);
27509
27549
  if (d < minDist) {
27510
27550
  minDist = d;
27511
27551
  closest = v;
@@ -27517,11 +27557,13 @@ function getDataKeyForJson(keysParam, config) {
27517
27557
  var $$ = this,
27518
27558
  isRotated = $$.config.axis_rotated,
27519
27559
  scale = $$.scale,
27520
- xIndex = isRotated ? 1 : 0,
27521
- yIndex = isRotated ? 0 : 1,
27522
27560
  y = $$.circleY(data, data.index),
27523
27561
  x = (scale.zoom || scale.x)(data.x);
27524
- return Math.sqrt(Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2));
27562
+
27563
+ // true: 1, false: 0
27564
+ // true: 0, false: 1
27565
+
27566
+ return Math.sqrt(Math.pow(x - pos[+isRotated], 2) + Math.pow(y - pos[+!isRotated], 2));
27525
27567
  },
27526
27568
  /**
27527
27569
  * Convert data for step type
@@ -29946,7 +29988,8 @@ function getLegendColor(id) {
29946
29988
  state = $$.state,
29947
29989
  isTouch = state.inputType === "touch",
29948
29990
  hasGauge = $$.hasType("gauge"),
29949
- useCssRule = config.boost_useCssRule;
29991
+ useCssRule = config.boost_useCssRule,
29992
+ interaction = config.legend_item_interaction;
29950
29993
  item.attr("class", function (id) {
29951
29994
  var node = src_select(this),
29952
29995
  itemClass = !node.empty() && node.attr("class") || "";
@@ -29964,19 +30007,27 @@ function getLegendColor(id) {
29964
30007
  $$.setCssRule(!1, selector, [props])($el.legend);
29965
30008
  }.bind(this));
29966
30009
  }
29967
- item.style("cursor", $$.getStylePropValue("pointer")).on("click", function (event, id) {
30010
+ item.on(interaction.dblclick ? "dblclick" : "click", interaction || isFunction(config.legend_item_onclick) ? function (event, id) {
29968
30011
  if (!callFn(config.legend_item_onclick, api, id)) {
29969
- if (event.altKey) {
29970
- api.hide();
29971
- api.show(id);
30012
+ var altKey = event.altKey,
30013
+ target = event.target,
30014
+ type = event.type;
30015
+ if (type === "dblclick" || altKey) {
30016
+ // when focused legend is clicked(with altKey or double clicked), reset all hiding.
30017
+ if (state.hiddenTargetIds.length && target.parentNode.getAttribute("class").indexOf($LEGEND.legendItemHidden) === -1) {
30018
+ api.show();
30019
+ } else {
30020
+ api.hide();
30021
+ api.show(id);
30022
+ }
29972
30023
  } else {
29973
30024
  api.toggle(id);
29974
30025
  src_select(this).classed($FOCUS.legendItemFocused, !1);
29975
30026
  }
29976
30027
  }
29977
30028
  isTouch && $$.hideTooltip();
29978
- });
29979
- isTouch || item.on("mouseout", function (event, id) {
30029
+ } : null);
30030
+ isTouch || item.on("mouseout", interaction || isFunction(config.legend_item_onout) ? function (event, id) {
29980
30031
  if (!callFn(config.legend_item_onout, api, id)) {
29981
30032
  src_select(this).classed($FOCUS.legendItemFocused, !1);
29982
30033
  if (hasGauge) {
@@ -29984,7 +30035,7 @@ function getLegendColor(id) {
29984
30035
  }
29985
30036
  $$.api.revert();
29986
30037
  }
29987
- }).on("mouseover", function (event, id) {
30038
+ } : null).on("mouseover", interaction || isFunction(config.legend_item_onover) ? function (event, id) {
29988
30039
  if (!callFn(config.legend_item_onover, api, id)) {
29989
30040
  src_select(this).classed($FOCUS.legendItemFocused, !0);
29990
30041
  if (hasGauge) {
@@ -29994,7 +30045,10 @@ function getLegendColor(id) {
29994
30045
  api.focus(id);
29995
30046
  }
29996
30047
  }
29997
- });
30048
+ } : null);
30049
+
30050
+ // set cursor when has some interaction
30051
+ !item.empty() && item.on("click mouseout mouseover") && item.style("cursor", $$.getStylePropValue("pointer"));
29998
30052
  }
29999
30053
  },
30000
30054
  /**
@@ -35763,6 +35817,7 @@ var ChartInternal = /*#__PURE__*/function () {
35763
35817
  // Define g for chart area
35764
35818
  main.append("g").classed($COMMON.chart, !0).attr("clip-path", hasAxis ? state.clip.path : null);
35765
35819
  $$.callPluginHook("$init");
35820
+ $$.initChartElements();
35766
35821
  if (hasAxis) {
35767
35822
  var _$$$axis;
35768
35823
  // Cover whole with rects for events
@@ -35774,7 +35829,6 @@ var ChartInternal = /*#__PURE__*/function () {
35774
35829
  // Add Axis here, when clipPath is 'true'
35775
35830
  config.clipPath && ((_$$$axis = $$.axis) == null ? void 0 : _$$$axis.init());
35776
35831
  }
35777
- $$.initChartElements();
35778
35832
 
35779
35833
  // Set targets
35780
35834
  $$.updateTargets($$.data.targets);
@@ -35819,7 +35873,11 @@ var ChartInternal = /*#__PURE__*/function () {
35819
35873
  hasTreemap = _$$$state.hasTreemap,
35820
35874
  types = [];
35821
35875
  if (hasAxis) {
35822
- ["bar", "bubble", "candlestick", "line"].forEach(function (v) {
35876
+ var shapes = ["bar", "bubble", "candlestick", "line"];
35877
+ if ($$.config.bar_front) {
35878
+ shapes.push(shapes.shift());
35879
+ }
35880
+ shapes.forEach(function (v) {
35823
35881
  _newArrowCheck(this, _this5);
35824
35882
  var name = capitalize(v);
35825
35883
  if (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) {
@@ -45478,9 +45536,9 @@ function point_y(p) {
45478
45536
  var $el = this.$el,
45479
45537
  config = this.config,
45480
45538
  clip = this.state.clip;
45481
- $el.bar = $el.main.select("." + $COMMON.chart)
45482
- // should positioned at the beginning of the shape node to not overlap others
45483
- .insert("g", ":first-child").attr("class", $BAR.chartBars).call(this.setCssRule(!1, "." + $BAR.chartBars, ["pointer-events:none"]));
45539
+ $el.bar = $el.main.select("." + $COMMON.chart);
45540
+ $el.bar = config.bar_front ? $el.bar.append("g") : $el.bar.insert("g", ":first-child");
45541
+ $el.bar.attr("class", $BAR.chartBars).call(this.setCssRule(!1, "." + $BAR.chartBars, ["pointer-events:none"]));
45484
45542
 
45485
45543
  // set clip-path attribute when condition meet
45486
45544
  // https://github.com/naver/billboard.js/issues/2421
@@ -46079,7 +46137,6 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
46079
46137
  if ($$.hasType("bubble")) {
46080
46138
  config.point_show = !0;
46081
46139
  config.point_type = "circle";
46082
- config.point_sensitivity = 25;
46083
46140
  }
46084
46141
  },
46085
46142
  /**
@@ -46704,6 +46761,7 @@ var getTransitionName = function () {
46704
46761
  } else if (isFunction(pointR)) {
46705
46762
  r = pointR.bind($$.api)(d);
46706
46763
  }
46764
+ d.r = r;
46707
46765
  return r;
46708
46766
  },
46709
46767
  pointExpandedR: function pointExpandedR(d) {
@@ -48239,6 +48297,7 @@ function convertDataToTreemapData(data) {
48239
48297
  * Copyright (c) 2017 ~ present NAVER Corp.
48240
48298
  * billboard.js project is licensed under the MIT license
48241
48299
  */
48300
+
48242
48301
  /**
48243
48302
  * point config options
48244
48303
  */
@@ -48260,7 +48319,20 @@ function convertDataToTreemapData(data) {
48260
48319
  * - **NOTE:**
48261
48320
  * - `null` will make to not set inline 'opacity' css prop.
48262
48321
  * - when no value(or undefined) is set, it defaults to set opacity value according its chart types.
48263
- * @property {number} [point.sensitivity=10] The senstivity value for interaction boundary.
48322
+ * @property {number|string|Function} [point.sensitivity=10] The senstivity value for interaction boundary.
48323
+ * - **Available Values:**
48324
+ * - {number}: Absolute sensitivity value which is the distance from the data point in pixel.
48325
+ * - "radius": sensitivity based on point's radius
48326
+ * - Function: callback for each point to determine the sensitivity<br>
48327
+ * ```js
48328
+ * sensitivity: function(d) {
48329
+ * // ex. of argument d:
48330
+ * // ==> {x: 2, value: 55, id: 'data3', index: 2, r: 19.820624179302296}
48331
+ *
48332
+ * // returning d.r, will make sensitivity same as point's radius value.
48333
+ * return d.r;
48334
+ * }
48335
+ * ```
48264
48336
  * @property {number} [point.select.r=point.r*4] The radius size of each point on selected.
48265
48337
  * @property {string} [point.type="circle"] The type of point to be drawn
48266
48338
  * - **NOTE:**
@@ -48281,6 +48353,7 @@ function convertDataToTreemapData(data) {
48281
48353
  * (ex. `<polygon points='2.5 0 0 5 5 5'></polygon>`)
48282
48354
  * @see [Demo: point type](https://naver.github.io/billboard.js/demo/#Point.RectanglePoints)
48283
48355
  * @see [Demo: point focus only](https://naver.github.io/billboard.js/demo/#Point.FocusOnly)
48356
+ * @see [Demo: point sensitivity](https://naver.github.io/billboard.js/demo/#Point.PointSensitivity)
48284
48357
  * @example
48285
48358
  * point: {
48286
48359
  * show: false,
@@ -48313,6 +48386,18 @@ function convertDataToTreemapData(data) {
48313
48386
  * // having lower value, means how closer to be for interaction
48314
48387
  * sensitivity: 3,
48315
48388
  *
48389
+ * // sensitivity based on point's radius
48390
+ * sensitivity: "radius",
48391
+ *
48392
+ * // callback for each point to determine the sensitivity
48393
+ * sensitivity: function(d) {
48394
+ * // ex. of argument d:
48395
+ * // ==> {x: 2, value: 55, id: 'data3', index: 2, r: 19.820624179302296}
48396
+ *
48397
+ * // returning d.r, will make sensitivity same as point's radius value.
48398
+ * return d.r;
48399
+ * }
48400
+ *
48316
48401
  * // valid values are "circle" or "rectangle"
48317
48402
  * type: "rectangle",
48318
48403
  *
@@ -48420,6 +48505,7 @@ function convertDataToTreemapData(data) {
48420
48505
  * @memberof Options
48421
48506
  * @type {object}
48422
48507
  * @property {object} bar Bar object
48508
+ * @property {boolean} [bar.front=false] Set 'bar' to be positioned over(on the top) other shapes elements.
48423
48509
  * @property {number} [bar.indices.removeNull=false] Remove nullish data on bar indices positions.
48424
48510
  * @property {number} [bar.label.threshold=0] Set threshold ratio to show/hide labels.
48425
48511
  * @property {boolean|object} [bar.linearGradient=false] Set the linear gradient on bar.<br><br>
@@ -48442,6 +48528,7 @@ function convertDataToTreemapData(data) {
48442
48528
  * @property {number} [bar.width.dataname.ratio=0.6] Change the width of bar chart by ratio.
48443
48529
  * @property {number} [bar.width.dataname.max] The maximum width value for ratio.
48444
48530
  * @property {boolean} [bar.zerobased=true] Set if min or max value will be 0 on bar chart.
48531
+ * @see [Demo: bar front](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarFront)
48445
48532
  * @see [Demo: bar indices](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarIndices)
48446
48533
  * @see [Demo: bar overlap](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarOverlap)
48447
48534
  * @see [Demo: bar padding](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarPadding)
@@ -48450,6 +48537,9 @@ function convertDataToTreemapData(data) {
48450
48537
  * @see [Demo: bar width variant](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarWidthVariant)
48451
48538
  * @example
48452
48539
  * bar: {
48540
+ * // make bar shape to be positioned over the other shape elements
48541
+ * front: true,
48542
+ *
48453
48543
  * // remove nullish data on bar indices postions
48454
48544
  * indices: {
48455
48545
  * removeNull: true
@@ -48520,9 +48610,10 @@ function convertDataToTreemapData(data) {
48520
48610
  * zerobased: false
48521
48611
  * }
48522
48612
  */
48613
+ bar_front: !1,
48614
+ bar_indices_removeNull: !1,
48523
48615
  bar_label_threshold: 0,
48524
48616
  bar_linearGradient: !1,
48525
- bar_indices_removeNull: !1,
48526
48617
  bar_overlap: !1,
48527
48618
  bar_padding: 0,
48528
48619
  bar_radius: undefined,
@@ -52028,7 +52119,7 @@ var _defaults = {};
52028
52119
 
52029
52120
  /**
52030
52121
  * @namespace bb
52031
- * @version 3.9.0-next.1
52122
+ * @version 3.9.0
52032
52123
  */
52033
52124
  var bb = {
52034
52125
  /**
@@ -52038,7 +52129,7 @@ var bb = {
52038
52129
  * bb.version; // "1.0.0"
52039
52130
  * @memberof bb
52040
52131
  */
52041
- version: "3.9.0-next.1",
52132
+ version: "3.9.0",
52042
52133
  /**
52043
52134
  * Generate chart
52044
52135
  * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when: