@carbon/charts-vue 0.54.13 → 0.55.1

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
@@ -334,7 +334,7 @@ __webpack_require__.d(configuration_namespaceObject, "circlePack", function() {
334
334
  __webpack_require__.d(configuration_namespaceObject, "color", function() { return configuration_non_customizable_color; });
335
335
  __webpack_require__.d(configuration_namespaceObject, "boxplot", function() { return boxplot; });
336
336
  __webpack_require__.d(configuration_namespaceObject, "histogram", function() { return configuration_non_customizable_histogram; });
337
- __webpack_require__.d(configuration_namespaceObject, "legend", function() { return configuration_non_customizable_legend; });
337
+ __webpack_require__.d(configuration_namespaceObject, "legend", function() { return legend; });
338
338
  __webpack_require__.d(configuration_namespaceObject, "lines", function() { return configuration_non_customizable_lines; });
339
339
  __webpack_require__.d(configuration_namespaceObject, "meter", function() { return meter; });
340
340
  __webpack_require__.d(configuration_namespaceObject, "pie", function() { return configuration_non_customizable_pie; });
@@ -1051,7 +1051,7 @@ var boxplot = {
1051
1051
  var configuration_non_customizable_histogram = {
1052
1052
  defaultBins: 10,
1053
1053
  };
1054
- var configuration_non_customizable_legend = {
1054
+ var legend = {
1055
1055
  items: {
1056
1056
  status: {
1057
1057
  ACTIVE: 1,
@@ -9572,7 +9572,7 @@ var model_ChartModel = /** @class */ (function () {
9572
9572
  if (!this.get('data')) {
9573
9573
  return null;
9574
9574
  }
9575
- var ACTIVE = configuration_non_customizable_legend.items.status.ACTIVE;
9575
+ var ACTIVE = legend.items.status.ACTIVE;
9576
9576
  var dataGroups = this.getDataGroups(groups);
9577
9577
  var groupMapsTo = this.getOptions().data.groupMapsTo;
9578
9578
  var allDataFromDomain = this.getAllDataFromDomain(groups);
@@ -9617,7 +9617,7 @@ var model_ChartModel = /** @class */ (function () {
9617
9617
  return this.get('dataGroups');
9618
9618
  };
9619
9619
  ChartModel.prototype.getActiveDataGroups = function (groups) {
9620
- var ACTIVE = configuration_non_customizable_legend.items.status.ACTIVE;
9620
+ var ACTIVE = legend.items.status.ACTIVE;
9621
9621
  return this.getDataGroups(groups).filter(function (dataGroup) { return dataGroup.status === ACTIVE; });
9622
9622
  };
9623
9623
  ChartModel.prototype.getDataGroupNames = function (groups) {
@@ -9889,7 +9889,7 @@ var model_ChartModel = /** @class */ (function () {
9889
9889
  * Data labels
9890
9890
  */
9891
9891
  ChartModel.prototype.toggleDataLabel = function (changedLabel) {
9892
- var _a = configuration_non_customizable_legend.items.status, ACTIVE = _a.ACTIVE, DISABLED = _a.DISABLED;
9892
+ var _a = legend.items.status, ACTIVE = _a.ACTIVE, DISABLED = _a.DISABLED;
9893
9893
  var dataGroups = this.getDataGroups();
9894
9894
  var hasDeactivatedItems = dataGroups.some(function (group) { return group.status === DISABLED; });
9895
9895
  var activeItems = dataGroups.filter(function (group) { return group.status === ACTIVE; });
@@ -10100,7 +10100,7 @@ var model_ChartModel = /** @class */ (function () {
10100
10100
  };
10101
10101
  ChartModel.prototype.generateDataGroups = function (data) {
10102
10102
  var groupMapsTo = this.getOptions().data.groupMapsTo;
10103
- var _a = configuration_non_customizable_legend.items.status, ACTIVE = _a.ACTIVE, DISABLED = _a.DISABLED;
10103
+ var _a = legend.items.status, ACTIVE = _a.ACTIVE, DISABLED = _a.DISABLED;
10104
10104
  var options = this.getOptions();
10105
10105
  var uniqueDataGroups = tools_Tools.removeArrayDuplicates(data.map(function (datum) { return datum[groupMapsTo]; }));
10106
10106
  // check if selectedGroups can be applied to chart with current data groups
@@ -18010,7 +18010,7 @@ var legend_Legend = /** @class */ (function (_super) {
18010
18010
  var legendOrientation = tools_Tools.getProperty(options, 'legend', 'orientation');
18011
18011
  var dataGroups = this.model.getDataGroups();
18012
18012
  // Check if there are disabled legend items
18013
- var DISABLED = configuration_non_customizable_legend.items.status.DISABLED;
18013
+ var DISABLED = legend.items.status.DISABLED;
18014
18014
  var hasDeactivatedItems = dataGroups.some(function (dataGroup) { return dataGroup.status === DISABLED; });
18015
18015
  var userProvidedOrder = tools_Tools.getProperty(legendOptions, 'order');
18016
18016
  var svg = this.getComponentContainer()
@@ -18034,11 +18034,11 @@ var legend_Legend = /** @class */ (function (_super) {
18034
18034
  addedLegendItems
18035
18035
  .merge(svg.selectAll('div.legend-item'))
18036
18036
  .classed('active', function (d, i) {
18037
- return d.status === configuration_non_customizable_legend.items.status.ACTIVE;
18037
+ return d.status === legend.items.status.ACTIVE;
18038
18038
  });
18039
18039
  var legendClickable = tools_Tools.getProperty(this.getOptions(), 'legend', 'clickable');
18040
18040
  svg.classed('clickable', legendClickable && dataGroups.length > 1);
18041
- var checkboxRadius = configuration_non_customizable_legend.checkbox.radius;
18041
+ var checkboxRadius = legend.checkbox.radius;
18042
18042
  var addedCheckboxes = addedLegendItems
18043
18043
  .append('div')
18044
18044
  .classed('checkbox', true);
@@ -18051,7 +18051,7 @@ var legend_Legend = /** @class */ (function (_super) {
18051
18051
  })
18052
18052
  .attr('aria-checked', function (_a) {
18053
18053
  var status = _a.status;
18054
- return status === configuration_non_customizable_legend.items.status.ACTIVE;
18054
+ return status === legend.items.status.ACTIVE;
18055
18055
  })
18056
18056
  .attr('width', checkboxRadius * 2)
18057
18057
  .attr('height', checkboxRadius * 2)
@@ -18063,13 +18063,13 @@ var legend_Legend = /** @class */ (function (_super) {
18063
18063
  });
18064
18064
  })
18065
18065
  .style('background', function (d) {
18066
- return d.status === configuration_non_customizable_legend.items.status.ACTIVE
18066
+ return d.status === legend.items.status.ACTIVE
18067
18067
  ? _this.model.getFillColor(d.name) ||
18068
18068
  _this.model.getStrokeColor(d.name)
18069
18069
  : null;
18070
18070
  })
18071
18071
  .classed('active', function (d, i) {
18072
- return d.status === configuration_non_customizable_legend.items.status.ACTIVE;
18072
+ return d.status === legend.items.status.ACTIVE;
18073
18073
  });
18074
18074
  var addedCheckIcons = addedCheckboxes
18075
18075
  .append('svg')
@@ -18154,7 +18154,7 @@ var legend_Legend = /** @class */ (function (_super) {
18154
18154
  return dataGroups;
18155
18155
  };
18156
18156
  Legend.prototype.addAdditionalItem = function (additionalItem, itemConfig, indexOfItem) {
18157
- var _a = configuration_non_customizable_legend.area, width = _a.width, height = _a.height;
18157
+ var _a = legend.area, width = _a.width, height = _a.height;
18158
18158
  if (itemConfig.type === LegendItemType.RADIUS) {
18159
18159
  // Circular icon
18160
18160
  additionalItem
@@ -18167,7 +18167,7 @@ var legend_Legend = /** @class */ (function (_super) {
18167
18167
  .style('height', height + "px");
18168
18168
  }
18169
18169
  if (itemConfig.type === LegendItemType.RADIUS) {
18170
- var _b = configuration_non_customizable_legend.radius, iconData = _b.iconData, fill = _b.fill, stroke = _b.stroke;
18170
+ var _b = legend.radius, iconData = _b.iconData, fill = _b.fill, stroke = _b.stroke;
18171
18171
  var circleEnter = additionalItem
18172
18172
  .attr('fill', 'none')
18173
18173
  .selectAll('circle')
@@ -18185,7 +18185,7 @@ var legend_Legend = /** @class */ (function (_super) {
18185
18185
  .style('stroke', itemConfig.stroke ? itemConfig.stroke : stroke);
18186
18186
  }
18187
18187
  else if (itemConfig.type === LegendItemType.LINE) {
18188
- var lineConfig = configuration_non_customizable_legend.line;
18188
+ var lineConfig = legend.line;
18189
18189
  if (additionalItem.select('line.line').empty()) {
18190
18190
  additionalItem
18191
18191
  .append('line')
@@ -18212,13 +18212,13 @@ var legend_Legend = /** @class */ (function (_super) {
18212
18212
  .attr('width', width)
18213
18213
  .attr('height', height)
18214
18214
  .style('fill', indexOfItem > 3 && !itemConfig.fill
18215
- ? configuration_non_customizable_legend.area.fill
18215
+ ? legend.area.fill
18216
18216
  : itemConfig.fill)
18217
18217
  .style('stroke', itemConfig.stroke);
18218
18218
  }
18219
18219
  }
18220
18220
  else if (itemConfig.type === LegendItemType.SIZE) {
18221
- var _c = configuration_non_customizable_legend.size, iconData = _c.iconData, fill = _c.fill, stroke = _c.stroke;
18221
+ var _c = legend.size, iconData = _c.iconData, fill = _c.fill, stroke = _c.stroke;
18222
18222
  var sizeEnter = additionalItem
18223
18223
  .attr('fill', 'none')
18224
18224
  .attr('role', Roles.IMG)
@@ -18237,7 +18237,7 @@ var legend_Legend = /** @class */ (function (_super) {
18237
18237
  .style('stroke-width', 1);
18238
18238
  }
18239
18239
  else if (itemConfig.type === LegendItemType.QUARTILE) {
18240
- var iconData = configuration_non_customizable_legend.quartile.iconData;
18240
+ var iconData = legend.quartile.iconData;
18241
18241
  var quartileEnter = additionalItem
18242
18242
  .selectAll('rect')
18243
18243
  .attr('role', Roles.IMG)
@@ -18610,16 +18610,17 @@ var color_scale_legend_ColorScaleLegend = /** @class */ (function (_super) {
18610
18610
  _this.type = 'color-legend';
18611
18611
  _this.renderType = RenderTypes.SVG;
18612
18612
  _this.gradient_id = 'gradient-id-' + Math.floor(Math.random() * 99999999999);
18613
- _this.handleAxisComplete = function (event) {
18613
+ // Position legend after axis have rendered
18614
+ _this.handleAxisCompleteEvent = function (event) {
18614
18615
  var svg = _this.getComponentContainer();
18615
18616
  var width = dom_utils_DOMUtils.getSVGElementSize(svg, {
18616
18617
  useAttrs: true,
18617
18618
  }).width;
18618
18619
  var isDataLoading = tools_Tools.getProperty(_this.getOptions(), 'data', 'loading');
18619
- if (width > configuration_non_customizable_legend.color.barWidth && !isDataLoading) {
18620
+ if (width > legend.color.barWidth && !isDataLoading) {
18620
18621
  var title = tools_Tools.getProperty(_this.getOptions(), 'heatmap', 'colorLegend', 'title');
18621
18622
  var cartesianScales = _this.services.cartesianScales;
18622
- // Get available chart area
18623
+ // Get axis width & start/end positions
18623
18624
  var mainXScale = cartesianScales.getMainXScale();
18624
18625
  var xDimensions = mainXScale.range();
18625
18626
  // Align legend with the axis
@@ -18627,9 +18628,9 @@ var color_scale_legend_ColorScaleLegend = /** @class */ (function (_super) {
18627
18628
  svg.select('g.legend').attr('transform', "translate(" + xDimensions[0] + ", 0)");
18628
18629
  if (title) {
18629
18630
  var textWidth = dom_utils_DOMUtils.getSVGElementSize(svg.select('g.legend-title').select('text'), { useBBox: true }).width;
18630
- // -9 since LEFT y-axis labels are moved towards the left by 9 by d3
18631
+ // D3 moves the LEFT y-axis labels by 9
18631
18632
  var availableSpace = xDimensions[0] - textWidth - 9;
18632
- // If space is available align the the label with the axis labels
18633
+ // If space is available, align the label with the axis labels
18633
18634
  if (availableSpace > 1) {
18634
18635
  svg.select('g.legend-title').attr('transform', "translate(" + availableSpace + ", 0)");
18635
18636
  }
@@ -18642,45 +18643,50 @@ var color_scale_legend_ColorScaleLegend = /** @class */ (function (_super) {
18642
18643
  }
18643
18644
  }
18644
18645
  }
18646
+ else {
18647
+ // Default state
18648
+ svg.select('g.legend-title').attr('transform', "translate(0, 0)");
18649
+ }
18645
18650
  };
18646
18651
  return _this;
18647
18652
  }
18648
18653
  ColorScaleLegend.prototype.init = function () {
18649
18654
  var eventsFragment = this.services.events;
18650
18655
  // Highlight correct circle on legend item hovers
18651
- eventsFragment.addEventListener(Events.Axis.RENDER_COMPLETE, this.handleAxisComplete);
18656
+ eventsFragment.addEventListener(Events.Axis.RENDER_COMPLETE, this.handleAxisCompleteEvent);
18652
18657
  };
18653
18658
  ColorScaleLegend.prototype.render = function (animate) {
18654
18659
  if (animate === void 0) { animate = false; }
18655
18660
  var options = this.getOptions();
18661
+ var svg = this.getComponentContainer();
18662
+ var width = dom_utils_DOMUtils.getSVGElementSize(svg, {
18663
+ useAttrs: true,
18664
+ }).width;
18656
18665
  var customColors = tools_Tools.getProperty(options, 'color', 'gradient', 'colors');
18657
18666
  var colorScaleType = tools_Tools.getProperty(options, 'heatmap', 'colorLegend', 'type');
18658
18667
  var colorPairingOption = tools_Tools.getProperty(options, 'color', 'pairing', 'option');
18659
18668
  var title = tools_Tools.getProperty(options, 'heatmap', 'colorLegend', 'title');
18660
- var customColorsEnabled = !tools_Tools.isEmpty(customColors);
18661
- var domain = this.model.getValueDomain();
18662
- var svg = this.getComponentContainer();
18663
18669
  // Clear DOM if loading
18664
18670
  var isDataLoading = tools_Tools.getProperty(this.getOptions(), 'data', 'loading');
18665
18671
  if (isDataLoading) {
18666
18672
  svg.html('');
18667
18673
  return;
18668
18674
  }
18669
- var legend = dom_utils_DOMUtils.appendOrSelect(svg, 'g.legend');
18670
- var axis = dom_utils_DOMUtils.appendOrSelect(legend, 'g.legend-axis');
18671
- var width = dom_utils_DOMUtils.getSVGElementSize(svg, {
18672
- useAttrs: true,
18673
- }).width;
18674
- var barWidth = configuration_non_customizable_legend.color.barWidth;
18675
- if (width <= configuration_non_customizable_legend.color.barWidth) {
18676
- barWidth = width;
18677
- }
18675
+ var customColorsEnabled = !tools_Tools.isEmpty(customColors);
18676
+ var domain = this.model.getValueDomain();
18677
+ var useDefaultBarWidth = !(width <= legend.color.barWidth);
18678
+ var barWidth = useDefaultBarWidth
18679
+ ? legend.color.barWidth
18680
+ : width;
18681
+ var legendGroupElement = dom_utils_DOMUtils.appendOrSelect(svg, 'g.legend');
18682
+ var axisElement = dom_utils_DOMUtils.appendOrSelect(legendGroupElement, 'g.legend-axis');
18683
+ // Render title if it exists
18678
18684
  if (title) {
18679
18685
  var legendTitleGroup = dom_utils_DOMUtils.appendOrSelect(svg, 'g.legend-title');
18680
18686
  var legendTitle = dom_utils_DOMUtils.appendOrSelect(legendTitleGroup, 'text');
18681
18687
  legendTitle.text(title).attr('dy', '0.7em');
18682
18688
  // Move the legend down by 16 pixels to display legend text on top
18683
- legend.attr('transform', "translate(0, 16)");
18689
+ legendGroupElement.attr('transform', "translate(0, 16)");
18684
18690
  }
18685
18691
  // If domain consists of negative and positive values, use diverging palettes
18686
18692
  var colorScheme = domain[0] < 0 && domain[1] > 0 ? 'diverge' : 'mono';
@@ -18710,107 +18716,95 @@ var color_scale_legend_ColorScaleLegend = /** @class */ (function (_super) {
18710
18716
  // Use custom colors
18711
18717
  colorPairing = customColors;
18712
18718
  }
18713
- if (colorScaleType === ColorLegendType.LINEAR) {
18714
- var stopLengthPercentage_1 = 100 / (colorPairing.length - 1);
18715
- // Generate the gradient
18716
- var linearGradient = dom_utils_DOMUtils.appendOrSelect(legend, 'linearGradient');
18717
- linearGradient
18718
- .attr('id', this.gradient_id + "-legend")
18719
- .selectAll('stop')
18720
- .data(colorPairing)
18721
- .enter()
18722
- .append('stop')
18723
- .attr('offset', function (_, i) { return i * stopLengthPercentage_1 + "%"; })
18724
- .attr('class', function (_, i) { return colorPairing[i]; })
18725
- .attr('stop-color', function (d) { return d; });
18726
- // Create the legend container
18727
- var rectangle = dom_utils_DOMUtils.appendOrSelect(legend, 'rect');
18728
- rectangle
18729
- .attr('width', barWidth)
18730
- .attr('height', configuration_non_customizable_legend.color.barHeight)
18731
- .style('fill', "url(#" + this.gradient_id + "-legend)");
18732
- // Create scale & ticks
18733
- var linearScale = linear_linear()
18734
- .domain(domain)
18735
- .range([0, barWidth]);
18736
- domain.splice(1, 0, (domain[0] + domain[1]) / 2);
18737
- var xAxis = axisBottom(linearScale)
18738
- .tickSize(0)
18739
- .tickValues(domain);
18740
- // Align axes at the bottom of the rectangle and delete the domain line
18741
- axis.attr('transform', "translate(0," + configuration_non_customizable_legend.color.axisYTranslation + ")").call(xAxis);
18742
- // Remove domain
18743
- axis.select('.domain').remove();
18744
- // Align text to fit in container
18745
- axis.style('text-anchor', 'start');
18746
- }
18747
- else if (colorScaleType === ColorLegendType.QUANTIZE) {
18748
- // Generate equal chunks between range to act as ticks
18749
- var interpolator = src_round(domain[0], domain[1]);
18750
- var quant_1 = quantize(interpolator, colorPairing.length);
18751
- // If divergent && non-custom color, remove 0/white from being displayed
18752
- if (!customColorsEnabled && colorScheme === 'diverge') {
18753
- colorPairing.splice(colorPairing.length / 2, 1);
18754
- }
18755
- var colorScaleBand_1 = band()
18756
- .domain(colorPairing)
18757
- .range([0, barWidth]);
18758
- // Render the quantized rectangles
18759
- var rectangle = dom_utils_DOMUtils.appendOrSelect(legend, 'g.quantized-rect');
18760
- rectangle
18761
- .selectAll('rect')
18762
- .data(colorScaleBand_1.domain())
18763
- .join('rect')
18764
- .attr('x', function (d) { return colorScaleBand_1(d); })
18765
- .attr('y', 0)
18766
- .attr('width', Math.max(0, colorScaleBand_1.bandwidth()) - 1)
18767
- .attr('height', configuration_non_customizable_legend.color.barHeight)
18768
- .attr('class', function (d) { return d; })
18769
- .attr('fill', function (d) { return d; });
18770
- var xAxis = axisBottom(colorScaleBand_1)
18771
- .tickSize(0)
18772
- .tickValues(colorPairing)
18773
- .tickFormat(function (_, i) {
18774
- // Display every other tick to create space
18775
- if (!customColorsEnabled &&
18776
- ((i + 1) % 2 === 0 || i === colorPairing.length - 1)) {
18777
- return null;
18778
- }
18779
- // Use the quant interpolators as ticks
18780
- return quant_1[i].toString();
18781
- });
18782
- // Align axis to match bandwidth start after initial (white)
18783
- var axisTranslation = colorScaleBand_1.bandwidth() / 2;
18784
- axis.attr('transform', "translate(" + (!customColorsEnabled && colorScheme === 'diverge' ? '-' : '') + axisTranslation + ", " + configuration_non_customizable_legend.color.axisYTranslation + ")").call(xAxis);
18785
- // Append the last tick
18786
- var firstTick = axis.select('g.tick').clone(true);
18787
- firstTick
18788
- .attr('transform', "translate(" + (barWidth +
18789
- (!customColorsEnabled && colorScheme === 'diverge'
18790
- ? axisTranslation
18791
- : -axisTranslation)) + ", 0)")
18792
- .classed('final-tick', true)
18793
- .select('text')
18794
- .text(quant_1[quant_1.length - 1]);
18795
- axis.enter().append(firstTick.node());
18796
- axis.select('.domain').remove();
18797
- }
18798
- else {
18799
- throw Error('Entered color legend type is not supported.');
18800
- }
18801
- // Translate last axis tick if barWidth equals chart width
18802
- if (width <= configuration_non_customizable_legend.color.barWidth) {
18803
- var lastTick = axis.select('g.tick:last-of-type text');
18804
- var width_1 = dom_utils_DOMUtils.getSVGElementSize(lastTick, {
18805
- useBBox: true,
18806
- }).width;
18807
- lastTick.attr('x', "-" + width_1);
18808
- }
18719
+ // Generate equal chunks between range to act as ticks
18720
+ var interpolator = d3_interpolate_src_number(domain[0], domain[1]);
18721
+ var quant = quantize(interpolator, 3);
18722
+ // Create scale & ticks
18723
+ var linearScale = linear_linear().domain(domain).range([0, barWidth]);
18724
+ var legendAxis = axisBottom(linearScale)
18725
+ .tickSize(0)
18726
+ .tickValues(quant);
18727
+ switch (colorScaleType) {
18728
+ case ColorLegendType.LINEAR:
18729
+ this.drawLinear(colorPairing, legendGroupElement, barWidth);
18730
+ break;
18731
+ case ColorLegendType.QUANTIZE:
18732
+ var rangeStart = this.drawQuantize(colorPairing, colorScheme, customColorsEnabled, legendGroupElement, barWidth);
18733
+ // Using range provided by drawQuantize for alignment purposes
18734
+ linearScale.range([rangeStart, barWidth]);
18735
+ break;
18736
+ default:
18737
+ throw Error('Entered color legend type is not supported.');
18738
+ }
18739
+ // Align axes at the bottom of the rectangle and delete the domain line
18740
+ axisElement
18741
+ .attr('transform', "translate(0," + legend.color.axisYTranslation + ")")
18742
+ .call(legendAxis);
18743
+ // Remove auto generated axis bottom line
18744
+ axisElement.select('.domain').remove();
18745
+ // Translate first/last axis tick if barWidth equals chart width
18746
+ // Ensures text is not clipped when default bar width (300px) is not used
18747
+ axisElement
18748
+ .select('g.tick:last-of-type text')
18749
+ .style('text-anchor', useDefaultBarWidth ? 'middle' : 'end');
18750
+ axisElement
18751
+ .select('g.tick:first-of-type text')
18752
+ .style('text-anchor', useDefaultBarWidth ? 'middle' : 'start');
18753
+ };
18754
+ // Renders gradient legend
18755
+ ColorScaleLegend.prototype.drawLinear = function (colorPairing, legendGroupElement, barWidth) {
18756
+ var stopLengthPercentage = 100 / (colorPairing.length - 1);
18757
+ // Generate the gradient
18758
+ var linearGradient = dom_utils_DOMUtils.appendOrSelect(legendGroupElement, 'linearGradient');
18759
+ // Rendering gradient
18760
+ linearGradient
18761
+ .attr('id', this.gradient_id + "-legend")
18762
+ .selectAll('stop')
18763
+ .data(colorPairing)
18764
+ .enter()
18765
+ .append('stop')
18766
+ .attr('offset', function (_, i) { return i * stopLengthPercentage + "%"; })
18767
+ .attr('class', function (_, i) { return colorPairing[i]; })
18768
+ .attr('stop-color', function (d) { return d; });
18769
+ // Create the legend container
18770
+ var rectangle = dom_utils_DOMUtils.appendOrSelect(legendGroupElement, 'rect');
18771
+ rectangle
18772
+ .attr('width', barWidth)
18773
+ .attr('height', legend.color.barHeight)
18774
+ .style('fill', "url(#" + this.gradient_id + "-legend)");
18775
+ };
18776
+ /**
18777
+ * Renders quantized legend
18778
+ * @returns number (range start)
18779
+ */
18780
+ ColorScaleLegend.prototype.drawQuantize = function (colorPairing, colorScheme, customColorsEnabled, legendGroupElement, barWidth) {
18781
+ // If divergent && non-custom color, remove 0/white from being displayed
18782
+ if (!customColorsEnabled && colorScheme === 'diverge') {
18783
+ colorPairing.splice(colorPairing.length / 2, 1);
18784
+ }
18785
+ var colorScaleBand = band()
18786
+ .domain(colorPairing)
18787
+ .range([0, barWidth]);
18788
+ // Render the quantized rectangles
18789
+ var rectangle = dom_utils_DOMUtils.appendOrSelect(legendGroupElement, 'g.quantized-rect');
18790
+ rectangle
18791
+ .selectAll('rect')
18792
+ .data(colorScaleBand.domain())
18793
+ .join('rect')
18794
+ .attr('x', function (d) { return colorScaleBand(d); })
18795
+ .attr('y', 0)
18796
+ .attr('width', Math.max(0, colorScaleBand.bandwidth() - 1))
18797
+ .attr('height', legend.color.barHeight)
18798
+ .attr('class', function (d) { return d; })
18799
+ .attr('fill', function (d) { return d; });
18800
+ return (!customColorsEnabled && colorScheme) === 'mono'
18801
+ ? colorScaleBand.bandwidth() - 1
18802
+ : 0;
18809
18803
  };
18810
18804
  ColorScaleLegend.prototype.destroy = function () {
18811
18805
  // Remove legend listeners
18812
18806
  var eventsFragment = this.services.events;
18813
- eventsFragment.removeEventListener(Events.Axis.RENDER_COMPLETE, this.handleAxisComplete);
18807
+ eventsFragment.removeEventListener(Events.Axis.RENDER_COMPLETE, this.handleAxisCompleteEvent);
18814
18808
  };
18815
18809
  return ColorScaleLegend;
18816
18810
  }(legend_Legend));
@@ -20595,12 +20589,12 @@ var essentials_modal_Modal = /** @class */ (function (_super) {
20595
20589
  var options = this.model.getOptions();
20596
20590
  var chartprefix = tools_Tools.getProperty(options, 'style', 'prefix');
20597
20591
  var tableArray = this.model.getTabularDataArray();
20598
- return "\n\t\t<div class=\"bx--modal-container\">\n\t\t\t<div class=\"bx--modal-header\">\n\t\t\t\t<p class=\"bx--modal-header__label bx--type-delta\" id=\"modal-title\">Tabular representation</p>\n\t\t\t\t<p class=\"bx--modal-header__heading bx--type-beta\" id=\"modal-description\">" + options.title + "</p>\n\t\t\t\t<button class=\"bx--modal-close\" type=\"button\" data-modal-close aria-label=\"close modal\" data-modal-primary-focus>\n\t\t\t\t\t<svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\" aria-label=\"Close\" width=\"20\" height=\"20\" viewBox=\"0 0 32 32\" role=\"img\" class=\"bx--modal-close__icon\">\n\t\t\t\t\t\t<path d=\"M24 9.4L22.6 8 16 14.6 9.4 8 8 9.4 14.6 16 8 22.6 9.4 24 16 17.4 22.6 24 24 22.6 17.4 16 24 9.4z\"></path>\n\t\t\t\t\t</svg>\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t\t<div class=\"bx--modal-content\"><table class=\"bx--data-table bx--data-table--no-border\">\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t" + lodash_es_get(tableArray, 0)
20599
- .map(function (heading) { return "<th scope=\"col\">\n\t\t\t\t\t\t\t\t<div class=\"bx--table-header-label\">" + heading + "</div>\n\t\t\t\t\t\t\t</th>"; })
20600
- .join('') + "\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>" + tableArray
20592
+ return "\n\t\t<div class=\"bx--modal-container cds--modal-container\">\n\t\t\t<div class=\"bx--modal-header cds--modal-header\">\n\t\t\t\t<p class=\"bx--modal-header__label bx--type-delta cds--modal-header__label cds--type-delta\" id=\"modal-title\">Tabular representation</p>\n\n\t\t\t\t<p class=\"bx--modal-header__heading bx--type-beta cds--modal-header__heading cds--type-beta\" id=\"modal-description\">" + options.title + "</p>\n\n\t\t\t\t<button class=\"bx--modal-close cds--modal-close\" type=\"button\" data-modal-close aria-label=\"close modal\" data-modal-primary-focus>\n\t\t\t\t\t<svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\" aria-label=\"Close\" width=\"20\" height=\"20\" viewBox=\"0 0 32 32\" role=\"img\" class=\"bx--modal-close__icon cds--modal-close__icon\">\n\t\t\t\t\t\t<path d=\"M24 9.4L22.6 8 16 14.6 9.4 8 8 9.4 14.6 16 8 22.6 9.4 24 16 17.4 22.6 24 24 22.6 17.4 16 24 9.4z\"></path>\n\t\t\t\t\t</svg>\n\t\t\t\t</button>\n\t\t\t</div>\n\n\t\t\t<div class=\"bx--modal-content cds--modal-content\">\n\t\t\t\t<table class=\"bx--data-table bx--data-table--no-border cds--data-table cds--data-table--no-border\">\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t" + lodash_es_get(tableArray, 0)
20593
+ .map(function (heading) { return "<th scope=\"col\">\n\t\t\t\t\t\t\t\t<div class=\"bx--table-header-label cds--table-header-label\">" + heading + "</div>\n\t\t\t\t\t\t\t</th>"; })
20594
+ .join('') + "\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\n\t\t\t\t\t<tbody>" + tableArray
20601
20595
  .slice(1)
20602
20596
  .map(function (row) { return "\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t" + row.map(function (column) { return "<td>" + column + "</td>"; }).join('') + "\n\t\t\t\t\t\t\t</tr>"; })
20603
- .join('') + "\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t\t<div class=\"bx--modal-footer\">\n\t\t\t <div class=\"" + js_settings.prefix + "--" + chartprefix + "-modal-footer-spacer\"></div>\n\t\t\t <button class=\"bx--btn bx--btn--primary\" type=\"button\" data-modal-primary-focus>Download as CSV</button>\n\t\t\t</div>\n\t\t</div>";
20597
+ .join('') + "\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</div>\n\n\t\t\t<div class=\"bx--modal-footer cds--modal-footer\">\n\t\t\t <div class=\"" + js_settings.prefix + "--" + chartprefix + "-modal-footer-spacer\"></div>\n\t\t\t <button class=\"bx--btn bx--btn--primary cds--btn cds--btn--primary\" type=\"button\" data-modal-primary-focus>Download as CSV</button>\n\t\t\t</div>\n\t\t</div>";
20604
20598
  };
20605
20599
  Modal.prototype.render = function () {
20606
20600
  var options = this.model.getOptions();
@@ -20613,7 +20607,7 @@ var essentials_modal_Modal = /** @class */ (function (_super) {
20613
20607
  this.isEventListenerAdded = true;
20614
20608
  this.modal
20615
20609
  .attr('data-modal', true)
20616
- .attr('class', 'bx--modal')
20610
+ .attr('class', 'bx--modal cds--modal')
20617
20611
  .attr('role', 'dialog')
20618
20612
  .attr('aria-modal', true)
20619
20613
  .attr('aria-labelledby', 'modal-title')
@@ -39601,7 +39595,7 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
39601
39595
  if (!this.overflowMenu) {
39602
39596
  this.overflowMenu = container
39603
39597
  .append('div')
39604
- .attr('class', 'bx--overflow-menu-options bx--overflow-menu--flip')
39598
+ .attr('class', 'bx--overflow-menu-options bx--overflow-menu--flip cds--overflow-menu-options cds--overflow-menu--flip')
39605
39599
  .attr('tabindex', -1)
39606
39600
  .attr('role', 'menu')
39607
39601
  .html("<ul></ul>");
@@ -39619,7 +39613,7 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
39619
39613
  var enteringToolbarControls = toolbarControls
39620
39614
  .enter()
39621
39615
  .append('div')
39622
- .attr('class', 'toolbar-control bx--overflow-menu')
39616
+ .attr('class', 'toolbar-control bx--overflow-menu cds--overflow-menu')
39623
39617
  .attr('role', 'button');
39624
39618
  var self_1 = this;
39625
39619
  var allToolbarControls = enteringToolbarControls
@@ -39627,9 +39621,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
39627
39621
  .classed('disabled', function (d) { return d.shouldBeDisabled(); })
39628
39622
  .attr('aria-disabled', function (d) { return d.shouldBeDisabled(); })
39629
39623
  .attr('aria-label', function (d) { return d.title; })
39630
- .html(function (d) { return "\n\t\t\t<button\n\t\t\t\tclass=\"bx--overflow-menu__trigger\"\n\t\t\t\taria-haspopup=\"true\" aria-expanded=\"false\" id=\"" + _this.services.domUtils.generateElementIDString("control-" + d.id) + "\" aria-label=\"" + d.title + "\">\n\t\t\t\t<svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" style=\"will-change: transform; width: " + (d.iconSVG.width !== undefined ? d.iconSVG.width : '20px') + "; height: " + (d.iconSVG.height !== undefined
39624
+ .html(function (d) { return "\n\t\t\t<button\n\t\t\t\tclass=\"bx--overflow-menu__trigger cds--overflow-menu__trigger\"\n\t\t\t\taria-haspopup=\"true\" aria-expanded=\"false\" id=\"" + _this.services.domUtils.generateElementIDString("control-" + d.id) + "\" aria-label=\"" + d.title + "\">\n\t\t\t\t<svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" style=\"will-change: transform; width: " + (d.iconSVG.width !== undefined ? d.iconSVG.width : '20px') + "; height: " + (d.iconSVG.height !== undefined
39631
39625
  ? d.iconSVG.height
39632
- : '20px') + "\" xmlns=\"http://www.w3.org/2000/svg\" class=\"bx--overflow-menu__icon\" viewBox=\"0 0 32 32\" aria-hidden=\"true\">\n\t\t\t\t\t" + d.iconSVG.content + "\n\t\t\t\t</svg>\n\t\t\t</button>"; })
39626
+ : '20px') + "\" xmlns=\"http://www.w3.org/2000/svg\" class=\"bx--overflow-menu__icon cds--overflow-menu__icon\" viewBox=\"0 0 32 32\" aria-hidden=\"true\">\n\t\t\t\t\t" + d.iconSVG.content + "\n\t\t\t\t</svg>\n\t\t\t</button>"; })
39633
39627
  .each(function (d, index) {
39634
39628
  var _this = this;
39635
39629
  src_select(this)
@@ -39673,15 +39667,18 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
39673
39667
  .attr('id', function (d) {
39674
39668
  return _this.services.domUtils.generateElementIDString("control-" + d.id);
39675
39669
  })
39676
- .attr('class', 'bx--overflow-menu-options__option')
39670
+ .attr('class', 'bx--overflow-menu-options__option cds--overflow-menu-options__option')
39677
39671
  .attr('role', 'menuitem');
39678
39672
  enteringOverflowMenuControls
39679
39673
  .append('button')
39680
- .attr('class', 'bx--overflow-menu-options__btn');
39674
+ .attr('class', 'bx--overflow-menu-options__btn cds--overflow-menu-options__btn');
39681
39675
  enteringOverflowMenuControls
39682
39676
  .merge(overflowMenuControls)
39683
39677
  .classed('bx--overflow-menu-options__option--disabled', function (d) {
39684
39678
  return d.shouldBeDisabled();
39679
+ })
39680
+ .classed('cds--overflow-menu-options__option--disabled', function (d) {
39681
+ return d.shouldBeDisabled();
39685
39682
  })
39686
39683
  .attr('aria-disabled', function (d) { return d.shouldBeDisabled(); })
39687
39684
  .selectAll('button')
@@ -39699,7 +39696,8 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
39699
39696
  // update overflow button background
39700
39697
  if (this.overflowButton) {
39701
39698
  this.overflowButton.attr('aria-expanded', show);
39702
- src_select(this.overflowButton.node().parentNode).classed('bx--overflow-menu--open', show);
39699
+ src_select(this.overflowButton.node().parentNode)
39700
+ .classed('bx--overflow-menu--open', show).classed('cds--overflow-menu--open', show);
39703
39701
  }
39704
39702
  if (show) {
39705
39703
  this.services.events.dispatchEvent(Events.Toolbar.SHOW_OVERFLOW_MENU);
@@ -44129,28 +44127,16 @@ var heatmap_HeatmapModel = /** @class */ (function (_super) {
44129
44127
  * @returns Array consisting of smallest and largest values in data
44130
44128
  */
44131
44129
  HeatmapModel.prototype.getValueDomain = function () {
44132
- var data = this.getDisplayData().map(function (element) { return element.value; });
44133
- var limits = src_extent(data);
44134
- var domain = [];
44135
- // Round extent values to the nearest multiple of 10
44136
- // Axis rounds values to multiples of 2, 5, and 10s.
44137
- limits.forEach(function (number, index) {
44138
- var value = Number(number);
44139
- if (index === 0 && value >= 0) {
44140
- value = 0;
44141
- }
44142
- else if (value % 10 === 0 || value === 0) {
44143
- value;
44144
- }
44145
- else if (value < 0) {
44146
- value = Math.floor(value / 10) * 10;
44147
- }
44148
- else {
44149
- value = Math.ceil(value / 10) * 10;
44150
- }
44151
- domain.push(value);
44152
- });
44153
- // Ensure the median of the range is 0
44130
+ var limits = src_extent(this.getDisplayData(), function (d) { return d.value; });
44131
+ var domain = linear_linear()
44132
+ .domain(limits)
44133
+ .nice()
44134
+ .domain();
44135
+ // Ensuring limits start at 0 to make scale look more `nicer`
44136
+ if (domain[0] > 0) {
44137
+ domain[0] = 0;
44138
+ }
44139
+ // Ensure the median of the range is 0 if domain extends into both negative & positive
44154
44140
  if (domain[0] < 0 && domain[1] > 0) {
44155
44141
  if (Math.abs(domain[0]) > domain[1]) {
44156
44142
  domain[1] = Math.abs(domain[0]);
@@ -44164,7 +44150,7 @@ var heatmap_HeatmapModel = /** @class */ (function (_super) {
44164
44150
  /**
44165
44151
  * @override
44166
44152
  * @param value
44167
- * @returns
44153
+ * @returns string
44168
44154
  */
44169
44155
  HeatmapModel.prototype.getFillColor = function (value) {
44170
44156
  return this._colorScale(value);