@carbon/charts-vue 1.1.0 → 1.3.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.
package/charts-vue.umd.js CHANGED
@@ -11296,9 +11296,7 @@ var CSS_VERIFIER_ELEMENT_CLASSNAME = 'DONT_STYLE_ME_css_styles_verifier';
11296
11296
  var dom_utils_DOMUtils = /** @class */ (function (_super) {
11297
11297
  __extends(DOMUtils, _super);
11298
11298
  function DOMUtils(model, services) {
11299
- var _this = _super.call(this, model, services) || this;
11300
- _this.chartID = Math.floor((1 + Math.random()) * 0x1000000000000).toString(16);
11301
- return _this;
11299
+ return _super.call(this, model, services) || this;
11302
11300
  }
11303
11301
  DOMUtils.getHTMLElementSize = function (element) {
11304
11302
  return {
@@ -11434,6 +11432,8 @@ var dom_utils_DOMUtils = /** @class */ (function (_super) {
11434
11432
  DOMUtils.prototype.init = function () {
11435
11433
  // Add width & height to the chart holder if necessary, and add a classname
11436
11434
  this.styleHolderElement();
11435
+ // Initialize chart ID
11436
+ this.initializeID();
11437
11437
  this.addMainContainer();
11438
11438
  this.verifyCSSStylesBeingApplied();
11439
11439
  if (this.model.getOptions().resizable) {
@@ -11448,12 +11448,16 @@ var dom_utils_DOMUtils = /** @class */ (function (_super) {
11448
11448
  DOMUtils.prototype.generateElementIDString = function (originalID) {
11449
11449
  return "chart-" + this.chartID + "-" + originalID;
11450
11450
  };
11451
+ DOMUtils.prototype.initializeID = function () {
11452
+ this.chartID = Math.floor((1 + Math.random()) * 0x1000000000000).toString(16);
11453
+ };
11451
11454
  DOMUtils.prototype.addMainContainer = function () {
11452
11455
  var options = this.model.getOptions();
11453
11456
  var chartsprefix = tools_Tools.getProperty(options, 'style', 'prefix');
11454
11457
  var mainContainer = src_select(this.getHolder())
11455
11458
  .append('div')
11456
11459
  .classed(carbonPrefix + "--" + chartsprefix + "--chart-wrapper", true)
11460
+ .attr('id', "chart-" + this.getChartID())
11457
11461
  .style('height', '100%')
11458
11462
  .style('width', '100%');
11459
11463
  mainContainer.append('g').attr('class', CSS_VERIFIER_ELEMENT_CLASSNAME);
@@ -25765,6 +25769,8 @@ var bar_grouped_GroupedBar = /** @class */ (function (_super) {
25765
25769
  _this.type = 'grouped-bar';
25766
25770
  _this.renderType = RenderTypes.SVG;
25767
25771
  _this.padding = 5;
25772
+ // A factor to normalize padding between bars regardless of bar group density.
25773
+ _this.defaultStepFactor = 70;
25768
25774
  // Highlight elements that match the hovered legend item
25769
25775
  _this.handleLegendOnHover = function (event) {
25770
25776
  var hoveredElement = event.detail.hoveredElement;
@@ -25884,7 +25890,7 @@ var bar_grouped_GroupedBar = /** @class */ (function (_super) {
25884
25890
  });
25885
25891
  })
25886
25892
  .style('fill', function (d) { return _this.model.getFillColor(d[groupMapsTo]); })
25887
- .attr('d', function (d) {
25893
+ .attr('d', function (d, i) {
25888
25894
  /*
25889
25895
  * Orientation support for horizontal/vertical bar charts
25890
25896
  * Determine coordinates needed for a vertical set of paths
@@ -25898,8 +25904,11 @@ var bar_grouped_GroupedBar = /** @class */ (function (_super) {
25898
25904
  var rangeAxis = _this.services.cartesianScales.getRangeAxisPosition({ datum: d });
25899
25905
  var y0 = _this.services.cartesianScales.getValueThroughAxisPosition(rangeAxis, 0);
25900
25906
  var y1 = _this.services.cartesianScales.getRangeValue(d);
25901
- // don't show if part of bar is out of zoom domain
25902
- if (_this.isOutsideZoomedDomain(x0, x1)) {
25907
+ // don't show if part of bar is out of zoom domain - test zoom on bar pos, not group
25908
+ var zoomx0 = _this.services.cartesianScales.getDomainValue(d, i) -
25909
+ barWidth / 2;
25910
+ var zoomx1 = zoomx0 + barWidth;
25911
+ if (_this.isOutsideZoomedDomain(zoomx0, zoomx1)) {
25903
25912
  return;
25904
25913
  }
25905
25914
  return tools_Tools.generateSVGPathString({ x0: x0, x1: x1, y0: y0, y1: y1 }, _this.services.cartesianScales.getOrientation());
@@ -25984,7 +25993,7 @@ var bar_grouped_GroupedBar = /** @class */ (function (_super) {
25984
25993
  var displayData = this.model.getDisplayData(this.configs.groups);
25985
25994
  return displayData.filter(function (datum) {
25986
25995
  var domainIdentifier = _this.services.cartesianScales.getDomainIdentifier(datum);
25987
- return datum[domainIdentifier] === label;
25996
+ return datum[domainIdentifier].toString() === label;
25988
25997
  });
25989
25998
  };
25990
25999
  GroupedBar.prototype.getGroupWidth = function () {
@@ -25992,13 +26001,29 @@ var bar_grouped_GroupedBar = /** @class */ (function (_super) {
25992
26001
  var totalGroupPadding = this.getTotalGroupPadding();
25993
26002
  return this.getBarWidth() * activeData.length + totalGroupPadding;
25994
26003
  };
26004
+ GroupedBar.prototype.getDomainScaleStep = function () {
26005
+ var domainScale = this.services.cartesianScales.getDomainScale();
26006
+ var activeData = this.model.getGroupedData(this.configs.groups);
26007
+ var step = this.defaultStepFactor;
26008
+ if (typeof domainScale.step === 'function') {
26009
+ step = domainScale.step();
26010
+ }
26011
+ else if (activeData.length > 0) {
26012
+ // as a fallback use distance between first bars of adjacent bar groups
26013
+ var ref = activeData.find(function (d) { var _a; return ((_a = d.data) === null || _a === void 0 ? void 0 : _a.length) > 1; });
26014
+ if (ref) {
26015
+ var domainIdentifier = this.services.cartesianScales.getDomainIdentifier(ref.data[0]);
26016
+ step = Math.abs(domainScale(ref.data[1][domainIdentifier]) - domainScale(ref.data[0][domainIdentifier]));
26017
+ }
26018
+ }
26019
+ return step;
26020
+ };
25995
26021
  GroupedBar.prototype.getTotalGroupPadding = function () {
25996
26022
  var activeData = this.model.getGroupedData(this.configs.groups);
25997
26023
  if (activeData.length === 1) {
25998
26024
  return 0;
25999
26025
  }
26000
- var domainScale = this.services.cartesianScales.getDomainScale();
26001
- var padding = Math.min(5, 5 * (domainScale.step() / 70));
26026
+ var padding = Math.min(5, 5 * (this.getDomainScaleStep() / this.defaultStepFactor));
26002
26027
  return padding * (activeData.length - 1);
26003
26028
  };
26004
26029
  // Gets the correct width for bars based on options & configurations
@@ -26017,8 +26042,7 @@ var bar_grouped_GroupedBar = /** @class */ (function (_super) {
26017
26042
  var activeData = this.model.getGroupedData(this.configs.groups);
26018
26043
  var numOfActiveDataGroups = activeData.length;
26019
26044
  var totalGroupPadding = this.getTotalGroupPadding();
26020
- var domainScale = this.services.cartesianScales.getDomainScale();
26021
- return Math.min(providedMaxWidth, (domainScale.step() - totalGroupPadding) / numOfActiveDataGroups);
26045
+ return Math.min(providedMaxWidth, (this.getDomainScaleStep() - totalGroupPadding) / numOfActiveDataGroups);
26022
26046
  };
26023
26047
  GroupedBar.prototype.setGroupScale = function () {
26024
26048
  var activeData = this.model.getActiveDataGroupNames(this.configs.groups);
@@ -39634,7 +39658,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
39634
39658
  Toolbar.prototype.render = function (animate) {
39635
39659
  var _this = this;
39636
39660
  if (animate === void 0) { animate = true; }
39637
- var container = this.getComponentContainer().attr('role', 'toolbar');
39661
+ var container = this.getComponentContainer()
39662
+ .attr('role', 'toolbar')
39663
+ .attr('aria-label', "chart-" + this.services.domUtils.getChartID() + " toolbar");
39638
39664
  var isDataLoading = tools_Tools.getProperty(this.getOptions(), 'data', 'loading');
39639
39665
  if (isDataLoading) {
39640
39666
  container.html('');