@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/charts-vue.umd.js CHANGED
@@ -450,6 +450,7 @@ var events_Toolbar;
450
450
  (function (Toolbar) {
451
451
  Toolbar["SHOW_OVERFLOW_MENU"] = "show-toolbar-overflow-menu";
452
452
  Toolbar["HIDE_OVERFLOW_MENU"] = "hide-toolbar-overflow-menu";
453
+ Toolbar["BUTTON_CLICK"] = "toolbar-button-click";
453
454
  })(events_Toolbar || (events_Toolbar = {}));
454
455
  /**
455
456
  * enum of all events related to the zoom-bar
@@ -893,6 +894,7 @@ var ToolbarControlTypes;
893
894
  ToolbarControlTypes["RESET_ZOOM"] = "Reset zoom";
894
895
  ToolbarControlTypes["MAKE_FULLSCREEN"] = "Make fullscreen";
895
896
  ToolbarControlTypes["SHOW_AS_DATATABLE"] = "Show as data-table";
897
+ ToolbarControlTypes["CUSTOM"] = "Custom";
896
898
  })(ToolbarControlTypes || (ToolbarControlTypes = {}));
897
899
  /**
898
900
  * enum of title orientations for _vertical axes_
@@ -9727,7 +9729,9 @@ var model_ChartModel = /** @class */ (function () {
9727
9729
  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;
9728
9730
  var options = this.getOptions();
9729
9731
  var groupMapsTo = options.data.groupMapsTo;
9730
- var dataGroupNames = this.getDataGroupNames(groups);
9732
+ // Get only active data groups so non-active data groups are not rendered
9733
+ // on legend item click
9734
+ var dataGroupNames = this.getActiveDataGroupNames(groups);
9731
9735
  var dataValuesGroupedByKeys = this.getDataValuesGroupedByKeys({
9732
9736
  groups: groups,
9733
9737
  });
@@ -23796,6 +23800,7 @@ var tooltip_axis_AxisChartsTooltip = /** @class */ (function (_super) {
23796
23800
  var options = this.getOptions();
23797
23801
  var cartesianScales = this.services.cartesianScales;
23798
23802
  var domainIdentifier = cartesianScales.getDomainIdentifier();
23803
+ var dualAxes = cartesianScales.isDualAxes();
23799
23804
  // Generate default tooltip
23800
23805
  var groupMapsTo = options.data.groupMapsTo;
23801
23806
  var domainLabel = cartesianScales.getDomainLabel();
@@ -23805,6 +23810,13 @@ var tooltip_axis_AxisChartsTooltip = /** @class */ (function (_super) {
23805
23810
  if (data.length === 1) {
23806
23811
  var datum = data[0];
23807
23812
  var rangeIdentifier = cartesianScales.getRangeIdentifier(datum);
23813
+ if (dualAxes) {
23814
+ var position = cartesianScales.getRangeAxisPosition({
23815
+ datum: datum,
23816
+ groups: [datum[groupMapsTo]],
23817
+ });
23818
+ rangeLabel = cartesianScales.getScaleLabel(position);
23819
+ }
23808
23820
  var value = datum[rangeIdentifier];
23809
23821
  items = tooltip_axis_spreadArrays([
23810
23822
  {
@@ -23864,7 +23876,6 @@ var tooltip_axis_AxisChartsTooltip = /** @class */ (function (_super) {
23864
23876
  }),
23865
23877
  }); })
23866
23878
  .sort(function (a, b) { return b.value - a.value; }));
23867
- var dualAxes = cartesianScales.isDualAxes();
23868
23879
  if (!dualAxes &&
23869
23880
  tools_Tools.getProperty(options, 'tooltip', 'showTotal') === true) {
23870
23881
  // use the primary/only range id
@@ -38604,6 +38615,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38604
38615
  var isDataLoading = tools_Tools.getProperty(this.getOptions(), 'data', 'loading');
38605
38616
  if (isDataLoading) {
38606
38617
  container.html('');
38618
+ // Set overflow menu to null if data is loading
38619
+ // This will render in a new overflow menu when data is done loading
38620
+ this.overflowMenu = null;
38607
38621
  }
38608
38622
  else {
38609
38623
  if (!this.overflowMenu) {
@@ -38632,23 +38646,26 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38632
38646
  var self_1 = this;
38633
38647
  var allToolbarControls = enteringToolbarControls
38634
38648
  .merge(toolbarControls)
38635
- .classed('disabled', function (d) {
38636
- return d.shouldBeDisabled ? d.shouldBeDisabled() : false;
38637
- })
38638
- .attr('aria-disabled', function (d) {
38639
- return d.shouldBeDisabled ? d.shouldBeDisabled() : false;
38640
- })
38649
+ .classed('disabled', function (d) { return d.shouldBeDisabled(); })
38650
+ .attr('aria-disabled', function (d) { return d.shouldBeDisabled(); })
38641
38651
  .attr('aria-label', function (d) { return d.title; })
38642
- .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>"; })
38652
+ .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
38653
+ ? d.iconSVG.height
38654
+ : '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>"; })
38643
38655
  .each(function (d, index) {
38656
+ var _this = this;
38644
38657
  src_select(this)
38645
38658
  .select('button')
38646
- .on('click', !d.shouldBeDisabled() ? d.clickFunction : null)
38659
+ .on('click', function (event) {
38660
+ if (!d.shouldBeDisabled()) {
38661
+ self_1.triggerFunctionAndEvent(d, event, _this);
38662
+ }
38663
+ })
38647
38664
  .on('keydown', function (event) {
38648
38665
  if ((event.key && event.key === 'Enter') ||
38649
38666
  event.key === ' ') {
38650
38667
  event.preventDefault();
38651
- d.clickFunction();
38668
+ self_1.triggerFunctionAndEvent(d, event, _this);
38652
38669
  }
38653
38670
  else if (event.key && event.key === 'ArrowLeft') {
38654
38671
  self_1.focusOnPreviousEnabledToolbarItem(index);
@@ -38697,6 +38714,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38697
38714
  };
38698
38715
  // show/hide overflow menu
38699
38716
  Toolbar.prototype.updateOverflowMenu = function (show) {
38717
+ if (!this.overflowMenu) {
38718
+ return;
38719
+ }
38700
38720
  this.overflowMenu.classed('is-open', show);
38701
38721
  // update overflow button background
38702
38722
  if (this.overflowButton) {
@@ -38799,15 +38819,13 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38799
38819
  var element = src_select("#" + _this.services.domUtils.generateElementIDString("control-" + menuItem.id));
38800
38820
  if (element !== null) {
38801
38821
  element.on('click', function () {
38802
- // call the specified function
38803
- menuItem.clickFunction();
38822
+ self_2.triggerFunctionAndEvent(menuItem, event, element.node());
38804
38823
  // hide overflow menu
38805
38824
  self_2.updateOverflowMenu(false);
38806
38825
  });
38807
38826
  element.on('keydown', function (keyEvent) {
38808
38827
  if (keyEvent && keyEvent.key === 'Enter') {
38809
- // call the specified function
38810
- menuItem.clickFunction();
38828
+ self_2.triggerFunctionAndEvent(menuItem, event, element.node());
38811
38829
  }
38812
38830
  else if (keyEvent && keyEvent.key === 'ArrowUp') {
38813
38831
  // focus on previous menu item
@@ -38834,35 +38852,75 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38834
38852
  event.stopImmediatePropagation();
38835
38853
  }
38836
38854
  };
38855
+ // Calls passed function && dispatches event
38856
+ Toolbar.prototype.triggerFunctionAndEvent = function (control, event, element) {
38857
+ // Call custom function only if it exists
38858
+ if (typeof control.clickFunction === 'function') {
38859
+ control.clickFunction(event);
38860
+ }
38861
+ // Dispatch selection event
38862
+ this.services.events.dispatchEvent(Events.Toolbar.BUTTON_CLICK, {
38863
+ control: control,
38864
+ event: event,
38865
+ element: element,
38866
+ });
38867
+ };
38837
38868
  Toolbar.prototype.getControlConfigs = function () {
38838
38869
  var _this = this;
38839
- var numberOfIcons = tools_Tools.getProperty(this.getOptions(), 'toolbar', 'numberOfIcons');
38870
+ var numberOfIcons = tools_Tools.getProperty(this.getOptions(), 'toolbar', 'numberOfIcons') -
38871
+ 1;
38840
38872
  var controls = tools_Tools.getProperty(this.getOptions(), 'toolbar', 'controls');
38841
- var controlList = [];
38842
38873
  var overflowSpecificControls = [];
38874
+ var buttonList = [];
38875
+ var overflowList = [];
38843
38876
  controls.forEach(function (control) {
38844
- var controlConfig = _this.getControlConfigByType(control.type);
38877
+ var controlConfig = null;
38878
+ // check if button is custom or default control
38879
+ if (control.type === ToolbarControlTypes.CUSTOM) {
38880
+ // add generic id if missing
38881
+ if (tools_Tools.getProperty(control, 'id') === null) {
38882
+ // add id directly to the data passed so that id isn't reassigned on rerender
38883
+ control.id = "toolbar-button-" + Toolbar.buttonID++;
38884
+ }
38885
+ // define function if missing
38886
+ if (tools_Tools.getProperty(control, 'shouldBeDisabled') === null) {
38887
+ control.shouldBeDisabled = function () { return false; };
38888
+ }
38889
+ controlConfig = control;
38890
+ }
38891
+ else {
38892
+ controlConfig = _this.getControlConfigByType(control.type);
38893
+ }
38845
38894
  // add to list if config is valid
38846
38895
  if (controlConfig) {
38847
38896
  controlConfig.text = control.text ? control.text : control.type;
38848
38897
  if (controlConfig.id.indexOf('toolbar-export') !== -1) {
38849
38898
  overflowSpecificControls.push(controlConfig);
38850
38899
  }
38900
+ else if (buttonList.length < numberOfIcons) {
38901
+ // check if icon exists else assign to the overflow list
38902
+ if (tools_Tools.getProperty(controlConfig, 'iconSVG', 'content') === null) {
38903
+ overflowList.push(controlConfig);
38904
+ }
38905
+ else {
38906
+ buttonList.push(controlConfig);
38907
+ }
38908
+ }
38851
38909
  else {
38852
- controlList.push(controlConfig);
38910
+ overflowList.push(controlConfig);
38853
38911
  }
38854
38912
  }
38855
38913
  });
38856
- if (controlList.length <= numberOfIcons &&
38857
- overflowSpecificControls.length === 0) {
38914
+ // Ensures the `export` controls are always at the bottom
38915
+ overflowList.push.apply(overflowList, overflowSpecificControls);
38916
+ if (!overflowList.length) {
38858
38917
  return {
38859
- buttonList: controlList,
38918
+ buttonList: buttonList,
38860
38919
  };
38861
38920
  }
38862
38921
  return {
38863
- // leave one button for overflow button
38864
- buttonList: controlList.splice(0, numberOfIcons - 1),
38865
- overflowMenuItemList: controlList.concat(overflowSpecificControls),
38922
+ buttonList: buttonList,
38923
+ overflowMenuItemList: overflowList,
38866
38924
  };
38867
38925
  };
38868
38926
  Toolbar.prototype.getToolbarButtonItems = function () {
@@ -38891,7 +38949,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38891
38949
  id: 'toolbar-overflow-menu',
38892
38950
  title: 'More options',
38893
38951
  shouldBeDisabled: function () { return false; },
38894
- 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>",
38952
+ iconSVG: {
38953
+ 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>",
38954
+ },
38895
38955
  clickFunction: function (event) { return _this.toggleOverflowMenu(event); },
38896
38956
  };
38897
38957
  };
@@ -38911,7 +38971,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38911
38971
  shouldBeDisabled: function () {
38912
38972
  return _this.services.zoom.isMinZoomDomain();
38913
38973
  },
38914
- iconSVGContent: this.getControlIconByType(controlType),
38974
+ iconSVG: {
38975
+ content: this.getControlIconByType(controlType),
38976
+ },
38915
38977
  clickFunction: function () { return _this.services.zoom.zoomIn(); },
38916
38978
  };
38917
38979
  }
@@ -38924,7 +38986,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38924
38986
  shouldBeDisabled: function () {
38925
38987
  return _this.services.zoom.isMaxZoomDomain();
38926
38988
  },
38927
- iconSVGContent: this.getControlIconByType(controlType),
38989
+ iconSVG: {
38990
+ content: this.getControlIconByType(controlType),
38991
+ },
38928
38992
  clickFunction: function () { return _this.services.zoom.zoomOut(); },
38929
38993
  };
38930
38994
  }
@@ -38937,7 +39001,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38937
39001
  shouldBeDisabled: function () {
38938
39002
  return _this.services.zoom.isMaxZoomDomain();
38939
39003
  },
38940
- iconSVGContent: this.getControlIconByType(controlType),
39004
+ iconSVG: {
39005
+ content: this.getControlIconByType(controlType),
39006
+ },
38941
39007
  clickFunction: function () {
38942
39008
  return _this.services.zoom.resetZoomDomain();
38943
39009
  },
@@ -38947,10 +39013,12 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38947
39013
  case ToolbarControlTypes.MAKE_FULLSCREEN:
38948
39014
  controlConfig = {
38949
39015
  id: 'toolbar-makefullscreen',
39016
+ iconSVG: {
39017
+ content: this.getControlIconByType(controlType),
39018
+ width: '15px',
39019
+ height: '15px',
39020
+ },
38950
39021
  title: 'Make fullscreen',
38951
- iconSVGContent: this.getControlIconByType(controlType),
38952
- iconWidth: '15px',
38953
- iconHight: '15px',
38954
39022
  shouldBeDisabled: function () { return false; },
38955
39023
  clickFunction: function () {
38956
39024
  _this.services.domUtils.toggleFullscreen();
@@ -38960,8 +39028,10 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38960
39028
  case ToolbarControlTypes.SHOW_AS_DATATABLE:
38961
39029
  controlConfig = {
38962
39030
  id: 'toolbar-showasdatatable',
39031
+ iconSVG: {
39032
+ content: this.getControlIconByType(controlType),
39033
+ },
38963
39034
  title: 'Show as table',
38964
- iconSVGContent: this.getControlIconByType(controlType),
38965
39035
  shouldBeDisabled: function () { return displayData.length === 0; },
38966
39036
  clickFunction: function () {
38967
39037
  return _this.services.events.dispatchEvent(Events.Modal.SHOW);
@@ -38973,7 +39043,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38973
39043
  id: 'toolbar-export-CSV',
38974
39044
  title: 'Export as CSV',
38975
39045
  shouldBeDisabled: function () { return false; },
38976
- iconSVGContent: this.getControlIconByType(controlType),
39046
+ iconSVG: {
39047
+ content: this.getControlIconByType(controlType),
39048
+ },
38977
39049
  clickFunction: function () { return _this.model.exportToCSV(); },
38978
39050
  };
38979
39051
  break;
@@ -38982,7 +39054,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38982
39054
  id: 'toolbar-export-PNG',
38983
39055
  title: 'Export as PNG',
38984
39056
  shouldBeDisabled: function () { return false; },
38985
- iconSVGContent: this.getControlIconByType(controlType),
39057
+ iconSVG: {
39058
+ content: this.getControlIconByType(controlType),
39059
+ },
38986
39060
  clickFunction: function () { return _this.services.domUtils.exportToPNG(); },
38987
39061
  };
38988
39062
  break;
@@ -38991,7 +39065,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38991
39065
  id: 'toolbar-export-JPG',
38992
39066
  title: 'Export as JPG',
38993
39067
  shouldBeDisabled: function () { return false; },
38994
- iconSVGContent: this.getControlIconByType(controlType),
39068
+ iconSVG: {
39069
+ content: this.getControlIconByType(controlType),
39070
+ },
38995
39071
  clickFunction: function () { return _this.services.domUtils.exportToJPG(); },
38996
39072
  };
38997
39073
  break;
@@ -39024,6 +39100,7 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
39024
39100
  throw Error('Not supported toolbar control type: ' + controlType);
39025
39101
  }
39026
39102
  };
39103
+ Toolbar.buttonID = 0;
39027
39104
  return Toolbar;
39028
39105
  }(component_Component));
39029
39106