@carbon/charts-vue 0.52.1 → 0.52.2

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
@@ -34145,6 +34145,7 @@ var alluvial_Alluvial = /** @class */ (function (_super) {
34145
34145
  var _this = _super !== null && _super.apply(this, arguments) || this;
34146
34146
  _this.type = 'alluvial';
34147
34147
  _this.renderType = RenderTypes.SVG;
34148
+ _this.gradient_id = 'gradient-id-' + Math.floor(Math.random() * 99999999999);
34148
34149
  return _this;
34149
34150
  }
34150
34151
  Alluvial.prototype.render = function (animate) {
@@ -34164,6 +34165,8 @@ var alluvial_Alluvial = /** @class */ (function (_super) {
34164
34165
  }
34165
34166
  var options = this.model.getOptions();
34166
34167
  var data = this.model.getDisplayData();
34168
+ // Is gradient enabled or not
34169
+ var isGradientAllowed = tools_Tools.getProperty(this.getOptions(), 'color', 'gradient', 'enabled');
34167
34170
  // Set the custom node padding if provided
34168
34171
  var nodePadding = alluvial.minNodePadding;
34169
34172
  if (options.alluvial.nodePadding > alluvial.minNodePadding) {
@@ -34234,11 +34237,45 @@ var alluvial_Alluvial = /** @class */ (function (_super) {
34234
34237
  return x;
34235
34238
  });
34236
34239
  // Draws the links (Waves)
34237
- svg.append('g')
34240
+ var links = svg
34241
+ .append('g')
34238
34242
  .attr('fill', 'none')
34239
34243
  .selectAll('g')
34240
- .data(this.graph.links)
34241
- .join('path')
34244
+ .data(this.graph.links);
34245
+ // Exit so we can have multiple appends in group
34246
+ links.exit().remove();
34247
+ // Add gradient if requsted
34248
+ if (isGradientAllowed) {
34249
+ var scale_1 = tools_Tools.getProperty(this.getOptions(), 'color', 'scale');
34250
+ if (scale_1) {
34251
+ links
34252
+ .enter()
34253
+ .append('linearGradient')
34254
+ .attr('id', function (d) { return _this.gradient_id + "-link-" + d.index; })
34255
+ .attr('gradientUnits', 'userSpaceOnUse')
34256
+ .call(function (gradient) {
34257
+ return gradient
34258
+ .append('stop')
34259
+ .attr('offset', '0%')
34260
+ .attr('stop-color', function (d) {
34261
+ return scale_1[d.source.name];
34262
+ });
34263
+ })
34264
+ .call(function (gradient) {
34265
+ return gradient
34266
+ .append('stop')
34267
+ .attr('offset', '100%')
34268
+ .attr('stop-color', function (d) {
34269
+ return scale_1[d.target.name];
34270
+ });
34271
+ });
34272
+ }
34273
+ // Exit so path can be appended to the group
34274
+ links.exit().remove();
34275
+ }
34276
+ links
34277
+ .enter()
34278
+ .append('path')
34242
34279
  .classed('link', true)
34243
34280
  .attr('d', sankeyLinkHorizontal())
34244
34281
  .attr('id', function (d) {
@@ -34259,7 +34296,12 @@ var alluvial_Alluvial = /** @class */ (function (_super) {
34259
34296
  originalClassName: 'link',
34260
34297
  });
34261
34298
  })
34262
- .style('stroke', function (d) { return _this.model.getFillColor(d.source.name); })
34299
+ .style('stroke', function (d) {
34300
+ if (isGradientAllowed) {
34301
+ return "url(#" + _this.gradient_id + "-link-" + d.index + ")";
34302
+ }
34303
+ return _this.model.getFillColor(d.source.name);
34304
+ })
34263
34305
  .attr('stroke-width', function (d) { return Math.max(1, d.width); })
34264
34306
  .style('stroke-opacity', alluvial.opacity.default)
34265
34307
  .attr('aria-label', function (d) {