@carbon/charts-vue 0.52.1 → 0.53.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
@@ -1080,6 +1080,7 @@ var meter = {
1080
1080
  },
1081
1081
  total: {
1082
1082
  paddingLeft: 36,
1083
+ paddingRight: 24,
1083
1084
  },
1084
1085
  height: {
1085
1086
  default: 8,
@@ -23281,9 +23282,9 @@ var title_meter_MeterTitle = /** @class */ (function (_super) {
23281
23282
  title.exit().remove();
23282
23283
  // appends the associated percentage after title
23283
23284
  this.appendPercentage();
23284
- // if status ranges are provided (custom or default), display indicator
23285
- this.displayStatus();
23286
23285
  }
23286
+ // if status ranges are provided (custom or default), display indicator
23287
+ this.displayStatus();
23287
23288
  // get the max width of a title (with consideration for the status/percentage)
23288
23289
  var maxWidth = this.getMaxTitleWidth();
23289
23290
  var titleElement = dom_utils_DOMUtils.appendOrSelect(svg, 'text.meter-title');
@@ -23354,7 +23355,7 @@ var title_meter_MeterTitle = /** @class */ (function (_super) {
23354
23355
  var totalString = totalFormatter !== null
23355
23356
  ? totalFormatter(totalValue)
23356
23357
  : total + " " + unit + " total";
23357
- var containerBounds = dom_utils_DOMUtils.getSVGElementSize(this.services.domUtils.getMainContainer(), { useAttrs: true });
23358
+ var containerBounds = dom_utils_DOMUtils.getHTMLElementSize(this.services.domUtils.getMainContainer());
23358
23359
  // need to check if the width is 0, and try to use the parent attribute
23359
23360
  // this can happen if the chart is toggled on/off and the height is 0 for the parent, it wont validateDimensions
23360
23361
  var containerWidth = containerBounds.width
@@ -23368,7 +23369,10 @@ var title_meter_MeterTitle = /** @class */ (function (_super) {
23368
23369
  .append('text')
23369
23370
  .classed('proportional-meter-total', true)
23370
23371
  .merge(title)
23371
- .attr('x', containerWidth)
23372
+ // Position the total text -24 pixels to add spacing between text and status icon (if status exists)
23373
+ .attr('x', this.model.getStatus()
23374
+ ? containerWidth - meter.total.paddingRight
23375
+ : containerWidth)
23372
23376
  .attr('y', '1em')
23373
23377
  .attr('text-anchor', 'end')
23374
23378
  .text(function (d) { return d; });
@@ -34145,6 +34149,7 @@ var alluvial_Alluvial = /** @class */ (function (_super) {
34145
34149
  var _this = _super !== null && _super.apply(this, arguments) || this;
34146
34150
  _this.type = 'alluvial';
34147
34151
  _this.renderType = RenderTypes.SVG;
34152
+ _this.gradient_id = 'gradient-id-' + Math.floor(Math.random() * 99999999999);
34148
34153
  return _this;
34149
34154
  }
34150
34155
  Alluvial.prototype.render = function (animate) {
@@ -34164,6 +34169,8 @@ var alluvial_Alluvial = /** @class */ (function (_super) {
34164
34169
  }
34165
34170
  var options = this.model.getOptions();
34166
34171
  var data = this.model.getDisplayData();
34172
+ // Is gradient enabled or not
34173
+ var isGradientAllowed = tools_Tools.getProperty(this.getOptions(), 'color', 'gradient', 'enabled');
34167
34174
  // Set the custom node padding if provided
34168
34175
  var nodePadding = alluvial.minNodePadding;
34169
34176
  if (options.alluvial.nodePadding > alluvial.minNodePadding) {
@@ -34234,11 +34241,45 @@ var alluvial_Alluvial = /** @class */ (function (_super) {
34234
34241
  return x;
34235
34242
  });
34236
34243
  // Draws the links (Waves)
34237
- svg.append('g')
34244
+ var links = svg
34245
+ .append('g')
34238
34246
  .attr('fill', 'none')
34239
34247
  .selectAll('g')
34240
- .data(this.graph.links)
34241
- .join('path')
34248
+ .data(this.graph.links);
34249
+ // Exit so we can have multiple appends in group
34250
+ links.exit().remove();
34251
+ // Add gradient if requsted
34252
+ if (isGradientAllowed) {
34253
+ var scale_1 = tools_Tools.getProperty(this.getOptions(), 'color', 'scale');
34254
+ if (scale_1) {
34255
+ links
34256
+ .enter()
34257
+ .append('linearGradient')
34258
+ .attr('id', function (d) { return _this.gradient_id + "-link-" + d.index; })
34259
+ .attr('gradientUnits', 'userSpaceOnUse')
34260
+ .call(function (gradient) {
34261
+ return gradient
34262
+ .append('stop')
34263
+ .attr('offset', '0%')
34264
+ .attr('stop-color', function (d) {
34265
+ return scale_1[d.source.name];
34266
+ });
34267
+ })
34268
+ .call(function (gradient) {
34269
+ return gradient
34270
+ .append('stop')
34271
+ .attr('offset', '100%')
34272
+ .attr('stop-color', function (d) {
34273
+ return scale_1[d.target.name];
34274
+ });
34275
+ });
34276
+ }
34277
+ // Exit so path can be appended to the group
34278
+ links.exit().remove();
34279
+ }
34280
+ links
34281
+ .enter()
34282
+ .append('path')
34242
34283
  .classed('link', true)
34243
34284
  .attr('d', sankeyLinkHorizontal())
34244
34285
  .attr('id', function (d) {
@@ -34259,7 +34300,12 @@ var alluvial_Alluvial = /** @class */ (function (_super) {
34259
34300
  originalClassName: 'link',
34260
34301
  });
34261
34302
  })
34262
- .style('stroke', function (d) { return _this.model.getFillColor(d.source.name); })
34303
+ .style('stroke', function (d) {
34304
+ if (isGradientAllowed) {
34305
+ return "url(#" + _this.gradient_id + "-link-" + d.index + ")";
34306
+ }
34307
+ return _this.model.getFillColor(d.source.name);
34308
+ })
34263
34309
  .attr('stroke-width', function (d) { return Math.max(1, d.width); })
34264
34310
  .style('stroke-opacity', alluvial.opacity.default)
34265
34311
  .attr('aria-label', function (d) {
@@ -39216,7 +39262,7 @@ var zoom_bar_ZoomBar = /** @class */ (function (_super) {
39216
39262
  }, { skipUpdate: true });
39217
39263
  }
39218
39264
  else if (newInitialZoomDomain === null &&
39219
- oldInitialZoomDomain != null) {
39265
+ oldInitialZoomDomain !== null) {
39220
39266
  // if newInitialZoomDomain is set to null (when oldInitialZoomDomain is not null)
39221
39267
  // save initialZoomDomain and reset zoom domain to default domain
39222
39268
  this.model.set({
@@ -41512,9 +41558,18 @@ var meter_MeterChartModel = /** @class */ (function (_super) {
41512
41558
  */
41513
41559
  MeterChartModel.prototype.getStatus = function () {
41514
41560
  var options = this.getOptions();
41515
- var dataValue = tools_Tools.getProperty(this.getDisplayData(), 0, 'value');
41561
+ var dataValues = tools_Tools.getProperty(this.getDisplayData());
41562
+ var totalValue = (dataValues
41563
+ ? dataValues.reduce(function (previous, current) {
41564
+ return { value: previous.value + current.value };
41565
+ })
41566
+ : 0).value;
41516
41567
  // use max value if the percentage is bigger than 100%
41517
- var boundedValue = dataValue > 100 ? 100 : dataValue;
41568
+ var boundedValue = tools_Tools.getProperty(options, 'meter', 'proportional')
41569
+ ? totalValue
41570
+ : totalValue > 100
41571
+ ? 100
41572
+ : totalValue;
41518
41573
  // user needs to supply ranges
41519
41574
  var allRanges = tools_Tools.getProperty(options, 'meter', 'status', 'ranges');
41520
41575
  if (allRanges) {
@@ -41671,7 +41726,9 @@ var meter_Meter = /** @class */ (function (_super) {
41671
41726
  // rect with the value binded
41672
41727
  var valued = svg.selectAll('rect.value').data(stackedData);
41673
41728
  // if user provided a color for the bar, we dont want to attach a status class
41674
- var className = status != null && !self.model.isUserProvidedColorScaleValid()
41729
+ var className = status != null &&
41730
+ !self.model.isUserProvidedColorScaleValid() &&
41731
+ !proportional
41675
41732
  ? "value status--" + status
41676
41733
  : 'value';
41677
41734
  // draw the value bar
@@ -41717,9 +41774,7 @@ var meter_Meter = /** @class */ (function (_super) {
41717
41774
  .attr('aria-label', function (d) { return d.value; });
41718
41775
  valued.exit().remove();
41719
41776
  // draw the peak
41720
- var peakValue = proportional
41721
- ? null
41722
- : tools_Tools.getProperty(options, 'meter', 'peak');
41777
+ var peakValue = tools_Tools.getProperty(options, 'meter', 'peak');
41723
41778
  var peakData = peakValue;
41724
41779
  if (peakValue !== null) {
41725
41780
  if (peakValue > domainMax) {
@@ -41741,7 +41796,11 @@ var meter_Meter = /** @class */ (function (_super) {
41741
41796
  .attr('y1', 0)
41742
41797
  .attr('y2', function () {
41743
41798
  var userProvidedHeight = tools_Tools.getProperty(options, 'meter', 'height');
41744
- return userProvidedHeight ? userProvidedHeight : 8;
41799
+ return userProvidedHeight
41800
+ ? userProvidedHeight
41801
+ : proportional
41802
+ ? meter.height.proportional
41803
+ : meter.height.default;
41745
41804
  })
41746
41805
  .transition()
41747
41806
  .call(function (t) {