@nova-ui/charts 12.0.34 → 12.0.35

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.
@@ -4263,6 +4263,7 @@
4263
4263
  dataSeries: chartSeries,
4264
4264
  containers: childContainers,
4265
4265
  scales: chartSeries.scales,
4266
+ parentContainer: this.renderLayers.data,
4266
4267
  };
4267
4268
  chartSeries.renderer.highlightDataPoint(renderSeries, index, this.rendererSubject);
4268
4269
  };
@@ -5988,17 +5989,19 @@
5988
5989
  var textSelection = interactionLabel
5989
5990
  .select("text")
5990
5991
  .text(labelContent);
5991
- var bbox = textSelection.node().getBBox();
5992
+ if (!this.elBBox) {
5993
+ this.elBBox = textSelection.node().getBBox();
5994
+ }
5992
5995
  var gridDimension = this.chart.getGrid().config().dimension;
5993
5996
  // subtract the relative vertical text offset inside the bbox from
5994
5997
  // the grid height to determine the label's vertical placement
5995
- var heightOffset = gridDimension.height() - bbox.y;
5998
+ var heightOffset = gridDimension.height() - this.elBBox.y;
5996
5999
  textSelection
5997
6000
  .attr("transform", "translate(0, " + heightOffset + ")")
5998
6001
  .style("text-anchor", "middle");
5999
6002
  // match the horizontal padding to the built-in bbox vertical padding
6000
- var horizontalPadding = (bbox.height + bbox.y) * 2;
6001
- var labelWidth = bbox.width + horizontalPadding;
6003
+ var horizontalPadding = (this.elBBox.height + this.elBBox.y) * 2;
6004
+ var labelWidth = this.elBBox.width + horizontalPadding;
6002
6005
  var allowedRange = [
6003
6006
  labelWidth / 2,
6004
6007
  gridDimension.width() - labelWidth / 2,
@@ -6011,9 +6014,9 @@
6011
6014
  .attrs({
6012
6015
  transform: "translate(0," + heightOffset + ")",
6013
6016
  x: -(labelWidth / 2),
6014
- y: bbox.y,
6017
+ y: this.elBBox.y,
6015
6018
  width: labelWidth,
6016
- height: bbox.height,
6019
+ height: this.elBBox.height,
6017
6020
  });
6018
6021
  };
