billboard.js 3.9.0-next.2 → 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 (39) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +59 -18
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +59 -18
  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 +89 -42
  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 +1 -1
  37. package/src/ChartInternal/internals/legend.ts +50 -34
  38. package/src/config/Options/common/legend.ts +37 -6
  39. package/types/options.d.ts +25 -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.9.0-next.2
8
+ * @version 3.9.0
9
9
  */
10
10
  import { timeParse, utcParse, timeFormat, utcFormat } from 'd3-time-format';
11
11
  import { pointer, select, namespaces, selectAll } from 'd3-selection';
@@ -156,7 +156,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
156
156
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
157
157
  PERFORMANCE OF THIS SOFTWARE.
158
158
  ***************************************************************************** */
159
- /* global Reflect, Promise */
159
+ /* global Reflect, Promise, SuppressedError, Symbol */
160
160
 
161
161
  var _assign = function __assign() {
162
162
  _assign = Object.assign || function (t) {
@@ -177,6 +177,10 @@ function __spreadArray(to, from, pack) {
177
177
  }
178
178
  return to.concat(ar || Array.prototype.slice.call(from));
179
179
  }
180
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
181
+ var e = new Error(message);
182
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
183
+ };
180
184
 
181
185
  var isValue = function (v) { return v || v === 0; };
182
186
  var isFunction = function (v) { return typeof v === "function"; };
