@carbon/charts-vue 0.54.11 → 0.54.14

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
+ ## [0.54.14](https://github.com/carbon-design-system/carbon-charts/compare/v0.54.13...v0.54.14) (2022-03-14)
7
+
8
+ **Note:** Version bump only for package @carbon/charts-vue
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.54.13](https://github.com/carbon-design-system/carbon-charts/compare/v0.54.12...v0.54.13) (2022-03-09)
15
+
16
+ **Note:** Version bump only for package @carbon/charts-vue
17
+
18
+
19
+
20
+
21
+
22
+ ## [0.54.12](https://github.com/carbon-design-system/carbon-charts/compare/v0.54.11...v0.54.12) (2022-02-04)
23
+
24
+ **Note:** Version bump only for package @carbon/charts-vue
25
+
26
+
27
+
28
+
29
+
6
30
  ## [0.54.11](https://github.com/carbon-design-system/carbon-charts/compare/v0.54.10...v0.54.11) (2022-02-02)
7
31
 
8
32
  **Note:** Version bump only for package @carbon/charts-vue
@@ -325,7 +325,7 @@ __webpack_require__.d(configuration_namespaceObject, "circlePack", function() {
325
325
  __webpack_require__.d(configuration_namespaceObject, "color", function() { return configuration_non_customizable_color; });
326
326
  __webpack_require__.d(configuration_namespaceObject, "boxplot", function() { return boxplot; });
327
327
  __webpack_require__.d(configuration_namespaceObject, "histogram", function() { return configuration_non_customizable_histogram; });
328
- __webpack_require__.d(configuration_namespaceObject, "legend", function() { return configuration_non_customizable_legend; });
328
+ __webpack_require__.d(configuration_namespaceObject, "legend", function() { return legend; });
329
329
  __webpack_require__.d(configuration_namespaceObject, "lines", function() { return configuration_non_customizable_lines; });
330
330
  __webpack_require__.d(configuration_namespaceObject, "meter", function() { return meter; });
331
331
  __webpack_require__.d(configuration_namespaceObject, "pie", function() { return configuration_non_customizable_pie; });
@@ -1042,7 +1042,7 @@ var boxplot = {
1042
1042
  var configuration_non_customizable_histogram = {
1043
1043
  defaultBins: 10,
1044
1044
  };
1045
- var configuration_non_customizable_legend = {
1045
+ var legend = {
1046
1046
  items: {
1047
1047
  status: {
1048
1048
  ACTIVE: 1,
@@ -9563,7 +9563,7 @@ var model_ChartModel = /** @class */ (function () {
9563
9563
  if (!this.get('data')) {
9564
9564
  return null;
9565
9565
  }
9566
- var ACTIVE = configuration_non_customizable_legend.items.status.ACTIVE;
9566
+ var ACTIVE = legend.items.status.ACTIVE;
9567
9567
  var dataGroups = this.getDataGroups(groups);
9568
9568
  var groupMapsTo = this.getOptions().data.groupMapsTo;
9569
9569
  var allDataFromDomain = this.getAllDataFromDomain(groups);
@@ -9608,7 +9608,7 @@ var model_ChartModel = /** @class */ (function () {
9608
9608
  return this.get('dataGroups');
9609
9609
  };
9610
9610
  ChartModel.prototype.getActiveDataGroups = function (groups) {
9611
- var ACTIVE = configuration_non_customizable_legend.items.status.ACTIVE;
9611
+ var ACTIVE = legend.items.status.ACTIVE;
9612
9612
  return this.getDataGroups(groups).filter(function (dataGroup) { return dataGroup.status === ACTIVE; });
9613
9613
  };
9614
9614
  ChartModel.prototype.getDataGroupNames = function (groups) {
@@ -9880,7 +9880,7 @@ var model_ChartModel = /** @class */ (function () {
9880
9880
  * Data labels
9881
9881
  */
9882
9882
  ChartModel.prototype.toggleDataLabel = function (changedLabel) {
9883
- var _a = configuration_non_customizable_legend.items.status, ACTIVE = _a.ACTIVE, DISABLED = _a.DISABLED;
9883
+ var _a = legend.items.status, ACTIVE = _a.ACTIVE, DISABLED = _a.DISABLED;
9884
9884
  var dataGroups = this.getDataGroups();
9885
9885
  var hasDeactivatedItems = dataGroups.some(function (group) { return group.status === DISABLED; });
9886
9886
  var activeItems = dataGroups.filter(function (group) { return group.status === ACTIVE; });
@@ -10091,7 +10091,7 @@ var model_ChartModel = /** @class */ (function () {
10091
10091
  };
10092
10092
  ChartModel.prototype.generateDataGroups = function (data) {
10093
10093
  var groupMapsTo = this.getOptions().data.groupMapsTo;
10094
- var _a = configuration_non_customizable_legend.items.status, ACTIVE = _a.ACTIVE, DISABLED = _a.DISABLED;
10094
+ var _a = legend.items.status, ACTIVE = _a.ACTIVE, DISABLED = _a.DISABLED;
10095
10095
  var options = this.getOptions();
10096
10096
  var uniqueDataGroups = tools_Tools.removeArrayDuplicates(data.map(function (datum) { return datum[groupMapsTo]; }));
10097
10097
  // check if selectedGroups can be applied to chart with current data groups
@@ -18001,7 +18001,7 @@ var legend_Legend = /** @class */ (function (_super) {
18001
18001
  var legendOrientation = tools_Tools.getProperty(options, 'legend', 'orientation');
18002
18002
  var dataGroups = this.model.getDataGroups();
18003
18003
  // Check if there are disabled legend items
18004
- var DISABLED = configuration_non_customizable_legend.items.status.DISABLED;
18004
+ var DISABLED = legend.items.status.DISABLED;
18005
18005
  var hasDeactivatedItems = dataGroups.some(function (dataGroup) { return dataGroup.status === DISABLED; });
18006
18006
  var userProvidedOrder = tools_Tools.getProperty(legendOptions, 'order');
18007
18007
  var svg = this.getComponentContainer()
@@ -18025,11 +18025,11 @@ var legend_Legend = /** @class */ (function (_super) {
18025
18025
  addedLegendItems
18026
18026
  .merge(svg.selectAll('div.legend-item'))
18027
18027
  .classed('active', function (d, i) {
18028
- return d.status === configuration_non_customizable_legend.items.status.ACTIVE;
18028
+ return d.status === legend.items.status.ACTIVE;
18029
18029
  });
18030
18030
  var legendClickable = tools_Tools.getProperty(this.getOptions(), 'legend', 'clickable');
18031
18031
  svg.classed('clickable', legendClickable && dataGroups.length > 1);
18032
- var checkboxRadius = configuration_non_customizable_legend.checkbox.radius;
18032
+ var checkboxRadius = legend.checkbox.radius;
18033
18033
  var addedCheckboxes = addedLegendItems
18034
18034
  .append('div')
18035
18035
  .classed('checkbox', true);
@@ -18042,7 +18042,7 @@ var legend_Legend = /** @class */ (function (_super) {
18042
18042
  })
18043
18043
  .attr('aria-checked', function (_a) {
18044
18044
  var status = _a.status;
18045
- return status === configuration_non_customizable_legend.items.status.ACTIVE;
18045
+ return status === legend.items.status.ACTIVE;
18046
18046
  })
18047
18047
  .attr('width', checkboxRadius * 2)
18048
18048
  .attr('height', checkboxRadius * 2)
@@ -18054,13 +18054,13 @@ var legend_Legend = /** @class */ (function (_super) {
18054
18054
  });
18055
18055
  })
18056
18056
  .style('background', function (d) {
18057
- return d.status === configuration_non_customizable_legend.items.status.ACTIVE
18057
+ return d.status === legend.items.status.ACTIVE
18058
18058
  ? _this.model.getFillColor(d.name) ||
18059
18059
  _this.model.getStrokeColor(d.name)
18060
18060
  : null;
18061
18061
  })
18062
18062
  .classed('active', function (d, i) {
18063
- return d.status === configuration_non_customizable_legend.items.status.ACTIVE;
18063
+ return d.status === legend.items.status.ACTIVE;
18064
18064
  });
18065
18065
  var addedCheckIcons = addedCheckboxes
18066
18066
  .append('svg')
@@ -18145,7 +18145,7 @@ var legend_Legend = /** @class */ (function (_super) {
18145
18145
  return dataGroups;
18146
18146
  };
18147
18147
  Legend.prototype.addAdditionalItem = function (additionalItem, itemConfig, indexOfItem) {
18148
- var _a = configuration_non_customizable_legend.area, width = _a.width, height = _a.height;
18148
+ var _a = legend.area, width = _a.width, height = _a.height;
18149
18149
  if (itemConfig.type === LegendItemType.RADIUS) {
18150
18150
  // Circular icon
18151
18151
  additionalItem
@@ -18158,7 +18158,7 @@ var legend_Legend = /** @class */ (function (_super) {
18158
18158
  .style('height', height + "px");
18159
18159
  }
18160
18160
  if (itemConfig.type === LegendItemType.RADIUS) {
18161
- var _b = configuration_non_customizable_legend.radius, iconData = _b.iconData, fill = _b.fill, stroke = _b.stroke;
18161
+ var _b = legend.radius, iconData = _b.iconData, fill = _b.fill, stroke = _b.stroke;
18162
18162
  var circleEnter = additionalItem
18163
18163
  .attr('fill', 'none')
18164
18164
  .selectAll('circle')
@@ -18176,7 +18176,7 @@ var legend_Legend = /** @class */ (function (_super) {
18176
18176
  .style('stroke', itemConfig.stroke ? itemConfig.stroke : stroke);
18177
18177
  }
18178
18178
  else if (itemConfig.type === LegendItemType.LINE) {
18179
- var lineConfig = configuration_non_customizable_legend.line;
18179
+ var lineConfig = legend.line;
18180
18180
  if (additionalItem.select('line.line').empty()) {
18181
18181
  additionalItem
18182
18182
  .append('line')
@@ -18203,13 +18203,13 @@ var legend_Legend = /** @class */ (function (_super) {
18203
18203
  .attr('width', width)
18204
18204
  .attr('height', height)
18205
18205
  .style('fill', indexOfItem > 3 && !itemConfig.fill
18206
- ? configuration_non_customizable_legend.area.fill
18206
+ ? legend.area.fill
18207
18207
  : itemConfig.fill)
18208
18208
  .style('stroke', itemConfig.stroke);
18209
18209
  }
18210
18210
  }
18211
18211
  else if (itemConfig.type === LegendItemType.SIZE) {
18212
- var _c = configuration_non_customizable_legend.size, iconData = _c.iconData, fill = _c.fill, stroke = _c.stroke;
18212
+ var _c = legend.size, iconData = _c.iconData, fill = _c.fill, stroke = _c.stroke;
18213
18213
  var sizeEnter = additionalItem
18214
18214
  .attr('fill', 'none')
18215
18215
  .attr('role', Roles.IMG)
@@ -18228,7 +18228,7 @@ var legend_Legend = /** @class */ (function (_super) {
18228
18228
  .style('stroke-width', 1);
18229
18229
  }
18230
18230
  else if (itemConfig.type === LegendItemType.QUARTILE) {
18231
- var iconData = configuration_non_customizable_legend.quartile.iconData;
18231
+ var iconData = legend.quartile.iconData;
18232
18232
  var quartileEnter = additionalItem
18233
18233
  .selectAll('rect')
18234
18234
  .attr('role', Roles.IMG)
@@ -18601,16 +18601,17 @@ var color_scale_legend_ColorScaleLegend = /** @class */ (function (_super) {
18601
18601
  _this.type = 'color-legend';
18602
18602
  _this.renderType = RenderTypes.SVG;
18603
18603
  _this.gradient_id = 'gradient-id-' + Math.floor(Math.random() * 99999999999);
18604
- _this.handleAxisComplete = function (event) {
18604
+ // Position legend after axis have rendered
18605
+ _this.handleAxisCompleteEvent = function (event) {
18605
18606
  var svg = _this.getComponentContainer();
18606
18607
  var width = dom_utils_DOMUtils.getSVGElementSize(svg, {
18607
18608
  useAttrs: true,
18608
18609
  }).width;
18609
18610
  var isDataLoading = tools_Tools.getProperty(_this.getOptions(), 'data', 'loading');
18610
- if (width > configuration_non_customizable_legend.color.barWidth && !isDataLoading) {
18611
+ if (width > legend.color.barWidth && !isDataLoading) {
18611
18612
  var title = tools_Tools.getProperty(_this.getOptions(), 'heatmap', 'colorLegend', 'title');
18612
18613
  var cartesianScales = _this.services.cartesianScales;
18613
- // Get available chart area
18614
+ // Get axis width & start/end positions
18614
18615
  var mainXScale = cartesianScales.getMainXScale();
18615
18616
  var xDimensions = mainXScale.range();
18616
18617
  // Align legend with the axis
@@ -18618,9 +18619,9 @@ var color_scale_legend_ColorScaleLegend = /** @class */ (function (_super) {
18618
18619
  svg.select('g.legend').attr('transform', "translate(" + xDimensions[0] + ", 0)");
18619
18620
  if (title) {
18620
18621
  var textWidth = dom_utils_DOMUtils.getSVGElementSize(svg.select('g.legend-title').select('text'), { useBBox: true }).width;
18621
- // -9 since LEFT y-axis labels are moved towards the left by 9 by d3
18622
+ // D3 moves the LEFT y-axis labels by 9
18622
18623
  var availableSpace = xDimensions[0] - textWidth - 9;
18623
- // If space is available align the the label with the axis labels
18624
+ // If space is available, align the label with the axis labels
18624
18625
  if (availableSpace > 1) {
18625
18626
  svg.select('g.legend-title').attr('transform', "translate(" + availableSpace + ", 0)");
18626
18627
  }
@@ -18633,45 +18634,50 @@ var color_scale_legend_ColorScaleLegend = /** @class */ (function (_super) {
18633
18634
  }
18634
18635
  }
18635
18636
  }
18637
+ else {
18638
+ // Default state
18639
+ svg.select('g.legend-title').attr('transform', "translate(0, 0)");
18640
+ }
18636
18641
  };
18637
18642
  return _this;
18638
18643
  }
18639
18644
  ColorScaleLegend.prototype.init = function () {
18640
18645
  var eventsFragment = this.services.events;
18641
18646
  // Highlight correct circle on legend item hovers
18642
- eventsFragment.addEventListener(Events.Axis.RENDER_COMPLETE, this.handleAxisComplete);
18647
+ eventsFragment.addEventListener(Events.Axis.RENDER_COMPLETE, this.handleAxisCompleteEvent);
18643
18648
  };
18644
18649
  ColorScaleLegend.prototype.render = function (animate) {
18645
18650
  if (animate === void 0) { animate = false; }
18646
18651
  var options = this.getOptions();
18652
+ var svg = this.getComponentContainer();
18653
+ var width = dom_utils_DOMUtils.getSVGElementSize(svg, {
18654
+ useAttrs: true,
18655
+ }).width;
18647
18656
  var customColors = tools_Tools.getProperty(options, 'color', 'gradient', 'colors');
18648
18657
  var colorScaleType = tools_Tools.getProperty(options, 'heatmap', 'colorLegend', 'type');
18649
18658
  var colorPairingOption = tools_Tools.getProperty(options, 'color', 'pairing', 'option');
18650
18659
  var title = tools_Tools.getProperty(options, 'heatmap', 'colorLegend', 'title');
18651
- var customColorsEnabled = !tools_Tools.isEmpty(customColors);
18652
- var domain = this.model.getValueDomain();
18653
- var svg = this.getComponentContainer();
18654
18660
  // Clear DOM if loading
18655
18661
  var isDataLoading = tools_Tools.getProperty(this.getOptions(), 'data', 'loading');
18656
18662
  if (isDataLoading) {
18657
18663
  svg.html('');
18658
18664
  return;
18659
18665
  }
18660
- var legend = dom_utils_DOMUtils.appendOrSelect(svg, 'g.legend');
18661
- var axis = dom_utils_DOMUtils.appendOrSelect(legend, 'g.legend-axis');
18662
- var width = dom_utils_DOMUtils.getSVGElementSize(svg, {
18663
- useAttrs: true,
18664
- }).width;
18665
- var barWidth = configuration_non_customizable_legend.color.barWidth;
18666
- if (width <= configuration_non_customizable_legend.color.barWidth) {
18667
- barWidth = width;
18668
- }
18666
+ var customColorsEnabled = !tools_Tools.isEmpty(customColors);
18667
+ var domain = this.model.getValueDomain();
18668
+ var useDefaultBarWidth = !(width <= legend.color.barWidth);
18669
+ var barWidth = useDefaultBarWidth
18670
+ ? legend.color.barWidth
18671
+ : width;
18672
+ var legendGroupElement = dom_utils_DOMUtils.appendOrSelect(svg, 'g.legend');
18673
+ var axisElement = dom_utils_DOMUtils.appendOrSelect(legendGroupElement, 'g.legend-axis');
18674
+ // Render title if it exists
18669
18675
  if (title) {
18670
18676
  var legendTitleGroup = dom_utils_DOMUtils.appendOrSelect(svg, 'g.legend-title');
18671
18677
  var legendTitle = dom_utils_DOMUtils.appendOrSelect(legendTitleGroup, 'text');
18672
18678
  legendTitle.text(title).attr('dy', '0.7em');
18673
18679
  // Move the legend down by 16 pixels to display legend text on top
18674
- legend.attr('transform', "translate(0, 16)");
18680
+ legendGroupElement.attr('transform', "translate(0, 16)");
18675
18681
  }
18676
18682
  // If domain consists of negative and positive values, use diverging palettes
18677
18683
  var colorScheme = domain[0] < 0 && domain[1] > 0 ? 'diverge' : 'mono';
@@ -18701,107 +18707,95 @@ var color_scale_legend_ColorScaleLegend = /** @class */ (function (_super) {
18701
18707
  // Use custom colors
18702
18708
  colorPairing = customColors;
18703
18709
  }
18704
- if (colorScaleType === ColorLegendType.LINEAR) {
18705
- var stopLengthPercentage_1 = 100 / (colorPairing.length - 1);
18706
- // Generate the gradient
18707
- var linearGradient = dom_utils_DOMUtils.appendOrSelect(legend, 'linearGradient');
18708
- linearGradient
18709
- .attr('id', this.gradient_id + "-legend")
18710
- .selectAll('stop')
18711
- .data(colorPairing)
18712
- .enter()
18713
- .append('stop')
18714
- .attr('offset', function (_, i) { return i * stopLengthPercentage_1 + "%"; })
18715
- .attr('class', function (_, i) { return colorPairing[i]; })
18716
- .attr('stop-color', function (d) { return d; });
18717
- // Create the legend container
18718
- var rectangle = dom_utils_DOMUtils.appendOrSelect(legend, 'rect');
18719
- rectangle
18720
- .attr('width', barWidth)
18721
- .attr('height', configuration_non_customizable_legend.color.barHeight)
18722
- .style('fill', "url(#" + this.gradient_id + "-legend)");
18723
- // Create scale & ticks
18724
- var linearScale = linear_linear()
18725
- .domain(domain)
18726
- .range([0, barWidth]);
18727
- domain.splice(1, 0, (domain[0] + domain[1]) / 2);
18728
- var xAxis = axisBottom(linearScale)
18729
- .tickSize(0)
18730
- .tickValues(domain);
18731
- // Align axes at the bottom of the rectangle and delete the domain line
18732
- axis.attr('transform', "translate(0," + configuration_non_customizable_legend.color.axisYTranslation + ")").call(xAxis);
18733
- // Remove domain
18734
- axis.select('.domain').remove();
18735
- // Align text to fit in container
18736
- axis.style('text-anchor', 'start');
18737
- }
18738
- else if (colorScaleType === ColorLegendType.QUANTIZE) {
18739
- // Generate equal chunks between range to act as ticks
18740
- var interpolator = src_round(domain[0], domain[1]);
18741
- var quant_1 = quantize(interpolator, colorPairing.length);
18742
- // If divergent && non-custom color, remove 0/white from being displayed
18743
- if (!customColorsEnabled && colorScheme === 'diverge') {
18744
- colorPairing.splice(colorPairing.length / 2, 1);
18745
- }
18746
- var colorScaleBand_1 = band()
18747
- .domain(colorPairing)
18748
- .range([0, barWidth]);
18749
- // Render the quantized rectangles
18750
- var rectangle = dom_utils_DOMUtils.appendOrSelect(legend, 'g.quantized-rect');
18751
- rectangle
18752
- .selectAll('rect')
18753
- .data(colorScaleBand_1.domain())
18754
- .join('rect')
18755
- .attr('x', function (d) { return colorScaleBand_1(d); })
18756
- .attr('y', 0)
18757
- .attr('width', Math.max(0, colorScaleBand_1.bandwidth()) - 1)
18758
- .attr('height', configuration_non_customizable_legend.color.barHeight)
18759
- .attr('class', function (d) { return d; })
18760
- .attr('fill', function (d) { return d; });
18761
- var xAxis = axisBottom(colorScaleBand_1)
18762
- .tickSize(0)
18763
- .tickValues(colorPairing)
18764
- .tickFormat(function (_, i) {
18765
- // Display every other tick to create space
18766
- if (!customColorsEnabled &&
18767
- ((i + 1) % 2 === 0 || i === colorPairing.length - 1)) {
18768
- return null;
18769
- }
18770
- // Use the quant interpolators as ticks
18771
- return quant_1[i].toString();
18772
- });
18773
- // Align axis to match bandwidth start after initial (white)
18774
- var axisTranslation = colorScaleBand_1.bandwidth() / 2;
18775
- axis.attr('transform', "translate(" + (!customColorsEnabled && colorScheme === 'diverge' ? '-' : '') + axisTranslation + ", " + configuration_non_customizable_legend.color.axisYTranslation + ")").call(xAxis);
18776
- // Append the last tick
18777
- var firstTick = axis.select('g.tick').clone(true);
18778
- firstTick
18779
- .attr('transform', "translate(" + (barWidth +
18780
- (!customColorsEnabled && colorScheme === 'diverge'
18781
- ? axisTranslation
18782
- : -axisTranslation)) + ", 0)")
18783
- .classed('final-tick', true)
18784
- .select('text')
18785
- .text(quant_1[quant_1.length - 1]);
18786
- axis.enter().append(firstTick.node());
18787
- axis.select('.domain').remove();
18788
- }
18789
- else {
18790
- throw Error('Entered color legend type is not supported.');
18791
- }
18792
- // Translate last axis tick if barWidth equals chart width
18793
- if (width <= configuration_non_customizable_legend.color.barWidth) {
18794
- var lastTick = axis.select('g.tick:last-of-type text');
18795
- var width_1 = dom_utils_DOMUtils.getSVGElementSize(lastTick, {
18796
- useBBox: true,
18797
- }).width;
18798
- lastTick.attr('x', "-" + width_1);
18799
- }
18710
+ // Generate equal chunks between range to act as ticks
18711
+ var interpolator = d3_interpolate_src_number(domain[0], domain[1]);
18712
+ var quant = quantize(interpolator, 3);
18713
+ // Create scale & ticks
18714
+ var linearScale = linear_linear().domain(domain).range([0, barWidth]);
18715
+ var legendAxis = axisBottom(linearScale)
18716
+ .tickSize(0)
18717
+ .tickValues(quant);
18718
+ switch (colorScaleType) {
18719
+ case ColorLegendType.LINEAR:
18720
+ this.drawLinear(colorPairing, legendGroupElement, barWidth);
18721
+ break;
18722
+ case ColorLegendType.QUANTIZE:
18723
+ var rangeStart = this.drawQuantize(colorPairing, colorScheme, customColorsEnabled, legendGroupElement, barWidth);
18724
+ // Using range provided by drawQuantize for alignment purposes
18725
+ linearScale.range([rangeStart, barWidth]);
18726
+ break;
18727
+ default:
18728
+ throw Error('Entered color legend type is not supported.');
18729
+ }
18730
+ // Align axes at the bottom of the rectangle and delete the domain line
18731
+ axisElement
18732
+ .attr('transform', "translate(0," + legend.color.axisYTranslation + ")")
18733
+ .call(legendAxis);
18734
+ // Remove auto generated axis bottom line
18735
+ axisElement.select('.domain').remove();
18736
+ // Translate first/last axis tick if barWidth equals chart width
18737
+ // Ensures text is not clipped when default bar width (300px) is not used
18738
+ axisElement
18739
+ .select('g.tick:last-of-type text')
18740
+ .style('text-anchor', useDefaultBarWidth ? 'middle' : 'end');
18741
+ axisElement
18742
+ .select('g.tick:first-of-type text')
18743
+ .style('text-anchor', useDefaultBarWidth ? 'middle' : 'start');
18744
+ };
18745
+ // Renders gradient legend
18746
+ ColorScaleLegend.prototype.drawLinear = function (colorPairing, legendGroupElement, barWidth) {
18747
+ var stopLengthPercentage = 100 / (colorPairing.length - 1);
18748
+ // Generate the gradient
18749
+ var linearGradient = dom_utils_DOMUtils.appendOrSelect(legendGroupElement, 'linearGradient');
18750
+ // Rendering gradient
18751
+ linearGradient
18752
+ .attr('id', this.gradient_id + "-legend")
18753
+ .selectAll('stop')
18754
+ .data(colorPairing)
18755
+ .enter()
18756
+ .append('stop')
18757
+ .attr('offset', function (_, i) { return i * stopLengthPercentage + "%"; })
18758
+ .attr('class', function (_, i) { return colorPairing[i]; })
18759
+ .attr('stop-color', function (d) { return d; });
18760
+ // Create the legend container
18761
+ var rectangle = dom_utils_DOMUtils.appendOrSelect(legendGroupElement, 'rect');
18762
+ rectangle
18763
+ .attr('width', barWidth)
18764
+ .attr('height', legend.color.barHeight)
18765
+ .style('fill', "url(#" + this.gradient_id + "-legend)");
18766
+ };
18767
+ /**
18768
+ * Renders quantized legend
18769
+ * @returns number (range start)
18770
+ */
18771
+ ColorScaleLegend.prototype.drawQuantize = function (colorPairing, colorScheme, customColorsEnabled, legendGroupElement, barWidth) {
18772
+ // If divergent && non-custom color, remove 0/white from being displayed
18773
+ if (!customColorsEnabled && colorScheme === 'diverge') {
18774
+ colorPairing.splice(colorPairing.length / 2, 1);
18775
+ }
18776
+ var colorScaleBand = band()
18777
+ .domain(colorPairing)
18778
+ .range([0, barWidth]);
18779
+ // Render the quantized rectangles
18780
+ var rectangle = dom_utils_DOMUtils.appendOrSelect(legendGroupElement, 'g.quantized-rect');
18781
+ rectangle
18782
+ .selectAll('rect')
18783
+ .data(colorScaleBand.domain())
18784
+ .join('rect')
18785
+ .attr('x', function (d) { return colorScaleBand(d); })
18786
+ .attr('y', 0)
18787
+ .attr('width', Math.max(0, colorScaleBand.bandwidth() - 1))
18788
+ .attr('height', legend.color.barHeight)
18789
+ .attr('class', function (d) { return d; })
18790
+ .attr('fill', function (d) { return d; });
18791
+ return (!customColorsEnabled && colorScheme) === 'mono'
18792
+ ? colorScaleBand.bandwidth() - 1
18793
+ : 0;
18800
18794
  };
18801
18795
  ColorScaleLegend.prototype.destroy = function () {
18802
18796
  // Remove legend listeners
18803
18797
  var eventsFragment = this.services.events;
18804
- eventsFragment.removeEventListener(Events.Axis.RENDER_COMPLETE, this.handleAxisComplete);
18798
+ eventsFragment.removeEventListener(Events.Axis.RENDER_COMPLETE, this.handleAxisCompleteEvent);
18805
18799
  };
18806
18800
  return ColorScaleLegend;
18807
18801
  }(legend_Legend));
@@ -31111,26 +31105,6 @@ function constantZero() {
31111
31105
  return treemap;
31112
31106
  });
31113
31107
 
31114
- // CONCATENATED MODULE: /home/runner/work/carbon-charts/carbon-charts/node_modules/d3-array/src/sum.js
31115
- function sum_sum(values, valueof) {
31116
- let sum = 0;
31117
- if (valueof === undefined) {
31118
- for (let value of values) {
31119
- if (value = +value) {
31120
- sum += value;
31121
- }
31122
- }
31123
- } else {
31124
- let index = -1;
31125
- for (let value of values) {
31126
- if (value = +valueof(value, ++index, values)) {
31127
- sum += value;
31128
- }
31129
- }
31130
- }
31131
- return sum;
31132
- }
31133
-
31134
31108
  // CONCATENATED MODULE: /home/runner/work/carbon-charts/carbon-charts/node_modules/@carbon/colors/es/index.js
31135
31109
  /**
31136
31110
  * Copyright IBM Corp. 2018, 2018
@@ -31756,7 +31730,6 @@ var treemap_extends = (undefined && undefined.__extends) || (function () {
31756
31730
 
31757
31731
 
31758
31732
 
31759
-
31760
31733
  // Carbon colors
31761
31734
 
31762
31735
  var findColorShade = function (hex) {
@@ -31850,9 +31823,6 @@ var treemap_Treemap = /** @class */ (function (_super) {
31850
31823
  })
31851
31824
  .sum(function (d) { return d.value; })
31852
31825
  .sort(function (a, b) { return b.value - a.value; });
31853
- var total = sum_sum(allData, function (d) {
31854
- return sum_sum(d.children, function (child) { return child.value; });
31855
- });
31856
31826
  var root = src_treemap()
31857
31827
  .size([width, height])
31858
31828
  .paddingInner(1)
@@ -33957,7 +33927,7 @@ var wordcloud_WordCloud = /** @class */ (function (_super) {
33957
33927
 
33958
33928
  //# sourceMappingURL=../../../src/components/graphs/wordcloud.js.map
33959
33929
  // CONCATENATED MODULE: /home/runner/work/carbon-charts/carbon-charts/node_modules/d3-sankey/node_modules/d3-array/src/sum.js
33960
- function src_sum_sum(values, valueof) {
33930
+ function sum_sum(values, valueof) {
33961
33931
  let sum = 0;
33962
33932
  if (valueof === undefined) {
33963
33933
  for (let value of values) {
@@ -34204,7 +34174,7 @@ function Sankey() {
34204
34174
  function computeNodeValues({nodes}) {
34205
34175
  for (const node of nodes) {
34206
34176
  node.value = node.fixedValue === undefined
34207
- ? Math.max(src_sum_sum(node.sourceLinks, sankey_value), src_sum_sum(node.targetLinks, sankey_value))
34177
+ ? Math.max(sum_sum(node.sourceLinks, sankey_value), sum_sum(node.targetLinks, sankey_value))
34208
34178
  : node.fixedValue;
34209
34179
  }
34210
34180
  }
@@ -34264,7 +34234,7 @@ function Sankey() {
34264
34234
  }
34265
34235
 
34266
34236
  function initializeNodeBreadths(columns) {
34267
- const ky = src_min_min(columns, c => (y1 - y0 - (c.length - 1) * py) / src_sum_sum(c, sankey_value));
34237
+ const ky = src_min_min(columns, c => (y1 - y0 - (c.length - 1) * py) / sum_sum(c, sankey_value));
34268
34238
  for (const nodes of columns) {
34269
34239
  let y = y0;
34270
34240
  for (const node of nodes) {
@@ -43521,10 +43491,11 @@ var model_treemap_extends = (undefined && undefined.__extends) || (function () {
43521
43491
  })();
43522
43492
  // Internal Imports
43523
43493
 
43494
+
43524
43495
  /**
43525
43496
  * The treemap chart model layer
43526
43497
  */
43527
- var TreemapChartModel = /** @class */ (function (_super) {
43498
+ var treemap_TreemapChartModel = /** @class */ (function (_super) {
43528
43499
  model_treemap_extends(TreemapChartModel, _super);
43529
43500
  function TreemapChartModel(services) {
43530
43501
  return _super.call(this, services) || this;
@@ -43533,9 +43504,15 @@ var TreemapChartModel = /** @class */ (function (_super) {
43533
43504
  var displayData = this.getDisplayData();
43534
43505
  var result = [['Child', 'Group', 'Value']];
43535
43506
  displayData.forEach(function (datum) {
43536
- datum.children.forEach(function (child) {
43537
- result.push([child.name, datum.name, child.value]);
43538
- });
43507
+ if (Array.isArray(datum.children)) {
43508
+ datum.children.forEach(function (child) {
43509
+ result.push([child.name, datum.name, child.value]);
43510
+ });
43511
+ }
43512
+ else if (tools_Tools.getProperty(datum.name) !== null &&
43513
+ tools_Tools.getProperty(datum.value)) {
43514
+ result.push(["–", datum.name, datum.value]);
43515
+ }
43539
43516
  });
43540
43517
  return result;
43541
43518
  };
@@ -43568,7 +43545,7 @@ var treemap_TreemapChart = /** @class */ (function (_super) {
43568
43545
  charts_treemap_extends(TreemapChart, _super);
43569
43546
  function TreemapChart(holder, chartConfigs) {
43570
43547
  var _this = _super.call(this, holder, chartConfigs) || this;
43571
- _this.model = new TreemapChartModel(_this.services);
43548
+ _this.model = new treemap_TreemapChartModel(_this.services);
43572
43549
  // Merge the default options for this chart
43573
43550
  // With the user provided options
43574
43551
  _this.model.setOptions(tools_Tools.mergeDefaultChartOptions(configuration_options.treemapChart, chartConfigs.options));
@@ -44137,28 +44114,16 @@ var heatmap_HeatmapModel = /** @class */ (function (_super) {
44137
44114
  * @returns Array consisting of smallest and largest values in data
44138
44115
  */
44139
44116
  HeatmapModel.prototype.getValueDomain = function () {
44140
- var data = this.getDisplayData().map(function (element) { return element.value; });
44141
- var limits = src_extent(data);
44142
- var domain = [];
44143
- // Round extent values to the nearest multiple of 10
44144
- // Axis rounds values to multiples of 2, 5, and 10s.
44145
- limits.forEach(function (number, index) {
44146
- var value = Number(number);
44147
- if (index === 0 && value >= 0) {
44148
- value = 0;
44149
- }
44150
- else if (value % 10 === 0 || value === 0) {
44151
- value;
44152
- }
44153
- else if (value < 0) {
44154
- value = Math.floor(value / 10) * 10;
44155
- }
44156
- else {
44157
- value = Math.ceil(value / 10) * 10;
44158
- }
44159
- domain.push(value);
44160
- });
44161
- // Ensure the median of the range is 0
44117
+ var limits = src_extent(this.getDisplayData(), function (d) { return d.value; });
44118
+ var domain = linear_linear()
44119
+ .domain(limits)
44120
+ .nice()
44121
+ .domain();
44122
+ // Ensuring limits start at 0 to make scale look more `nicer`
44123
+ if (domain[0] > 0) {
44124
+ domain[0] = 0;
44125
+ }
44126
+ // Ensure the median of the range is 0 if domain extends into both negative & positive
44162
44127
  if (domain[0] < 0 && domain[1] > 0) {
44163
44128
  if (Math.abs(domain[0]) > domain[1]) {
44164
44129
  domain[1] = Math.abs(domain[0]);
@@ -44172,7 +44137,7 @@ var heatmap_HeatmapModel = /** @class */ (function (_super) {
44172
44137
  /**
44173
44138
  * @override
44174
44139
  * @param value
44175
- * @returns
44140
+ * @returns string
44176
44141
  */
44177
44142
  HeatmapModel.prototype.getFillColor = function (value) {
44178
44143
  return this._colorScale(value);