6019
6022
  InteractionLabelPlugin.prototype.destroy = function () {
@@ -8083,7 +8086,7 @@
8083
8086
  if (chartSeriesSet.length === 0) {
8084
8087
  return chartSeriesSet;
8085
8088
  }
8086
- var categories = gatherCategories(chartSeriesSet);
8089
+ var categories = gatherCategories(chartSeriesSet.filter(function (chartSeries) { return isUndefined__default["default"](chartSeries.preprocess) || chartSeries.preprocess; }));
8087
8090
  // This is adding metadata to the dataset and filling missing
8088
8091
  var forExtents = chartSeriesSet.reduce(function (acc, chartSeries) {
8089
8092
  if (!isUndefined__default["default"](chartSeries.preprocess) && !chartSeries.preprocess) {
@@ -10671,6 +10674,69 @@
10671
10674
  return BarHighlightStrategy;
10672
10675
  }());
10673
10676
 
10677
+ // creates an outline element that is used to highlight hovered parts of the chart
10678
+ var BarHighlightStrategyOutline = /** @class */ (function (_super) {
10679
+ __extends(BarHighlightStrategyOutline, _super);
10680
+ /**
10681
+ * @param scaleKey scale that will be used for searching for the data point that will be highlighted
10682
+ * @param levels for band scales, how many levels deep do we go to compare values
10683
+ */
10684
+ function BarHighlightStrategyOutline(scaleKey, levels, selectedDataPointIdxFn) {
10685
+ if (levels === void 0) { levels = 1; }
10686
+ var _this = _super.call(this, scaleKey, levels, selectedDataPointIdxFn) || this;
10687
+ _this.outlineAdd = 6;
10688
+ _this.outlineElsMap = new Map();
10689
+ return _this;
10690
+ }
10691
+ BarHighlightStrategyOutline.prototype.highlightDataPoint = function (renderer, renderSeries, dataPointIndex) {
10692
+ var _a, _b;
10693
+ var target = renderSeries.containers[exports.RenderLayerName.data];
10694
+ var selectedDataPointIdx = !isUndefined__default["default"](this.selectedDataPointIdxFn)
10695
+ ? this.selectedDataPointIdxFn(renderSeries.dataSeries.id)
10696
+ : DATA_POINT_NOT_FOUND;
10697
+ var gNodes = target
10698
+ .selectAll("g." + renderer.barContainerClass)
10699
+ .nodes();
10700
+ var emphasizedNode = gNodes[dataPointIndex] || gNodes[selectedDataPointIdx];
10701
+ if (!renderSeries.parentContainer) {
10702
+ return;
10703
+ }
10704
+ // needs to replace all '.' from the serie id as the dot would be treated as a class name in the query selector
10705
+ var outlineRectClass = (renderer.barContainerClass + "-outline-" + renderSeries.dataSeries.id)
10706
+ .split(".")
10707
+ .join("-");
10708
+ if (!this.outlineElsMap.has(outlineRectClass)) {
10709
+ // creates a rect element that will be used as a outline
10710
+ var rect = renderSeries.parentContainer.append("rect");
10711
+ rect.classed(outlineRectClass, true);
10712
+ this.outlineElsMap.set(outlineRectClass, rect);
10713
+ }
10714
+ var outlineRect = this.outlineElsMap.get(outlineRectClass);
10715
+ var emphasizedDataValue = ((_a = renderSeries.dataSeries.data[dataPointIndex]) === null || _a === void 0 ? void 0 : _a.y) ||
10716
+ ((_b = renderSeries.dataSeries.data[dataPointIndex]) === null || _b === void 0 ? void 0 : _b.value);
10717
+ if (emphasizedDataValue && emphasizedNode && outlineRect) {
10718
+ // position the outline element on the position of the emphasized element and updates its attributes
10719
+ var emphasizedRect = d3Selection.select(emphasizedNode).select("rect");
10720
+ var x = parseFloat(emphasizedRect.attr("x")) - this.outlineAdd / 2;
10721
+ var y = parseFloat(emphasizedRect.attr("y")) - this.outlineAdd / 2;
10722
+ var width = parseFloat(emphasizedRect.attr("width")) + this.outlineAdd;
10723
+ var height = parseFloat(emphasizedRect.attr("height")) + this.outlineAdd;
10724
+ outlineRect.attr("x", x);
10725
+ outlineRect.attr("y", y);
10726
+ outlineRect.attr("width", width);
10727
+ outlineRect.attr("height", height);
10728
+ outlineRect.style("fill", emphasizedRect.style("fill"));
10729
+ outlineRect.style("display", "inline");
10730
+ }
10731
+ if ((outlineRect && !emphasizedDataValue) ||
10732
+ (outlineRect && !emphasizedNode)) {
10733
+ // hides outline element when there is no emphasized element
10734
+ outlineRect.style("display", "none");
10735
+ }
10736
+ };
10737
+ return BarHighlightStrategyOutline;
10738
+ }(BarHighlightStrategy));
10739
+
10674
10740
  // © 2022 SolarWinds Worldwide, LLC. All rights reserved.
10675
10741
  var BarSeriesHighlightStrategy = /** @class */ (function () {
10676
10742
  /**
@@ -11304,6 +11370,7 @@
11304
11370
  exports.BarAccessors = BarAccessors;
11305
11371
  exports.BarGridConfig = BarGridConfig;
11306
11372
  exports.BarHighlightStrategy = BarHighlightStrategy;
11373
+ exports.BarHighlightStrategyOutline = BarHighlightStrategyOutline;
11307
11374
  exports.BarHorizontalGridConfig = BarHorizontalGridConfig;
11308
11375
  exports.BarRenderer = BarRenderer;
11309
11376
  exports.BarSeriesHighlightStrategy = BarSeriesHighlightStrategy;