@carbon/charts-vue 0.51.4 → 0.52.3

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.52.3](https://github.com/carbon-design-system/carbon-charts/compare/v0.52.2...v0.52.3) (2021-11-22)
7
+
8
+ **Note:** Version bump only for package @carbon/charts-vue
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.52.2](https://github.com/carbon-design-system/carbon-charts/compare/v0.52.1...v0.52.2) (2021-11-19)
15
+
16
+ **Note:** Version bump only for package @carbon/charts-vue
17
+
18
+
19
+
20
+
21
+
22
+ ## [0.52.1](https://github.com/carbon-design-system/carbon-charts/compare/v0.52.0...v0.52.1) (2021-11-19)
23
+
24
+ **Note:** Version bump only for package @carbon/charts-vue
25
+
26
+
27
+
28
+
29
+
30
+ # [0.52.0](https://github.com/carbon-design-system/carbon-charts/compare/v0.51.4...v0.52.0) (2021-11-18)
31
+
32
+ **Note:** Version bump only for package @carbon/charts-vue
33
+
34
+
35
+
36
+
37
+
6
38
  ## [0.51.4](https://github.com/carbon-design-system/carbon-charts/compare/v0.51.3...v0.51.4) (2021-11-16)
7
39
 
8
40
  **Note:** Version bump only for package @carbon/charts-vue
@@ -1071,6 +1071,7 @@ var meter = {
1071
1071
  },
1072
1072
  total: {
1073
1073
  paddingLeft: 36,
1074
+ paddingRight: 24,
1074
1075
  },
1075
1076
  height: {
1076
1077
  default: 8,
@@ -10104,8 +10105,12 @@ var Service = /** @class */ (function () {
10104
10105
  this.services = services;
10105
10106
  this.init();
10106
10107
  }
10107
- Service.prototype.init = function () { };
10108
- Service.prototype.update = function () { };
10108
+ Service.prototype.init = function () {
10109
+ // do nothing.
10110
+ };
10111
+ Service.prototype.update = function () {
10112
+ // do nothing.
10113
+ };
10109
10114
  // Used to pass down information to the components
10110
10115
  Service.prototype.setModel = function (newObj) {
10111
10116
  this.model = newObj;
@@ -11699,12 +11704,12 @@ var Files = /** @class */ (function (_super) {
11699
11704
  function Files(model, services) {
11700
11705
  return _super.call(this, model, services) || this;
11701
11706
  }
11702
- Files.prototype.downloadCSV = function (content, filename, mimeType) {
11707
+ Files.prototype.downloadCSV = function (content, filename) {
11703
11708
  var anchor = document.createElement('a');
11704
- mimeType = 'text/csv;encoding:utf-8';
11705
- if (navigator.msSaveBlob) {
11709
+ var mimeType = 'text/csv;encoding:utf-8';
11710
+ if (navigator['msSaveBlob']) {
11706
11711
  // Internet Explorer 10
11707
- navigator.msSaveBlob(new Blob([content], {
11712
+ navigator['msSaveBlob'](new Blob([content], {
11708
11713
  type: mimeType,
11709
11714
  }), filename);
11710
11715
  }
@@ -17785,12 +17790,16 @@ var component_Component = /** @class */ (function () {
17785
17790
  this.setParent(src_select(this.services.domUtils.getMainContainer()));
17786
17791
  }
17787
17792
  }
17788
- Component.prototype.init = function () { };
17793
+ Component.prototype.init = function () {
17794
+ // do nothing.
17795
+ };
17789
17796
  Component.prototype.render = function (animate) {
17790
17797
  if (animate === void 0) { animate = true; }
17791
17798
  console.error('render() method is not implemented');
17792
17799
  };
17793
- Component.prototype.destroy = function () { };
17800
+ Component.prototype.destroy = function () {
17801
+ // do nothing.
17802
+ };
17794
17803
  // Used to pass down information to the components
17795
17804
  Component.prototype.setModel = function (newObj) {
17796
17805
  this.model = newObj;
@@ -20040,21 +20049,16 @@ var essentials_modal_Modal = /** @class */ (function (_super) {
20040
20049
  var modalInstance = modal.create(_this.modal.node());
20041
20050
  modalInstance.show();
20042
20051
  };
20043
- _this.handleHideModal = function () { };
20044
20052
  _this.init();
20045
20053
  return _this;
20046
20054
  }
20047
20055
  Modal.prototype.addEventListeners = function () {
20048
20056
  // listen to show-modal Custom Events to render the modal
20049
20057
  this.services.events.addEventListener(Events.Modal.SHOW, this.handleShowModal);
20050
- // listen to hide-modal Custom Events to hide the modal
20051
- this.services.events.addEventListener(Events.Modal.HIDE, this.handleHideModal);
20052
20058
  };
20053
20059
  Modal.prototype.removeEventListeners = function () {
20054
20060
  // remove show-modal Custom Events
20055
20061
  this.services.events.removeEventListener(Events.Modal.SHOW, this.handleShowModal);
20056
- // remove hide-modal Custom Events
20057
- this.services.events.removeEventListener(Events.Modal.HIDE, this.handleHideModal);
20058
20062
  };
20059
20063
  Modal.prototype.getModalHTML = function () {
20060
20064
  var options = this.model.getOptions();
@@ -23269,9 +23273,9 @@ var title_meter_MeterTitle = /** @class */ (function (_super) {
23269
23273
  title.exit().remove();
23270
23274
  // appends the associated percentage after title
23271
23275
  this.appendPercentage();
23272
- // if status ranges are provided (custom or default), display indicator
23273
- this.displayStatus();
23274
23276
  }
23277
+ // if status ranges are provided (custom or default), display indicator
23278
+ this.displayStatus();
23275
23279
  // get the max width of a title (with consideration for the status/percentage)
23276
23280
  var maxWidth = this.getMaxTitleWidth();
23277
23281
  var titleElement = dom_utils_DOMUtils.appendOrSelect(svg, 'text.meter-title');
@@ -23342,7 +23346,7 @@ var title_meter_MeterTitle = /** @class */ (function (_super) {
23342
23346
  var totalString = totalFormatter !== null
23343
23347
  ? totalFormatter(totalValue)
23344
23348
  : total + " " + unit + " total";
23345
- var containerBounds = dom_utils_DOMUtils.getSVGElementSize(this.services.domUtils.getMainContainer(), { useAttrs: true });
23349
+ var containerBounds = dom_utils_DOMUtils.getHTMLElementSize(this.services.domUtils.getMainContainer());
23346
23350
  // need to check if the width is 0, and try to use the parent attribute
23347
23351
  // this can happen if the chart is toggled on/off and the height is 0 for the parent, it wont validateDimensions
23348
23352
  var containerWidth = containerBounds.width
@@ -23356,7 +23360,10 @@ var title_meter_MeterTitle = /** @class */ (function (_super) {
23356
23360
  .append('text')
23357
23361
  .classed('proportional-meter-total', true)
23358
23362
  .merge(title)
23359
- .attr('x', containerWidth)
23363
+ // Position the total text -24 pixels to add spacing between text and status icon (if status exists)
23364
+ .attr('x', this.model.getStatus()
23365
+ ? containerWidth - meter.total.paddingRight
23366
+ : containerWidth)
23360
23367
  .attr('y', '1em')
23361
23368
  .attr('text-anchor', 'end')
23362
23369
  .text(function (d) { return d; });
@@ -25584,7 +25591,7 @@ var bar_stacked_StackedBar = /** @class */ (function (_super) {
25584
25591
  y1 += d[1] === 0 ? 2 : 1;
25585
25592
  }
25586
25593
  else {
25587
- y1 -= d[1] === 0 ? 1 : 1;
25594
+ y1 -= 1;
25588
25595
  }
25589
25596
  }
25590
25597
  else if (!barIsNegative) {
@@ -34133,6 +34140,7 @@ var alluvial_Alluvial = /** @class */ (function (_super) {
34133
34140
  var _this = _super !== null && _super.apply(this, arguments) || this;
34134
34141
  _this.type = 'alluvial';
34135
34142
  _this.renderType = RenderTypes.SVG;
34143
+ _this.gradient_id = 'gradient-id-' + Math.floor(Math.random() * 99999999999);
34136
34144
  return _this;
34137
34145
  }
34138
34146
  Alluvial.prototype.render = function (animate) {
@@ -34152,6 +34160,8 @@ var alluvial_Alluvial = /** @class */ (function (_super) {
34152
34160
  }
34153
34161
  var options = this.model.getOptions();
34154
34162
  var data = this.model.getDisplayData();
34163
+ // Is gradient enabled or not
34164
+ var isGradientAllowed = tools_Tools.getProperty(this.getOptions(), 'color', 'gradient', 'enabled');
34155
34165
  // Set the custom node padding if provided
34156
34166
  var nodePadding = alluvial.minNodePadding;
34157
34167
  if (options.alluvial.nodePadding > alluvial.minNodePadding) {
@@ -34222,11 +34232,45 @@ var alluvial_Alluvial = /** @class */ (function (_super) {
34222
34232
  return x;
34223
34233
  });
34224
34234
  // Draws the links (Waves)
34225
- svg.append('g')
34235
+ var links = svg
34236
+ .append('g')
34226
34237
  .attr('fill', 'none')
34227
34238
  .selectAll('g')
34228
- .data(this.graph.links)
34229
- .join('path')
34239
+ .data(this.graph.links);
34240
+ // Exit so we can have multiple appends in group
34241
+ links.exit().remove();
34242
+ // Add gradient if requsted
34243
+ if (isGradientAllowed) {
34244
+ var scale_1 = tools_Tools.getProperty(this.getOptions(), 'color', 'scale');
34245
+ if (scale_1) {
34246
+ links
34247
+ .enter()
34248
+ .append('linearGradient')
34249
+ .attr('id', function (d) { return _this.gradient_id + "-link-" + d.index; })
34250
+ .attr('gradientUnits', 'userSpaceOnUse')
34251
+ .call(function (gradient) {
34252
+ return gradient
34253
+ .append('stop')
34254
+ .attr('offset', '0%')
34255
+ .attr('stop-color', function (d) {
34256
+ return scale_1[d.source.name];
34257
+ });
34258
+ })
34259
+ .call(function (gradient) {
34260
+ return gradient
34261
+ .append('stop')
34262
+ .attr('offset', '100%')
34263
+ .attr('stop-color', function (d) {
34264
+ return scale_1[d.target.name];
34265
+ });
34266
+ });
34267
+ }
34268
+ // Exit so path can be appended to the group
34269
+ links.exit().remove();
34270
+ }
34271
+ links
34272
+ .enter()
34273
+ .append('path')
34230
34274
  .classed('link', true)
34231
34275
  .attr('d', sankeyLinkHorizontal())
34232
34276
  .attr('id', function (d) {
@@ -34247,7 +34291,12 @@ var alluvial_Alluvial = /** @class */ (function (_super) {
34247
34291
  originalClassName: 'link',
34248
34292
  });
34249
34293
  })
34250
- .style('stroke', function (d) { return _this.model.getFillColor(d.source.name); })
34294
+ .style('stroke', function (d) {
34295
+ if (isGradientAllowed) {
34296
+ return "url(#" + _this.gradient_id + "-link-" + d.index + ")";
34297
+ }
34298
+ return _this.model.getFillColor(d.source.name);
34299
+ })
34251
34300
  .attr('stroke-width', function (d) { return Math.max(1, d.width); })
34252
34301
  .style('stroke-opacity', alluvial.opacity.default)
34253
34302
  .attr('aria-label', function (d) {
@@ -39732,6 +39781,7 @@ var chart_Chart = /** @class */ (function () {
39732
39781
  canvasZoom: canvas_zoom_CanvasZoom,
39733
39782
  };
39734
39783
  this.model = new model_ChartModel(this.services);
39784
+ // do nothing.
39735
39785
  }
39736
39786
  // Contains the code that uses properties that are overridable by the super-class
39737
39787
  Chart.prototype.init = function (holder, chartConfigs) {
@@ -41499,9 +41549,18 @@ var meter_MeterChartModel = /** @class */ (function (_super) {
41499
41549
  */
41500
41550
  MeterChartModel.prototype.getStatus = function () {
41501
41551
  var options = this.getOptions();
41502
- var dataValue = tools_Tools.getProperty(this.getDisplayData(), 0, 'value');
41552
+ var dataValues = tools_Tools.getProperty(this.getDisplayData());
41553
+ var totalValue = (dataValues
41554
+ ? dataValues.reduce(function (previous, current) {
41555
+ return { value: previous.value + current.value };
41556
+ })
41557
+ : 0).value;
41503
41558
  // use max value if the percentage is bigger than 100%
41504
- var boundedValue = dataValue > 100 ? 100 : dataValue;
41559
+ var boundedValue = tools_Tools.getProperty(options, 'meter', 'proportional')
41560
+ ? totalValue
41561
+ : totalValue > 100
41562
+ ? 100
41563
+ : totalValue;
41505
41564
  // user needs to supply ranges
41506
41565
  var allRanges = tools_Tools.getProperty(options, 'meter', 'status', 'ranges');
41507
41566
  if (allRanges) {
@@ -41658,7 +41717,9 @@ var meter_Meter = /** @class */ (function (_super) {
41658
41717
  // rect with the value binded
41659
41718
  var valued = svg.selectAll('rect.value').data(stackedData);
41660
41719
  // if user provided a color for the bar, we dont want to attach a status class
41661
- var className = status != null && !self.model.isUserProvidedColorScaleValid()
41720
+ var className = status != null &&
41721
+ !self.model.isUserProvidedColorScaleValid() &&
41722
+ !proportional
41662
41723
  ? "value status--" + status
41663
41724
  : 'value';
41664
41725
  // draw the value bar
@@ -41704,9 +41765,7 @@ var meter_Meter = /** @class */ (function (_super) {
41704
41765
  .attr('aria-label', function (d) { return d.value; });
41705
41766
  valued.exit().remove();
41706
41767
  // draw the peak
41707
- var peakValue = proportional
41708
- ? null
41709
- : tools_Tools.getProperty(options, 'meter', 'peak');
41768
+ var peakValue = tools_Tools.getProperty(options, 'meter', 'peak');
41710
41769
  var peakData = peakValue;
41711
41770
  if (peakValue !== null) {
41712
41771
  if (peakValue > domainMax) {
@@ -41728,7 +41787,11 @@ var meter_Meter = /** @class */ (function (_super) {
41728
41787
  .attr('y1', 0)
41729
41788
  .attr('y2', function () {
41730
41789
  var userProvidedHeight = tools_Tools.getProperty(options, 'meter', 'height');
41731
- return userProvidedHeight ? userProvidedHeight : 8;
41790
+ return userProvidedHeight
41791
+ ? userProvidedHeight
41792
+ : proportional
41793
+ ? meter.height.proportional
41794
+ : meter.height.default;
41732
41795
  })
41733
41796
  .transition()
41734
41797
  .call(function (t) {