@carbon/charts-vue 0.53.0 → 0.53.4

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,38 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.53.4](https://github.com/carbon-design-system/carbon-charts/compare/v0.53.3...v0.53.4) (2021-12-13)
7
+
8
+ **Note:** Version bump only for package @carbon/charts-vue
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.53.3](https://github.com/carbon-design-system/carbon-charts/compare/v0.53.2...v0.53.3) (2021-12-07)
15
+
16
+ **Note:** Version bump only for package @carbon/charts-vue
17
+
18
+
19
+
20
+
21
+
22
+ ## [0.53.2](https://github.com/carbon-design-system/carbon-charts/compare/v0.53.1...v0.53.2) (2021-12-06)
23
+
24
+ **Note:** Version bump only for package @carbon/charts-vue
25
+
26
+
27
+
28
+
29
+
30
+ ## [0.53.1](https://github.com/carbon-design-system/carbon-charts/compare/v0.53.0...v0.53.1) (2021-12-02)
31
+
32
+ **Note:** Version bump only for package @carbon/charts-vue
33
+
34
+
35
+
36
+
37
+
6
38
  # [0.53.0](https://github.com/carbon-design-system/carbon-charts/compare/v0.52.4...v0.53.0) (2021-12-01)
7
39
 
8
40
  **Note:** Version bump only for package @carbon/charts-vue
@@ -441,6 +441,7 @@ var events_Toolbar;
441
441
  (function (Toolbar) {
442
442
  Toolbar["SHOW_OVERFLOW_MENU"] = "show-toolbar-overflow-menu";
443
443
  Toolbar["HIDE_OVERFLOW_MENU"] = "hide-toolbar-overflow-menu";
444
+ Toolbar["BUTTON_CLICK"] = "toolbar-button-click";
444
445
  })(events_Toolbar || (events_Toolbar = {}));
445
446
  /**
446
447
  * enum of all events related to the zoom-bar
@@ -884,6 +885,7 @@ var ToolbarControlTypes;
884
885
  ToolbarControlTypes["RESET_ZOOM"] = "Reset zoom";
885
886
  ToolbarControlTypes["MAKE_FULLSCREEN"] = "Make fullscreen";
886
887
  ToolbarControlTypes["SHOW_AS_DATATABLE"] = "Show as data-table";
888
+ ToolbarControlTypes["CUSTOM"] = "Custom";
887
889
  })(ToolbarControlTypes || (ToolbarControlTypes = {}));
888
890
  /**
889
891
  * enum of title orientations for _vertical axes_
@@ -9718,7 +9720,9 @@ var model_ChartModel = /** @class */ (function () {
9718
9720
  var _b = _a.percentage, percentage = _b === void 0 ? false : _b, _c = _a.groups, groups = _c === void 0 ? null : _c, _d = _a.divergent, divergent = _d === void 0 ? false : _d;
9719
9721
  var options = this.getOptions();
9720
9722
  var groupMapsTo = options.data.groupMapsTo;
9721
- var dataGroupNames = this.getDataGroupNames(groups);
9723
+ // Get only active data groups so non-active data groups are not rendered
9724
+ // on legend item click
9725
+ var dataGroupNames = this.getActiveDataGroupNames(groups);
9722
9726
  var dataValuesGroupedByKeys = this.getDataValuesGroupedByKeys({
9723
9727
  groups: groups,
9724
9728
  });
@@ -23787,6 +23791,7 @@ var tooltip_axis_AxisChartsTooltip = /** @class */ (function (_super) {
23787
23791
  var options = this.getOptions();
23788
23792
  var cartesianScales = this.services.cartesianScales;
23789
23793
  var domainIdentifier = cartesianScales.getDomainIdentifier();
23794
+ var dualAxes = cartesianScales.isDualAxes();
23790
23795
  // Generate default tooltip
23791
23796
  var groupMapsTo = options.data.groupMapsTo;
23792
23797
  var domainLabel = cartesianScales.getDomainLabel();
@@ -23796,6 +23801,13 @@ var tooltip_axis_AxisChartsTooltip = /** @class */ (function (_super) {
23796
23801
  if (data.length === 1) {
23797
23802
  var datum = data[0];
23798
23803
  var rangeIdentifier = cartesianScales.getRangeIdentifier(datum);
23804
+ if (dualAxes) {
23805
+ var position = cartesianScales.getRangeAxisPosition({
23806
+ datum: datum,
23807
+ groups: [datum[groupMapsTo]],
23808
+ });
23809
+ rangeLabel = cartesianScales.getScaleLabel(position);
23810
+ }
23799
23811
  var value = datum[rangeIdentifier];
23800
23812
  items = tooltip_axis_spreadArrays([
23801
23813
  {
@@ -23855,7 +23867,6 @@ var tooltip_axis_AxisChartsTooltip = /** @class */ (function (_super) {
23855
23867
  }),
23856
23868
  }); })
23857
23869
  .sort(function (a, b) { return b.value - a.value; }));
23858
- var dualAxes = cartesianScales.isDualAxes();
23859
23870
  if (!dualAxes &&
23860
23871
  tools_Tools.getProperty(options, 'tooltip', 'showTotal') === true) {
23861
23872
  // use the primary/only range id
@@ -38595,6 +38606,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38595
38606
  var isDataLoading = tools_Tools.getProperty(this.getOptions(), 'data', 'loading');
38596
38607
  if (isDataLoading) {
38597
38608
  container.html('');
38609
+ // Set overflow menu to null if data is loading
38610
+ // This will render in a new overflow menu when data is done loading
38611
+ this.overflowMenu = null;
38598
38612
  }
38599
38613
  else {
38600
38614
  if (!this.overflowMenu) {
@@ -38623,23 +38637,26 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38623
38637
  var self_1 = this;
38624
38638
  var allToolbarControls = enteringToolbarControls
38625
38639
  .merge(toolbarControls)
38626
- .classed('disabled', function (d) {
38627
- return d.shouldBeDisabled ? d.shouldBeDisabled() : false;
38628
- })
38629
- .attr('aria-disabled', function (d) {
38630
- return d.shouldBeDisabled ? d.shouldBeDisabled() : false;
38631
- })
38640
+ .classed('disabled', function (d) { return d.shouldBeDisabled(); })
38641
+ .attr('aria-disabled', function (d) { return d.shouldBeDisabled(); })
38632
38642
  .attr('aria-label', function (d) { return d.title; })
38633
- .html(function (d) { return "\n\t\t\t<button\n\t\t\t\tclass=\"bx--overflow-menu__trigger\"\n\t\t\t\taria-haspopup=\"true\" aria-expanded=\"false\" id=\"" + _this.services.domUtils.generateElementIDString("control-" + d.id) + "\" aria-label=\"" + d.title + "\">\n\t\t\t\t<svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" style=\"will-change: transform; width: " + (d.iconWidth !== undefined ? d.iconWidth : '20px') + "; height: " + (d.iconWidth !== undefined ? d.iconHeight : '20px') + "\" xmlns=\"http://www.w3.org/2000/svg\" class=\"bx--overflow-menu__icon\" viewBox=\"0 0 32 32\" aria-hidden=\"true\">\n\t\t\t\t\t" + d.iconSVGContent + "\n\t\t\t\t</svg>\n\t\t\t</button>"; })
38643
+ .html(function (d) { return "\n\t\t\t<button\n\t\t\t\tclass=\"bx--overflow-menu__trigger\"\n\t\t\t\taria-haspopup=\"true\" aria-expanded=\"false\" id=\"" + _this.services.domUtils.generateElementIDString("control-" + d.id) + "\" aria-label=\"" + d.title + "\">\n\t\t\t\t<svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" style=\"will-change: transform; width: " + (d.iconSVG.width !== undefined ? d.iconSVG.width : '20px') + "; height: " + (d.iconSVG.height !== undefined
38644
+ ? d.iconSVG.height
38645
+ : '20px') + "\" xmlns=\"http://www.w3.org/2000/svg\" class=\"bx--overflow-menu__icon\" viewBox=\"0 0 32 32\" aria-hidden=\"true\">\n\t\t\t\t\t" + d.iconSVG.content + "\n\t\t\t\t</svg>\n\t\t\t</button>"; })
38634
38646
  .each(function (d, index) {
38647
+ var _this = this;
38635
38648
  src_select(this)
38636
38649
  .select('button')
38637
- .on('click', !d.shouldBeDisabled() ? d.clickFunction : null)
38650
+ .on('click', function (event) {
38651
+ if (!d.shouldBeDisabled()) {
38652
+ self_1.triggerFunctionAndEvent(d, event, _this);
38653
+ }
38654
+ })
38638
38655
  .on('keydown', function (event) {
38639
38656
  if ((event.key && event.key === 'Enter') ||
38640
38657
  event.key === ' ') {
38641
38658
  event.preventDefault();
38642
- d.clickFunction();
38659
+ self_1.triggerFunctionAndEvent(d, event, _this);
38643
38660
  }
38644
38661
  else if (event.key && event.key === 'ArrowLeft') {
38645
38662
  self_1.focusOnPreviousEnabledToolbarItem(index);
@@ -38688,6 +38705,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38688
38705
  };
38689
38706
  // show/hide overflow menu
38690
38707
  Toolbar.prototype.updateOverflowMenu = function (show) {
38708
+ if (!this.overflowMenu) {
38709
+ return;
38710
+ }
38691
38711
  this.overflowMenu.classed('is-open', show);
38692
38712
  // update overflow button background
38693
38713
  if (this.overflowButton) {
@@ -38790,15 +38810,13 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38790
38810
  var element = src_select("#" + _this.services.domUtils.generateElementIDString("control-" + menuItem.id));
38791
38811
  if (element !== null) {
38792
38812
  element.on('click', function () {
38793
- // call the specified function
38794
- menuItem.clickFunction();
38813
+ self_2.triggerFunctionAndEvent(menuItem, event, element.node());
38795
38814
  // hide overflow menu
38796
38815
  self_2.updateOverflowMenu(false);
38797
38816
  });
38798
38817
  element.on('keydown', function (keyEvent) {
38799
38818
  if (keyEvent && keyEvent.key === 'Enter') {
38800
- // call the specified function
38801
- menuItem.clickFunction();
38819
+ self_2.triggerFunctionAndEvent(menuItem, event, element.node());
38802
38820
  }
38803
38821
  else if (keyEvent && keyEvent.key === 'ArrowUp') {
38804
38822
  // focus on previous menu item
@@ -38825,35 +38843,75 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38825
38843
  event.stopImmediatePropagation();
38826
38844
  }
38827
38845
  };
38846
+ // Calls passed function && dispatches event
38847
+ Toolbar.prototype.triggerFunctionAndEvent = function (control, event, element) {
38848
+ // Call custom function only if it exists
38849
+ if (typeof control.clickFunction === 'function') {
38850
+ control.clickFunction(event);
38851
+ }
38852
+ // Dispatch selection event
38853
+ this.services.events.dispatchEvent(Events.Toolbar.BUTTON_CLICK, {
38854
+ control: control,
38855
+ event: event,
38856
+ element: element,
38857
+ });
38858
+ };
38828
38859
  Toolbar.prototype.getControlConfigs = function () {
38829
38860
  var _this = this;
38830
- var numberOfIcons = tools_Tools.getProperty(this.getOptions(), 'toolbar', 'numberOfIcons');
38861
+ var numberOfIcons = tools_Tools.getProperty(this.getOptions(), 'toolbar', 'numberOfIcons') -
38862
+ 1;
38831
38863
  var controls = tools_Tools.getProperty(this.getOptions(), 'toolbar', 'controls');
38832
- var controlList = [];
38833
38864
  var overflowSpecificControls = [];
38865
+ var buttonList = [];
38866
+ var overflowList = [];
38834
38867
  controls.forEach(function (control) {
38835
- var controlConfig = _this.getControlConfigByType(control.type);
38868
+ var controlConfig = null;
38869
+ // check if button is custom or default control
38870
+ if (control.type === ToolbarControlTypes.CUSTOM) {
38871
+ // add generic id if missing
38872
+ if (tools_Tools.getProperty(control, 'id') === null) {
38873
+ // add id directly to the data passed so that id isn't reassigned on rerender
38874
+ control.id = "toolbar-button-" + Toolbar.buttonID++;
38875
+ }
38876
+ // define function if missing
38877
+ if (tools_Tools.getProperty(control, 'shouldBeDisabled') === null) {
38878
+ control.shouldBeDisabled = function () { return false; };
38879
+ }
38880
+ controlConfig = control;
38881
+ }
38882
+ else {
38883
+ controlConfig = _this.getControlConfigByType(control.type);
38884
+ }
38836
38885
  // add to list if config is valid
38837
38886
  if (controlConfig) {
38838
38887
  controlConfig.text = control.text ? control.text : control.type;
38839
38888
  if (controlConfig.id.indexOf('toolbar-export') !== -1) {
38840
38889
  overflowSpecificControls.push(controlConfig);
38841
38890
  }
38891
+ else if (buttonList.length < numberOfIcons) {
38892
+ // check if icon exists else assign to the overflow list
38893
+ if (tools_Tools.getProperty(controlConfig, 'iconSVG', 'content') === null) {
38894
+ overflowList.push(controlConfig);
38895
+ }
38896
+ else {
38897
+ buttonList.push(controlConfig);
38898
+ }
38899
+ }
38842
38900
  else {
38843
- controlList.push(controlConfig);
38901
+ overflowList.push(controlConfig);
38844
38902
  }
38845
38903
  }
38846
38904
  });
38847
- if (controlList.length <= numberOfIcons &&
38848
- overflowSpecificControls.length === 0) {
38905
+ // Ensures the `export` controls are always at the bottom
38906
+ overflowList.push.apply(overflowList, overflowSpecificControls);
38907
+ if (!overflowList.length) {
38849
38908
  return {
38850
- buttonList: controlList,
38909
+ buttonList: buttonList,
38851
38910
  };
38852
38911
  }
38853
38912
  return {
38854
- // leave one button for overflow button
38855
- buttonList: controlList.splice(0, numberOfIcons - 1),
38856
- overflowMenuItemList: controlList.concat(overflowSpecificControls),
38913
+ buttonList: buttonList,
38914
+ overflowMenuItemList: overflowList,
38857
38915
  };
38858
38916
  };
38859
38917
  Toolbar.prototype.getToolbarButtonItems = function () {
@@ -38882,7 +38940,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38882
38940
  id: 'toolbar-overflow-menu',
38883
38941
  title: 'More options',
38884
38942
  shouldBeDisabled: function () { return false; },
38885
- iconSVGContent: "<circle cx=\"16\" cy=\"8\" r=\"2\"></circle>\n\t\t\t\t\t\t\t <circle cx=\"16\" cy=\"16\" r=\"2\"></circle>\n\t\t\t\t\t\t\t <circle cx=\"16\" cy=\"24\" r=\"2\"></circle>",
38943
+ iconSVG: {
38944
+ content: "<circle cx=\"16\" cy=\"8\" r=\"2\"></circle>\n\t\t\t\t<circle cx=\"16\" cy=\"16\" r=\"2\"></circle>\n\t\t\t\t<circle cx=\"16\" cy=\"24\" r=\"2\"></circle>",
38945
+ },
38886
38946
  clickFunction: function (event) { return _this.toggleOverflowMenu(event); },
38887
38947
  };
38888
38948
  };
@@ -38902,7 +38962,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38902
38962
  shouldBeDisabled: function () {
38903
38963
  return _this.services.zoom.isMinZoomDomain();
38904
38964
  },
38905
- iconSVGContent: this.getControlIconByType(controlType),
38965
+ iconSVG: {
38966
+ content: this.getControlIconByType(controlType),
38967
+ },
38906
38968
  clickFunction: function () { return _this.services.zoom.zoomIn(); },
38907
38969
  };
38908
38970
  }
@@ -38915,7 +38977,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38915
38977
  shouldBeDisabled: function () {
38916
38978
  return _this.services.zoom.isMaxZoomDomain();
38917
38979
  },
38918
- iconSVGContent: this.getControlIconByType(controlType),
38980
+ iconSVG: {
38981
+ content: this.getControlIconByType(controlType),
38982
+ },
38919
38983
  clickFunction: function () { return _this.services.zoom.zoomOut(); },
38920
38984
  };
38921
38985
  }
@@ -38928,7 +38992,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38928
38992
  shouldBeDisabled: function () {
38929
38993
  return _this.services.zoom.isMaxZoomDomain();
38930
38994
  },
38931
- iconSVGContent: this.getControlIconByType(controlType),
38995
+ iconSVG: {
38996
+ content: this.getControlIconByType(controlType),
38997
+ },
38932
38998
  clickFunction: function () {
38933
38999
  return _this.services.zoom.resetZoomDomain();
38934
39000
  },
@@ -38938,10 +39004,12 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38938
39004
  case ToolbarControlTypes.MAKE_FULLSCREEN:
38939
39005
  controlConfig = {
38940
39006
  id: 'toolbar-makefullscreen',
39007
+ iconSVG: {
39008
+ content: this.getControlIconByType(controlType),
39009
+ width: '15px',
39010
+ height: '15px',
39011
+ },
38941
39012
  title: 'Make fullscreen',
38942
- iconSVGContent: this.getControlIconByType(controlType),
38943
- iconWidth: '15px',
38944
- iconHight: '15px',
38945
39013
  shouldBeDisabled: function () { return false; },
38946
39014
  clickFunction: function () {
38947
39015
  _this.services.domUtils.toggleFullscreen();
@@ -38951,8 +39019,10 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38951
39019
  case ToolbarControlTypes.SHOW_AS_DATATABLE:
38952
39020
  controlConfig = {
38953
39021
  id: 'toolbar-showasdatatable',
39022
+ iconSVG: {
39023
+ content: this.getControlIconByType(controlType),
39024
+ },
38954
39025
  title: 'Show as table',
38955
- iconSVGContent: this.getControlIconByType(controlType),
38956
39026
  shouldBeDisabled: function () { return displayData.length === 0; },
38957
39027
  clickFunction: function () {
38958
39028
  return _this.services.events.dispatchEvent(Events.Modal.SHOW);
@@ -38964,7 +39034,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38964
39034
  id: 'toolbar-export-CSV',
38965
39035
  title: 'Export as CSV',
38966
39036
  shouldBeDisabled: function () { return false; },
38967
- iconSVGContent: this.getControlIconByType(controlType),
39037
+ iconSVG: {
39038
+ content: this.getControlIconByType(controlType),
39039
+ },
38968
39040
  clickFunction: function () { return _this.model.exportToCSV(); },
38969
39041
  };
38970
39042
  break;
@@ -38973,7 +39045,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38973
39045
  id: 'toolbar-export-PNG',
38974
39046
  title: 'Export as PNG',
38975
39047
  shouldBeDisabled: function () { return false; },
38976
- iconSVGContent: this.getControlIconByType(controlType),
39048
+ iconSVG: {
39049
+ content: this.getControlIconByType(controlType),
39050
+ },
38977
39051
  clickFunction: function () { return _this.services.domUtils.exportToPNG(); },
38978
39052
  };
38979
39053
  break;
@@ -38982,7 +39056,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38982
39056
  id: 'toolbar-export-JPG',
38983
39057
  title: 'Export as JPG',
38984
39058
  shouldBeDisabled: function () { return false; },
38985
- iconSVGContent: this.getControlIconByType(controlType),
39059
+ iconSVG: {
39060
+ content: this.getControlIconByType(controlType),
39061
+ },
38986
39062
  clickFunction: function () { return _this.services.domUtils.exportToJPG(); },
38987
39063
  };
38988
39064
  break;
@@ -39015,6 +39091,7 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
39015
39091
  throw Error('Not supported toolbar control type: ' + controlType);
39016
39092
  }
39017
39093
  };
39094
+ Toolbar.buttonID = 0;
39018
39095
  return Toolbar;
39019
39096
  }(component_Component));
39020
39097