@@ -2723,17 +2727,34 @@ var legend$2 = {
2723
2727
  * - defines the max step the legend has (e.g. If 2 set and legend has 3 legend item, the legend 2 columns).
2724
2728
  * @property {boolean} [legend.equally=false] Set to all items have same width size.
2725
2729
  * @property {number} [legend.padding=0] Set padding value
2730
+ * @property {boolean} [legend.item.interaction=true] Set legend item interaction.
2731
+ * - **NOTE:**
2732
+ * - This setting will not have effect on `.toggle()` method.
2733
+ * - `legend.item.onXXX` listener options will work if set, regardless of this option value.
2734
+ * @property {boolean} [legend.item.interaction.dblclick=false] Set legend item to interact on double click.
2735
+ * - **NOTE:**
2736
+ * - Double clicking will make focused clicked dataseries only, hiding all others.
2737
+ * - for single click case, `click + altKey(Win)/optionKey(Mac OS)` to have same effect.
2738
+ * - To return initial state(which all dataseries are showing), double click current focused legend item again.
2739
+ * - for single click case, `click + altKey(Win)/optionKey(Mac OS)` to have same effect.
2740
+ * - In this case, default `click` interaction will be disabled.
2726
2741
  * @property {Function} [legend.item.onclick=undefined] Set click event handler to the legend item.
2742
+ * - **NOTE:**
2743
+ * - When set, default `click` interaction will be disabled.
2744
+ * - When `interaction.dblclick=true` is set, will be called on double click.
2727
2745
  * @property {Function} [legend.item.onover=undefined] Set mouse/touch over event handler to the legend item.
2746
+ * - **NOTE:** When set, default `mouseover` interaction will be disabled.
2728
2747
  * @property {Function} [legend.item.onout=undefined] Set mouse/touch out event handler to the legend item.
2748
+ * - **NOTE:** When set, default `mouseout` interaction will be disabled.
2729
2749
  * @property {number} [legend.item.tile.width=10] Set width for 'rectangle' legend item tile element.
2730
- * @property {number} [legend.item.tile.height=10] ㄹ
2750
+ * @property {number} [legend.item.tile.height=10] Set height for 'rectangle' legend item tile element.
2731
2751
  * @property {number} [legend.item.tile.r=5] Set the radius for 'circle' legend item tile type.
2732
2752
  * @property {string} [legend.item.tile.type="rectangle"] Set legend item shape type.<br>
2733
2753
  * - **Available Values:**
2734
2754
  * - circle
2735
2755
  * - rectangle
2736
2756
  * @property {boolean} [legend.usePoint=false] Whether to use custom points in legend.
2757
+ * @see [Demo: item.interaction](https://naver.github.io/billboard.js/demo/#Legend.LegendItemInteraction)
2737
2758
  * @see [Demo: item.tile.type](https://naver.github.io/billboard.js/demo/#Legend.LegendItemTileType)
2738
2759
  * @see [Demo: position](https://naver.github.io/billboard.js/demo/#Legend.LegendPosition)
2739
2760
  * @see [Demo: contents.template](https://naver.github.io/billboard.js/demo/#Legend.LegendTemplate1)
@@ -2768,6 +2789,16 @@ var legend$2 = {
2768
2789
  * equally: false,
2769
2790
  * padding: 10,
2770
2791
  * item: {
2792
+ * // will disable default interaction
2793
+ * interaction: false,
2794
+ *
2795
+ * // set legend interact on double click
2796
+ * // by double clicking, will make focused clicked dataseries only, hiding all others.
2797
+ * interaction: {
2798
+ * dblclick: true
2799
+ * }
2800
+ *
2801
+ * // when set below callback, will disable corresponding default interactions
2771
2802
  * onclick: function(id) { ... },
2772
2803
  * onover: function(id) { ... },
2773
2804
  * onout: function(id) { ... },
@@ -2788,24 +2819,26 @@ var legend$2 = {
2788
2819
  * usePoint: true
2789
2820
  * }
2790
2821
  */
2791
- legend_show: true,
2792
- legend_hide: false,
2793
2822
  legend_contents_bindto: undefined,
2794
2823
  legend_contents_template: "<span style='color:#fff;padding:5px;background-color:{=COLOR}'>{=TITLE}</span>",
2795
- legend_position: "bottom",
2824
+ legend_equally: false,
2825
+ legend_hide: false,
2796
2826
  legend_inset_anchor: "top-left",
2797
2827
  legend_inset_x: 10,
2798
2828
  legend_inset_y: 0,
2799
2829
  legend_inset_step: undefined,
2830
+ legend_item_interaction: true,
2831
+ legend_item_dblclick: false,
2800
2832
  legend_item_onclick: undefined,
2801
2833
  legend_item_onover: undefined,
2802
2834
  legend_item_onout: undefined,
2803
- legend_equally: false,
2804
- legend_padding: 0,
2805
2835
  legend_item_tile_width: 10,
2806
2836
  legend_item_tile_height: 10,
2807
2837
  legend_item_tile_r: 5,
2808
2838
  legend_item_tile_type: "rectangle",
2839
+ legend_padding: 0,
2840
+ legend_position: "bottom",
2841
+ legend_show: true,
2809
2842
  legend_usePoint: false
2810
2843
  };
2811
2844
 
@@ -6007,6 +6040,7 @@ var legend$1 = {
6007
6040
  var isTouch = state.inputType === "touch";
6008
6041
  var hasGauge = $$.hasType("gauge");
6009
6042
  var useCssRule = config.boost_useCssRule;
6043
+ var interaction = config.legend_item_interaction;
6010
6044
  item
6011
6045
  .attr("class", function (id) {
6012
6046
  var node = select(this);
@@ -6028,42 +6062,55 @@ var legend$1 = {
6028
6062
  });
6029
6063
  }
6030
6064
  item
6031
- .style("cursor", $$.getStylePropValue("pointer"))
6032
- .on("click", function (event, id) {
6033
- if (!callFn(config.legend_item_onclick, api, id)) {
6034
- if (event.altKey) {
6035
- api.hide();
6036
- api.show(id);
6037
- }
6038
- else {
6039
- api.toggle(id);
6040
- select(this)
6041
- .classed($FOCUS.legendItemFocused, false);
6065
+ .on(interaction.dblclick ? "dblclick" : "click", interaction || isFunction(config.legend_item_onclick) ?
6066
+ function (event, id) {
6067
+ if (!callFn(config.legend_item_onclick, api, id)) {
6068
+ var altKey = event.altKey, target = event.target, type = event.type;
6069
+ if (type === "dblclick" || altKey) {
6070
+ // when focused legend is clicked(with altKey or double clicked), reset all hiding.
6071
+ if (state.hiddenTargetIds.length &&
6072
+ target.parentNode.getAttribute("class").indexOf($LEGEND.legendItemHidden) === -1) {
6073
+ api.show();
6074
+ }
6075
+ else {
6076
+ api.hide();
6077
+ api.show(id);
6078
+ }
6079
+ }
6080
+ else {
6081
+ api.toggle(id);
6082
+ select(this)
6083
+ .classed($FOCUS.legendItemFocused, false);
6084
+ }
6042
6085
  }
6043
- }
6044
- isTouch && $$.hideTooltip();
6045
- });
6086
+ isTouch && $$.hideTooltip();
6087
+ } : null);
6046
6088
  !isTouch && item
6047
- .on("mouseout", function (event, id) {
6048
- if (!callFn(config.legend_item_onout, api, id)) {
6049
- select(this).classed($FOCUS.legendItemFocused, false);
6050
- if (hasGauge) {
6051
- $$.undoMarkOverlapped($$, ".".concat($GAUGE.gaugeValue));
6052
- }
6053
- $$.api.revert();
6054
- }
6055
- })
6056
- .on("mouseover", function (event, id) {
6057
- if (!callFn(config.legend_item_onover, api, id)) {
6058
- select(this).classed($FOCUS.legendItemFocused, true);
6059
- if (hasGauge) {
6060
- $$.markOverlapped(id, $$, ".".concat($GAUGE.gaugeValue));
6089
+ .on("mouseout", interaction || isFunction(config.legend_item_onout) ?
6090
+ function (event, id) {
6091
+ if (!callFn(config.legend_item_onout, api, id)) {
6092
+ select(this).classed($FOCUS.legendItemFocused, false);
6093
+ if (hasGauge) {
6094
+ $$.undoMarkOverlapped($$, ".".concat($GAUGE.gaugeValue));
6095
+ }
6096
+ $$.api.revert();
6061
6097
  }
6062
- if (!state.transiting && $$.isTargetToShow(id)) {
6063
- api.focus(id);
6098
+ } : null)
6099
+ .on("mouseover", interaction || isFunction(config.legend_item_onover) ?
6100
+ function (event, id) {
6101
+ if (!callFn(config.legend_item_onover, api, id)) {
6102
+ select(this).classed($FOCUS.legendItemFocused, true);
6103
+ if (hasGauge) {
6104
+ $$.markOverlapped(id, $$, ".".concat($GAUGE.gaugeValue));
6105
+ }
6106
+ if (!state.transiting && $$.isTargetToShow(id)) {
6107
+ api.focus(id);
6108
+ }
6064
6109
  }
6065
- }
6066
- });
6110
+ } : null);
6111
+ // set cursor when has some interaction
6112
+ !item.empty() && item.on("click mouseout mouseover") &&
6113
+ item.style("cursor", $$.getStylePropValue("pointer"));
6067
6114
  }
6068
6115
  },
6069
6116
  /**
@@ -22588,7 +22635,7 @@ var zoomModule = function () {
22588
22635
  var defaults = {};
22589
22636
  /**
22590
22637
  * @namespace bb
22591
- * @version 3.9.0-next.2
22638
+ * @version 3.9.0
22592
22639
  */
22593
22640
  var bb = {
22594
22641
  /**
@@ -22598,7 +22645,7 @@ var bb = {
22598
22645
  * bb.version; // "1.0.0"
22599
22646
  * @memberof bb
22600
22647
  */
22601
- version: "3.9.0-next.2",
22648
+ version: "3.9.0",
22602
22649
  /**
22603
22650
  * Generate chart
22604
22651
  * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
@@ -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.2
8
+ * @version 3.9.0
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -25,7 +25,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25
25
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26
26
  PERFORMANCE OF THIS SOFTWARE.
27
27
  ***************************************************************************** */
28
- /* global Reflect, Promise */
28
+ /* global Reflect, Promise, SuppressedError, Symbol */
29
29
 
30
30
  var _extendStatics = function extendStatics(d, b) {
31
31
  _extendStatics = Object.setPrototypeOf || {
@@ -104,7 +104,7 @@ var Plugin = /** @class */ (function () {
104
104
  delete _this[key];
105
105
  });
106
106
  };
107
- Plugin.version = "3.9.0-next.2";
107
+ Plugin.version = "3.9.0";
108
108
  return Plugin;
109
109
  }());
110
110
  var Plugin$1 = Plugin;
@@ -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.2
8
+ * @version 3.9.0
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -23,7 +23,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
23
23
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24
24
  PERFORMANCE OF THIS SOFTWARE.
25
25
  ***************************************************************************** */
26
- /* global Reflect, Promise */
26
+ /* global Reflect, Promise, SuppressedError, Symbol */
27
27
 
28
28
  var _extendStatics = function extendStatics(d, b) {
29
29
  _extendStatics = Object.setPrototypeOf || {
@@ -279,7 +279,7 @@ var Plugin = /** @class */ (function () {
279
279
  delete _this[key];
280
280
  });
281
281
  };
282
- Plugin.version = "3.9.0-next.2";
282
+ Plugin.version = "3.9.0";
283
283
  return Plugin;
284
284
  }());
285
285
  var Plugin$1 = Plugin;
@@ -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.2
8
+ * @version 3.9.0
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -29,7 +29,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
29
29
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
30
30
  PERFORMANCE OF THIS SOFTWARE.
31
31
  ***************************************************************************** */
32
- /* global Reflect, Promise */
32
+ /* global Reflect, Promise, SuppressedError, Symbol */
33
33
 
34
34
  var _extendStatics = function extendStatics(d, b) {
35
35
  _extendStatics = Object.setPrototypeOf || {
@@ -487,7 +487,7 @@ var Plugin = /** @class */ (function () {
487
487
  delete _this[key];
488
488
  });
489
489
  };
490
- Plugin.version = "3.9.0-next.2";
490
+ Plugin.version = "3.9.0";
491
491
  return Plugin;
492
492
  }());
493
493
  var Plugin$1 = Plugin;
@@ -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.2
8
+ * @version 3.9.0
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -23,7 +23,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
23
23
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24
24
  PERFORMANCE OF THIS SOFTWARE.
25
25
  ***************************************************************************** */
26
- /* global Reflect, Promise */
26
+ /* global Reflect, Promise, SuppressedError, Symbol */
27
27
 
28
28
  var _extendStatics = function extendStatics(d, b) {
29
29
  _extendStatics = Object.setPrototypeOf || {
@@ -121,7 +121,7 @@ var Plugin = /** @class */ (function () {
121
121
  delete _this[key];
122
122
  });
123
123
  };
124
- Plugin.version = "3.9.0-next.2";
124
+ Plugin.version = "3.9.0";
125
125
  return Plugin;
126
126
  }());
127
127
  var Plugin$1 = Plugin;
@@ -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.2
8
+ * @version 3.9.0
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -26,7 +26,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26
26
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27
27
  PERFORMANCE OF THIS SOFTWARE.
28
28
  ***************************************************************************** */
29
- /* global Reflect, Promise */
29
+ /* global Reflect, Promise, SuppressedError, Symbol */
30
30
 
31
31
  var _extendStatics = function extendStatics(d, b) {
32
32
  _extendStatics = Object.setPrototypeOf || {
@@ -263,7 +263,7 @@ var Plugin = /** @class */ (function () {
263
263
  delete _this[key];
264
264
  });
265
265
  };
266
- Plugin.version = "3.9.0-next.2";
266
+ Plugin.version = "3.9.0";
267
267
  return Plugin;
268
268
  }());
269
269
  var Plugin$1 = Plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "billboard.js",
3
- "version": "3.9.0-next.2",
3
+ "version": "3.9.0",
4
4
  "description": "Re-usable easy interface JavaScript chart library, based on D3 v4+",
5
5
  "homepage": "https://naver.github.io/billboard.js/",
6
6
  "main": "dist/billboard.js",
@@ -394,6 +394,7 @@ export default {
394
394
  const isTouch = state.inputType === "touch";
395
395
  const hasGauge = $$.hasType("gauge");
396
396
  const useCssRule = config.boost_useCssRule;
397
+ const interaction = config.legend_item_interaction;
397
398
 
398
399
  item
399
400
  .attr("class", function(id) {
@@ -420,48 +421,63 @@ export default {
420
421
  }
421
422
 
422
423
  item
423
- .style("cursor", $$.getStylePropValue("pointer"))
424
- .on("click", function(event, id) {
425
- if (!callFn(config.legend_item_onclick, api, id)) {
426
- if (event.altKey) {
427
- api.hide();
428
- api.show(id);
429
- } else {
430
- api.toggle(id);
431
-
432
- d3Select(this)
433
- .classed($FOCUS.legendItemFocused, false);
424
+ .on(interaction.dblclick ? "dblclick" : "click", interaction || isFunction(config.legend_item_onclick) ?
425
+ function(event, id) {
426
+ if (!callFn(config.legend_item_onclick, api, id)) {
427
+ const {altKey, target, type} = event;
428
+
429
+ if (type === "dblclick" || altKey) {
430
+ // when focused legend is clicked(with altKey or double clicked), reset all hiding.
431
+ if (state.hiddenTargetIds.length &&
432
+ target.parentNode.getAttribute("class").indexOf($LEGEND.legendItemHidden) === -1
433
+ ) {
434
+ api.show();
435
+ } else {
436
+ api.hide();
437
+ api.show(id);
438
+ }
439
+ } else {
440
+ api.toggle(id);
441
+
442
+ d3Select(this)
443
+ .classed($FOCUS.legendItemFocused, false);
444
+ }
434
445
  }
435
- }
436
446
 
437
- isTouch && $$.hideTooltip();
438
- });
447
+ isTouch && $$.hideTooltip();
448
+ } : null);
439
449
 
440
450
  !isTouch && item
441
- .on("mouseout", function(event, id) {
442
- if (!callFn(config.legend_item_onout, api, id)) {
443
- d3Select(this).classed($FOCUS.legendItemFocused, false);
451
+ .on("mouseout", interaction || isFunction(config.legend_item_onout) ?
452
+ function(event, id) {
453
+ if (!callFn(config.legend_item_onout, api, id)) {
454
+ d3Select(this).classed($FOCUS.legendItemFocused, false);
444
455
 
445
- if (hasGauge) {
446
- $$.undoMarkOverlapped($$, `.${$GAUGE.gaugeValue}`);
447
- }
448
-
449
- $$.api.revert();
450
- }
451
- })
452
- .on("mouseover", function(event, id) {
453
- if (!callFn(config.legend_item_onover, api, id)) {
454
- d3Select(this).classed($FOCUS.legendItemFocused, true);
456
+ if (hasGauge) {
457
+ $$.undoMarkOverlapped($$, `.${$GAUGE.gaugeValue}`);
458
+ }
455
459
 
456
- if (hasGauge) {
457
- $$.markOverlapped(id, $$, `.${$GAUGE.gaugeValue}`);
460
+ $$.api.revert();
458
461
  }
459
-
460
- if (!state.transiting && $$.isTargetToShow(id)) {
461
- api.focus(id);
462
+ } : null)
463
+ .on("mouseover", interaction || isFunction(config.legend_item_onover) ?
464
+ function(event, id) {
465
+ if (!callFn(config.legend_item_onover, api, id)) {
466
+ d3Select(this).classed($FOCUS.legendItemFocused, true);
467
+
468
+ if (hasGauge) {
469
+ $$.markOverlapped(id, $$, `.${$GAUGE.gaugeValue}`);
470
+ }
471
+
472
+ if (!state.transiting && $$.isTargetToShow(id)) {
473
+ api.focus(id);
474
+ }
462
475
  }
463
- }
464
- });
476
+ } : null);
477
+
478
+ // set cursor when has some interaction
479
+ !item.empty() && item.on("click mouseout mouseover") &&
480
+ item.style("cursor", $$.getStylePropValue("pointer"));
465
481
  }
466
482
  },
467
483
 
@@ -40,17 +40,34 @@ export default {
40
40
  * - defines the max step the legend has (e.g. If 2 set and legend has 3 legend item, the legend 2 columns).
41
41
  * @property {boolean} [legend.equally=false] Set to all items have same width size.
42
42
  * @property {number} [legend.padding=0] Set padding value
43
+ * @property {boolean} [legend.item.interaction=true] Set legend item interaction.
44
+ * - **NOTE:**
45
+ * - This setting will not have effect on `.toggle()` method.
46
+ * - `legend.item.onXXX` listener options will work if set, regardless of this option value.
47
+ * @property {boolean} [legend.item.interaction.dblclick=false] Set legend item to interact on double click.
48
+ * - **NOTE:**
49
+ * - Double clicking will make focused clicked dataseries only, hiding all others.
50
+ * - for single click case, `click + altKey(Win)/optionKey(Mac OS)` to have same effect.
51
+ * - To return initial state(which all dataseries are showing), double click current focused legend item again.
52
+ * - for single click case, `click + altKey(Win)/optionKey(Mac OS)` to have same effect.
53
+ * - In this case, default `click` interaction will be disabled.
43
54
  * @property {Function} [legend.item.onclick=undefined] Set click event handler to the legend item.
55
+ * - **NOTE:**
56
+ * - When set, default `click` interaction will be disabled.
57
+ * - When `interaction.dblclick=true` is set, will be called on double click.
44
58
  * @property {Function} [legend.item.onover=undefined] Set mouse/touch over event handler to the legend item.
59
+ * - **NOTE:** When set, default `mouseover` interaction will be disabled.
45
60
  * @property {Function} [legend.item.onout=undefined] Set mouse/touch out event handler to the legend item.
61
+ * - **NOTE:** When set, default `mouseout` interaction will be disabled.
46
62
  * @property {number} [legend.item.tile.width=10] Set width for 'rectangle' legend item tile element.
47
- * @property {number} [legend.item.tile.height=10] ㄹ
63
+ * @property {number} [legend.item.tile.height=10] Set height for 'rectangle' legend item tile element.
48
64
  * @property {number} [legend.item.tile.r=5] Set the radius for 'circle' legend item tile type.
49
65
  * @property {string} [legend.item.tile.type="rectangle"] Set legend item shape type.<br>
50
66
  * - **Available Values:**
51
67
  * - circle
52
68
  * - rectangle
53
69
  * @property {boolean} [legend.usePoint=false] Whether to use custom points in legend.
70
+ * @see [Demo: item.interaction](https://naver.github.io/billboard.js/demo/#Legend.LegendItemInteraction)
54
71
  * @see [Demo: item.tile.type](https://naver.github.io/billboard.js/demo/#Legend.LegendItemTileType)
55
72
  * @see [Demo: position](https://naver.github.io/billboard.js/demo/#Legend.LegendPosition)
56
73
  * @see [Demo: contents.template](https://naver.github.io/billboard.js/demo/#Legend.LegendTemplate1)
@@ -85,6 +102,16 @@ export default {
85
102
  * equally: false,
86
103
  * padding: 10,
87
104
  * item: {
105
+ * // will disable default interaction
106
+ * interaction: false,
107
+ *
108
+ * // set legend interact on double click
109
+ * // by double clicking, will make focused clicked dataseries only, hiding all others.
110
+ * interaction: {
111
+ * dblclick: true
112
+ * }
113
+ *
114
+ * // when set below callback, will disable corresponding default interactions
88
115
  * onclick: function(id) { ... },
89
116
  * onover: function(id) { ... },
90
117
  * onout: function(id) { ... },
@@ -105,23 +132,27 @@ export default {
105
132
  * usePoint: true
106
133
  * }
107
134
  */
108
- legend_show: true,
109
- legend_hide: false,
110
135
  legend_contents_bindto: <string|HTMLElement|undefined> undefined,
111
136
  legend_contents_template: <string|(() => string)|undefined> "<span style='color:#fff;padding:5px;background-color:{=COLOR}'>{=TITLE}</span>",
112
- legend_position: <"bottom"|"right"|"inset"> "bottom",
137
+ legend_equally: false,
138
+ legend_hide: false,
113
139
  legend_inset_anchor: <"top-left"|"top-right"|"bottom-left"|"bottom-right"> "top-left",
114
140
  legend_inset_x: 10,
115
141
  legend_inset_y: 0,
116
142
  legend_inset_step: <number|undefined> undefined,
143
+ legend_item_interaction: <boolean|{
144
+ dblclick?: boolean;
145
+ }> true,
146
+ legend_item_dblclick: false,
117
147
  legend_item_onclick: <Function|undefined> undefined,
118
148
  legend_item_onover: <Function|undefined> undefined,
119
149
  legend_item_onout: <Function|undefined> undefined,
120
- legend_equally: false,
121
- legend_padding: 0,
122
150
  legend_item_tile_width: 10,
123
151
  legend_item_tile_height: 10,
124
152
  legend_item_tile_r: 5,
125
153
  legend_item_tile_type: <"rectangle"|"circle"> "rectangle",
154
+ legend_padding: 0,
155
+ legend_position: <"bottom"|"right"|"inset"> "bottom",
156
+ legend_show: true,
126
157
  legend_usePoint: false
127
158
  };
@@ -470,18 +470,43 @@ export interface LegendOptions {
470
470
  */
471
471
  r?: number;
472
472
  };
473
+
474
+ /**
475
+ * Set legend item interaction.
476
+ * - **NOTE:**
477
+ * - This setting will not have effect on `.toggle()` method.
478
+ * - `legend.item.onXXX` listener options will work if set, regardless of this option value.
479
+ */
480
+ interaction?: boolean | {
481
+ /**
482
+ * Set legend item to interact on double click.
483
+ * - **NOTE:**
484
+ * - Double clicking will make focused clicked dataseries only, hiding all others.
485
+ * - for single click case, `click + altKey(Win)/optionKey(Mac OS)` to have same effect.
486
+ * - To return initial state(which all dataseries are showing), double click current focused legend item again.
487
+ * - for single click case, `click + altKey(Win)/optionKey(Mac OS)` to have same effect.
488
+ * - In this case, default `click` interaction will be disabled.
489
+ */
490
+ dblclick?: boolean;
491
+ };
492
+
473
493
  /**
474
494
  * Set click event handler to the legend item.
495
+ * - **NOTE:**
496
+ * - When set, default `click` interaction will be disabled.
497
+ * - When `interaction.dblclick=true` is set, will be called on double click.
475
498
  */
476
499
  onclick?(this: Chart, id: string): void;
477
500
 
478
501
  /**
479
502
  * Set mouseover event handler to the legend item.
503
+ * - **NOTE:** When set, default `mouseover` interaction will be disabled.
480
504
  */
481
505
  onover?(this: Chart, id: string): void;
482
506
 
483
507
  /**
484
508
  * Set mouseout event handler to the legend item.
509
+ * - **NOTE:** When set, default `mouseout` interaction will be disabled.
485
510
  */
486
511
  onout?(this: Chart, id: string): void;
487
512
  };