@carbon/charts-vue 0.53.1 → 0.53.5

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.5](https://github.com/carbon-design-system/carbon-charts/compare/v0.53.4...v0.53.5) (2021-12-15)
7
+
8
+ **Note:** Version bump only for package @carbon/charts-vue
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.53.4](https://github.com/carbon-design-system/carbon-charts/compare/v0.53.3...v0.53.4) (2021-12-13)
15
+
16
+ **Note:** Version bump only for package @carbon/charts-vue
17
+
18
+
19
+
20
+
21
+
22
+ ## [0.53.3](https://github.com/carbon-design-system/carbon-charts/compare/v0.53.2...v0.53.3) (2021-12-07)
23
+
24
+ **Note:** Version bump only for package @carbon/charts-vue
25
+
26
+
27
+
28
+
29
+
30
+ ## [0.53.2](https://github.com/carbon-design-system/carbon-charts/compare/v0.53.1...v0.53.2) (2021-12-06)
31
+
32
+ **Note:** Version bump only for package @carbon/charts-vue
33
+
34
+
35
+
36
+
37
+
6
38
  ## [0.53.1](https://github.com/carbon-design-system/carbon-charts/compare/v0.53.0...v0.53.1) (2021-12-02)
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_
@@ -17528,6 +17530,11 @@ var zoom_Zoom = /** @class */ (function (_super) {
17528
17530
  var cartesianScales = this.services.cartesianScales;
17529
17531
  var mainXAxisPosition = cartesianScales.getMainXAxisPosition();
17530
17532
  var domainIdentifier = cartesianScales.getDomainIdentifier();
17533
+ var customDomain = tools_Tools.getProperty(this.model.getOptions(), 'axes', mainXAxisPosition, 'domain');
17534
+ // return custom domain if exists && valid
17535
+ if (Array.isArray(customDomain) && customDomain.length === 2) {
17536
+ return customDomain;
17537
+ }
17531
17538
  // default to full range with extended domain
17532
17539
  return cartesianScales.extendsDomain(mainXAxisPosition, src_extent(allZoomBarData, function (d) { return d[domainIdentifier]; }));
17533
17540
  };
@@ -23789,6 +23796,7 @@ var tooltip_axis_AxisChartsTooltip = /** @class */ (function (_super) {
23789
23796
  var options = this.getOptions();
23790
23797
  var cartesianScales = this.services.cartesianScales;
23791
23798
  var domainIdentifier = cartesianScales.getDomainIdentifier();
23799
+ var dualAxes = cartesianScales.isDualAxes();
23792
23800
  // Generate default tooltip
23793
23801
  var groupMapsTo = options.data.groupMapsTo;
23794
23802
  var domainLabel = cartesianScales.getDomainLabel();
@@ -23798,6 +23806,13 @@ var tooltip_axis_AxisChartsTooltip = /** @class */ (function (_super) {
23798
23806
  if (data.length === 1) {
23799
23807
  var datum = data[0];
23800
23808
  var rangeIdentifier = cartesianScales.getRangeIdentifier(datum);
23809
+ if (dualAxes) {
23810
+ var position = cartesianScales.getRangeAxisPosition({
23811
+ datum: datum,
23812
+ groups: [datum[groupMapsTo]],
23813
+ });
23814
+ rangeLabel = cartesianScales.getScaleLabel(position);
23815
+ }
23801
23816
  var value = datum[rangeIdentifier];
23802
23817
  items = tooltip_axis_spreadArrays([
23803
23818
  {
@@ -23857,7 +23872,6 @@ var tooltip_axis_AxisChartsTooltip = /** @class */ (function (_super) {
23857
23872
  }),
23858
23873
  }); })
23859
23874
  .sort(function (a, b) { return b.value - a.value; }));
23860
- var dualAxes = cartesianScales.isDualAxes();
23861
23875
  if (!dualAxes &&
23862
23876
  tools_Tools.getProperty(options, 'tooltip', 'showTotal') === true) {
23863
23877
  // use the primary/only range id
@@ -38597,6 +38611,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38597
38611
  var isDataLoading = tools_Tools.getProperty(this.getOptions(), 'data', 'loading');
38598
38612
  if (isDataLoading) {
38599
38613
  container.html('');
38614
+ // Set overflow menu to null if data is loading
38615
+ // This will render in a new overflow menu when data is done loading
38616
+ this.overflowMenu = null;
38600
38617
  }
38601
38618
  else {
38602
38619
  if (!this.overflowMenu) {
@@ -38625,23 +38642,26 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38625
38642
  var self_1 = this;
38626
38643
  var allToolbarControls = enteringToolbarControls
38627
38644
  .merge(toolbarControls)
38628
- .classed('disabled', function (d) {
38629
- return d.shouldBeDisabled ? d.shouldBeDisabled() : false;
38630
- })
38631
- .attr('aria-disabled', function (d) {
38632
- return d.shouldBeDisabled ? d.shouldBeDisabled() : false;
38633
- })
38645
+ .classed('disabled', function (d) { return d.shouldBeDisabled(); })
38646
+ .attr('aria-disabled', function (d) { return d.shouldBeDisabled(); })
38634
38647
  .attr('aria-label', function (d) { return d.title; })
38635
- .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>"; })
38648
+ .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
38649
+ ? d.iconSVG.height
38650
+ : '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>"; })
38636
38651
  .each(function (d, index) {
38652
+ var _this = this;
38637
38653
  src_select(this)
38638
38654
  .select('button')
38639
- .on('click', !d.shouldBeDisabled() ? d.clickFunction : null)
38655
+ .on('click', function (event) {
38656
+ if (!d.shouldBeDisabled()) {
38657
+ self_1.triggerFunctionAndEvent(d, event, _this);
38658
+ }
38659
+ })
38640
38660
  .on('keydown', function (event) {
38641
38661
  if ((event.key && event.key === 'Enter') ||
38642
38662
  event.key === ' ') {
38643
38663
  event.preventDefault();
38644
- d.clickFunction();
38664
+ self_1.triggerFunctionAndEvent(d, event, _this);
38645
38665
  }
38646
38666
  else if (event.key && event.key === 'ArrowLeft') {
38647
38667
  self_1.focusOnPreviousEnabledToolbarItem(index);
@@ -38690,6 +38710,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38690
38710
  };
38691
38711
  // show/hide overflow menu
38692
38712
  Toolbar.prototype.updateOverflowMenu = function (show) {
38713
+ if (!this.overflowMenu) {
38714
+ return;
38715
+ }
38693
38716
  this.overflowMenu.classed('is-open', show);
38694
38717
  // update overflow button background
38695
38718
  if (this.overflowButton) {
@@ -38792,15 +38815,13 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38792
38815
  var element = src_select("#" + _this.services.domUtils.generateElementIDString("control-" + menuItem.id));
38793
38816
  if (element !== null) {
38794
38817
  element.on('click', function () {
38795
- // call the specified function
38796
- menuItem.clickFunction();
38818
+ self_2.triggerFunctionAndEvent(menuItem, event, element.node());
38797
38819
  // hide overflow menu
38798
38820
  self_2.updateOverflowMenu(false);
38799
38821
  });
38800
38822
  element.on('keydown', function (keyEvent) {
38801
38823
  if (keyEvent && keyEvent.key === 'Enter') {
38802
- // call the specified function
38803
- menuItem.clickFunction();
38824
+ self_2.triggerFunctionAndEvent(menuItem, event, element.node());
38804
38825
  }
38805
38826
  else if (keyEvent && keyEvent.key === 'ArrowUp') {
38806
38827
  // focus on previous menu item
@@ -38827,35 +38848,75 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38827
38848
  event.stopImmediatePropagation();
38828
38849
  }
38829
38850
  };
38851
+ // Calls passed function && dispatches event
38852
+ Toolbar.prototype.triggerFunctionAndEvent = function (control, event, element) {
38853
+ // Call custom function only if it exists
38854
+ if (typeof control.clickFunction === 'function') {
38855
+ control.clickFunction(event);
38856
+ }
38857
+ // Dispatch selection event
38858
+ this.services.events.dispatchEvent(Events.Toolbar.BUTTON_CLICK, {
38859
+ control: control,
38860
+ event: event,
38861
+ element: element,
38862
+ });
38863
+ };
38830
38864
  Toolbar.prototype.getControlConfigs = function () {
38831
38865
  var _this = this;
38832
- var numberOfIcons = tools_Tools.getProperty(this.getOptions(), 'toolbar', 'numberOfIcons');
38866
+ var numberOfIcons = tools_Tools.getProperty(this.getOptions(), 'toolbar', 'numberOfIcons') -
38867
+ 1;
38833
38868
  var controls = tools_Tools.getProperty(this.getOptions(), 'toolbar', 'controls');
38834
- var controlList = [];
38835
38869
  var overflowSpecificControls = [];
38870
+ var buttonList = [];
38871
+ var overflowList = [];
38836
38872
  controls.forEach(function (control) {
38837
- var controlConfig = _this.getControlConfigByType(control.type);
38873
+ var controlConfig = null;
38874
+ // check if button is custom or default control
38875
+ if (control.type === ToolbarControlTypes.CUSTOM) {
38876
+ // add generic id if missing
38877
+ if (tools_Tools.getProperty(control, 'id') === null) {
38878
+ // add id directly to the data passed so that id isn't reassigned on rerender
38879
+ control.id = "toolbar-button-" + Toolbar.buttonID++;
38880
+ }
38881
+ // define function if missing
38882
+ if (tools_Tools.getProperty(control, 'shouldBeDisabled') === null) {
38883
+ control.shouldBeDisabled = function () { return false; };
38884
+ }
38885
+ controlConfig = control;
38886
+ }
38887
+ else {
38888
+ controlConfig = _this.getControlConfigByType(control.type);
38889
+ }
38838
38890
  // add to list if config is valid
38839
38891
  if (controlConfig) {
38840
38892
  controlConfig.text = control.text ? control.text : control.type;
38841
38893
  if (controlConfig.id.indexOf('toolbar-export') !== -1) {
38842
38894
  overflowSpecificControls.push(controlConfig);
38843
38895
  }
38896
+ else if (buttonList.length < numberOfIcons) {
38897
+ // check if icon exists else assign to the overflow list
38898
+ if (tools_Tools.getProperty(controlConfig, 'iconSVG', 'content') === null) {
38899
+ overflowList.push(controlConfig);
38900
+ }
38901
+ else {
38902
+ buttonList.push(controlConfig);
38903
+ }
38904
+ }
38844
38905
  else {
38845
- controlList.push(controlConfig);
38906
+ overflowList.push(controlConfig);
38846
38907
  }
38847
38908
  }
38848
38909
  });
38849
- if (controlList.length <= numberOfIcons &&
38850
- overflowSpecificControls.length === 0) {
38910
+ // Ensures the `export` controls are always at the bottom
38911
+ overflowList.push.apply(overflowList, overflowSpecificControls);
38912
+ if (!overflowList.length) {
38851
38913
  return {
38852
- buttonList: controlList,
38914
+ buttonList: buttonList,
38853
38915
  };
38854
38916
  }
38855
38917
  return {
38856
- // leave one button for overflow button
38857
- buttonList: controlList.splice(0, numberOfIcons - 1),
38858
- overflowMenuItemList: controlList.concat(overflowSpecificControls),
38918
+ buttonList: buttonList,
38919
+ overflowMenuItemList: overflowList,
38859
38920
  };
38860
38921
  };
38861
38922
  Toolbar.prototype.getToolbarButtonItems = function () {
@@ -38884,7 +38945,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38884
38945
  id: 'toolbar-overflow-menu',
38885
38946
  title: 'More options',
38886
38947
  shouldBeDisabled: function () { return false; },
38887
- 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>",
38948
+ iconSVG: {
38949
+ 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>",
38950
+ },
38888
38951
  clickFunction: function (event) { return _this.toggleOverflowMenu(event); },
38889
38952
  };
38890
38953
  };
@@ -38904,7 +38967,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38904
38967
  shouldBeDisabled: function () {
38905
38968
  return _this.services.zoom.isMinZoomDomain();
38906
38969
  },
38907
- iconSVGContent: this.getControlIconByType(controlType),
38970
+ iconSVG: {
38971
+ content: this.getControlIconByType(controlType),
38972
+ },
38908
38973
  clickFunction: function () { return _this.services.zoom.zoomIn(); },
38909
38974
  };
38910
38975
  }
@@ -38917,7 +38982,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38917
38982
  shouldBeDisabled: function () {
38918
38983
  return _this.services.zoom.isMaxZoomDomain();
38919
38984
  },
38920
- iconSVGContent: this.getControlIconByType(controlType),
38985
+ iconSVG: {
38986
+ content: this.getControlIconByType(controlType),
38987
+ },
38921
38988
  clickFunction: function () { return _this.services.zoom.zoomOut(); },
38922
38989
  };
38923
38990
  }
@@ -38930,7 +38997,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38930
38997
  shouldBeDisabled: function () {
38931
38998
  return _this.services.zoom.isMaxZoomDomain();
38932
38999
  },
38933
- iconSVGContent: this.getControlIconByType(controlType),
39000
+ iconSVG: {
39001
+ content: this.getControlIconByType(controlType),
39002
+ },
38934
39003
  clickFunction: function () {
38935
39004
  return _this.services.zoom.resetZoomDomain();
38936
39005
  },
@@ -38940,10 +39009,12 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38940
39009
  case ToolbarControlTypes.MAKE_FULLSCREEN:
38941
39010
  controlConfig = {
38942
39011
  id: 'toolbar-makefullscreen',
39012
+ iconSVG: {
39013
+ content: this.getControlIconByType(controlType),
39014
+ width: '15px',
39015
+ height: '15px',
39016
+ },
38943
39017
  title: 'Make fullscreen',
38944
- iconSVGContent: this.getControlIconByType(controlType),
38945
- iconWidth: '15px',
38946
- iconHight: '15px',
38947
39018
  shouldBeDisabled: function () { return false; },
38948
39019
  clickFunction: function () {
38949
39020
  _this.services.domUtils.toggleFullscreen();
@@ -38953,8 +39024,10 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38953
39024
  case ToolbarControlTypes.SHOW_AS_DATATABLE:
38954
39025
  controlConfig = {
38955
39026
  id: 'toolbar-showasdatatable',
39027
+ iconSVG: {
39028
+ content: this.getControlIconByType(controlType),
39029
+ },
38956
39030
  title: 'Show as table',
38957
- iconSVGContent: this.getControlIconByType(controlType),
38958
39031
  shouldBeDisabled: function () { return displayData.length === 0; },
38959
39032
  clickFunction: function () {
38960
39033
  return _this.services.events.dispatchEvent(Events.Modal.SHOW);
@@ -38966,7 +39039,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38966
39039
  id: 'toolbar-export-CSV',
38967
39040
  title: 'Export as CSV',
38968
39041
  shouldBeDisabled: function () { return false; },
38969
- iconSVGContent: this.getControlIconByType(controlType),
39042
+ iconSVG: {
39043
+ content: this.getControlIconByType(controlType),
39044
+ },
38970
39045
  clickFunction: function () { return _this.model.exportToCSV(); },
38971
39046
  };
38972
39047
  break;
@@ -38975,7 +39050,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38975
39050
  id: 'toolbar-export-PNG',
38976
39051
  title: 'Export as PNG',
38977
39052
  shouldBeDisabled: function () { return false; },
38978
- iconSVGContent: this.getControlIconByType(controlType),
39053
+ iconSVG: {
39054
+ content: this.getControlIconByType(controlType),
39055
+ },
38979
39056
  clickFunction: function () { return _this.services.domUtils.exportToPNG(); },
38980
39057
  };
38981
39058
  break;
@@ -38984,7 +39061,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38984
39061
  id: 'toolbar-export-JPG',
38985
39062
  title: 'Export as JPG',
38986
39063
  shouldBeDisabled: function () { return false; },
38987
- iconSVGContent: this.getControlIconByType(controlType),
39064
+ iconSVG: {
39065
+ content: this.getControlIconByType(controlType),
39066
+ },
38988
39067
  clickFunction: function () { return _this.services.domUtils.exportToJPG(); },
38989
39068
  };
38990
39069
  break;
@@ -39017,6 +39096,7 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
39017
39096
  throw Error('Not supported toolbar control type: ' + controlType);
39018
39097
  }
39019
39098
  };
39099
+ Toolbar.buttonID = 0;
39020
39100
  return Toolbar;
39021
39101
  }(component_Component));
39022
39102