@carbon/charts-vue 1.2.0 → 1.3.1

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,30 @@
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
+ ## [1.3.1](https://github.com/carbon-design-system/carbon-charts/compare/v1.3.0...v1.3.1) (2022-06-28)
7
+
8
+ **Note:** Version bump only for package @carbon/charts-vue
9
+
10
+
11
+
12
+
13
+
14
+ # [1.3.0](https://github.com/carbon-design-system/carbon-charts/compare/v1.2.1...v1.3.0) (2022-06-28)
15
+
16
+ **Note:** Version bump only for package @carbon/charts-vue
17
+
18
+
19
+
20
+
21
+
22
+ ## [1.2.1](https://github.com/carbon-design-system/carbon-charts/compare/v1.2.0...v1.2.1) (2022-06-14)
23
+
24
+ **Note:** Version bump only for package @carbon/charts-vue
25
+
26
+
27
+
28
+
29
+
6
30
  # [1.2.0](https://github.com/carbon-design-system/carbon-charts/compare/v1.1.0...v1.2.0) (2022-06-13)
7
31
 
8
32
  **Note:** Version bump only for package @carbon/charts-vue
@@ -11287,9 +11287,7 @@ var CSS_VERIFIER_ELEMENT_CLASSNAME = 'DONT_STYLE_ME_css_styles_verifier';
11287
11287
  var dom_utils_DOMUtils = /** @class */ (function (_super) {
11288
11288
  __extends(DOMUtils, _super);
11289
11289
  function DOMUtils(model, services) {
11290
- var _this = _super.call(this, model, services) || this;
11291
- _this.chartID = Math.floor((1 + Math.random()) * 0x1000000000000).toString(16);
11292
- return _this;
11290
+ return _super.call(this, model, services) || this;
11293
11291
  }
11294
11292
  DOMUtils.getHTMLElementSize = function (element) {
11295
11293
  return {
@@ -11425,6 +11423,8 @@ var dom_utils_DOMUtils = /** @class */ (function (_super) {
11425
11423
  DOMUtils.prototype.init = function () {
11426
11424
  // Add width & height to the chart holder if necessary, and add a classname
11427
11425
  this.styleHolderElement();
11426
+ // Initialize chart ID
11427
+ this.initializeID();
11428
11428
  this.addMainContainer();
11429
11429
  this.verifyCSSStylesBeingApplied();
11430
11430
  if (this.model.getOptions().resizable) {
@@ -11439,12 +11439,16 @@ var dom_utils_DOMUtils = /** @class */ (function (_super) {
11439
11439
  DOMUtils.prototype.generateElementIDString = function (originalID) {
11440
11440
  return "chart-" + this.chartID + "-" + originalID;
11441
11441
  };
11442
+ DOMUtils.prototype.initializeID = function () {
11443
+ this.chartID = Math.floor((1 + Math.random()) * 0x1000000000000).toString(16);
11444
+ };
11442
11445
  DOMUtils.prototype.addMainContainer = function () {
11443
11446
  var options = this.model.getOptions();
11444
11447
  var chartsprefix = tools_Tools.getProperty(options, 'style', 'prefix');
11445
11448
  var mainContainer = src_select(this.getHolder())
11446
11449
  .append('div')
11447
11450
  .classed(carbonPrefix + "--" + chartsprefix + "--chart-wrapper", true)
11451
+ .attr('id', "chart-" + this.getChartID())
11448
11452
  .style('height', '100%')
11449
11453
  .style('width', '100%');
11450
11454
  mainContainer.append('g').attr('class', CSS_VERIFIER_ELEMENT_CLASSNAME);
@@ -25756,6 +25760,8 @@ var bar_grouped_GroupedBar = /** @class */ (function (_super) {
25756
25760
  _this.type = 'grouped-bar';
25757
25761
  _this.renderType = RenderTypes.SVG;
25758
25762
  _this.padding = 5;
25763
+ // A factor to normalize padding between bars regardless of bar group density.
25764
+ _this.defaultStepFactor = 70;
25759
25765
  // Highlight elements that match the hovered legend item
25760
25766
  _this.handleLegendOnHover = function (event) {
25761
25767
  var hoveredElement = event.detail.hoveredElement;
@@ -25875,7 +25881,7 @@ var bar_grouped_GroupedBar = /** @class */ (function (_super) {
25875
25881
  });
25876
25882
  })
25877
25883
  .style('fill', function (d) { return _this.model.getFillColor(d[groupMapsTo]); })
25878
- .attr('d', function (d) {
25884
+ .attr('d', function (d, i) {
25879
25885
  /*
25880
25886
  * Orientation support for horizontal/vertical bar charts
25881
25887
  * Determine coordinates needed for a vertical set of paths
@@ -25889,8 +25895,11 @@ var bar_grouped_GroupedBar = /** @class */ (function (_super) {
25889
25895
  var rangeAxis = _this.services.cartesianScales.getRangeAxisPosition({ datum: d });
25890
25896
  var y0 = _this.services.cartesianScales.getValueThroughAxisPosition(rangeAxis, 0);
25891
25897
  var y1 = _this.services.cartesianScales.getRangeValue(d);
25892
- // don't show if part of bar is out of zoom domain
25893
- if (_this.isOutsideZoomedDomain(x0, x1)) {
25898
+ // don't show if part of bar is out of zoom domain - test zoom on bar pos, not group
25899
+ var zoomx0 = _this.services.cartesianScales.getDomainValue(d, i) -
25900
+ barWidth / 2;
25901
+ var zoomx1 = zoomx0 + barWidth;
25902
+ if (_this.isOutsideZoomedDomain(zoomx0, zoomx1)) {
25894
25903
  return;
25895
25904
  }
25896
25905
  return tools_Tools.generateSVGPathString({ x0: x0, x1: x1, y0: y0, y1: y1 }, _this.services.cartesianScales.getOrientation());
@@ -25975,7 +25984,7 @@ var bar_grouped_GroupedBar = /** @class */ (function (_super) {
25975
25984
  var displayData = this.model.getDisplayData(this.configs.groups);
25976
25985
  return displayData.filter(function (datum) {
25977
25986
  var domainIdentifier = _this.services.cartesianScales.getDomainIdentifier(datum);
25978
- return datum[domainIdentifier] === label;
25987
+ return datum[domainIdentifier].toString() === label;
25979
25988
  });
25980
25989
  };
25981
25990
  GroupedBar.prototype.getGroupWidth = function () {
@@ -25983,13 +25992,29 @@ var bar_grouped_GroupedBar = /** @class */ (function (_super) {
25983
25992
  var totalGroupPadding = this.getTotalGroupPadding();
25984
25993
  return this.getBarWidth() * activeData.length + totalGroupPadding;
25985
25994
  };
25995
+ GroupedBar.prototype.getDomainScaleStep = function () {
25996
+ var domainScale = this.services.cartesianScales.getDomainScale();
25997
+ var activeData = this.model.getGroupedData(this.configs.groups);
25998
+ var step = this.defaultStepFactor;
25999
+ if (typeof domainScale.step === 'function') {
26000
+ step = domainScale.step();
26001
+ }
26002
+ else if (activeData.length > 0) {
26003
+ // as a fallback use distance between first bars of adjacent bar groups
26004
+ var ref = activeData.find(function (d) { var _a; return ((_a = d.data) === null || _a === void 0 ? void 0 : _a.length) > 1; });
26005
+ if (ref) {
26006
+ var domainIdentifier = this.services.cartesianScales.getDomainIdentifier(ref.data[0]);
26007
+ step = Math.abs(domainScale(ref.data[1][domainIdentifier]) - domainScale(ref.data[0][domainIdentifier]));
26008
+ }
26009
+ }
26010
+ return step;
26011
+ };
25986
26012
  GroupedBar.prototype.getTotalGroupPadding = function () {
25987
26013
  var activeData = this.model.getGroupedData(this.configs.groups);
25988
26014
  if (activeData.length === 1) {
25989
26015
  return 0;
25990
26016
  }
25991
- var domainScale = this.services.cartesianScales.getDomainScale();
25992
- var padding = Math.min(5, 5 * (domainScale.step() / 70));
26017
+ var padding = Math.min(5, 5 * (this.getDomainScaleStep() / this.defaultStepFactor));
25993
26018
  return padding * (activeData.length - 1);
25994
26019
  };
25995
26020
  // Gets the correct width for bars based on options & configurations
@@ -26008,8 +26033,7 @@ var bar_grouped_GroupedBar = /** @class */ (function (_super) {
26008
26033
  var activeData = this.model.getGroupedData(this.configs.groups);
26009
26034
  var numOfActiveDataGroups = activeData.length;
26010
26035
  var totalGroupPadding = this.getTotalGroupPadding();
26011
- var domainScale = this.services.cartesianScales.getDomainScale();
26012
- return Math.min(providedMaxWidth, (domainScale.step() - totalGroupPadding) / numOfActiveDataGroups);
26036
+ return Math.min(providedMaxWidth, (this.getDomainScaleStep() - totalGroupPadding) / numOfActiveDataGroups);
26013
26037
  };
26014
26038
  GroupedBar.prototype.setGroupScale = function () {
26015
26039
  var activeData = this.model.getActiveDataGroupNames(this.configs.groups);
@@ -36254,6 +36278,8 @@ var axis_Axis = /** @class */ (function (_super) {
36254
36278
  }
36255
36279
  lastStartPosition_1 = xTransformation;
36256
36280
  });
36281
+ // Cleanup mock text piece
36282
+ mockTextPiece.remove();
36257
36283
  }
36258
36284
  }
36259
36285
  if (shouldRotateTicks_1) {
@@ -39625,7 +39651,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
39625
39651
  Toolbar.prototype.render = function (animate) {
39626
39652
  var _this = this;
39627
39653
  if (animate === void 0) { animate = true; }
39628
- var container = this.getComponentContainer().attr('role', 'toolbar');
39654
+ var container = this.getComponentContainer()
39655
+ .attr('role', 'toolbar')
39656
+ .attr('aria-label', "chart-" + this.services.domUtils.getChartID() + " toolbar");
39629
39657
  var isDataLoading = tools_Tools.getProperty(this.getOptions(), 'data', 'loading');
39630
39658
  if (isDataLoading) {
39631
39659
  container.html('');