@fluentui/react-charting 5.23.20 → 5.23.21
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.json +16 -1
- package/CHANGELOG.md +11 -2
- package/dist/react-charting.d.ts +6 -1
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +2 -1
- package/lib/components/CommonComponents/CartesianChart.base.js +2 -2
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.d.ts +6 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.d.ts +2 -0
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js +70 -41
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib/utilities/test-data.d.ts +16 -0
- package/lib/utilities/test-data.js +52 -0
- package/lib/utilities/test-data.js.map +1 -1
- package/lib/utilities/utilities.d.ts +1 -1
- package/lib/utilities/utilities.js +29 -4
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +2 -2
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +6 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.d.ts +2 -0
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +70 -41
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-amd/utilities/test-data.d.ts +16 -0
- package/lib-amd/utilities/test-data.js +53 -1
- package/lib-amd/utilities/test-data.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +1 -1
- package/lib-amd/utilities/utilities.js +29 -4
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +2 -2
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +6 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.d.ts +2 -0
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +70 -41
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/utilities/test-data.d.ts +16 -0
- package/lib-commonjs/utilities/test-data.js +53 -1
- package/lib-commonjs/utilities/test-data.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +1 -1
- package/lib-commonjs/utilities/utilities.js +29 -4
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +1 -1
- package/src/components/CommonComponents/CartesianChart.types.ts +7 -0
|
@@ -255,7 +255,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-shape", "d3-sele
|
|
|
255
255
|
var xBarScale;
|
|
256
256
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
257
257
|
var yBarScale = (0, d3_scale_1.scaleLinear)()
|
|
258
|
-
.domain([0, _this._yMax])
|
|
258
|
+
.domain([_this.props.supportNegativeData ? _this._yMin : 0, _this._yMax])
|
|
259
259
|
.range([0, containerHeight - _this.margins.bottom - _this.margins.top]);
|
|
260
260
|
if (_this._xAxisType === index_2.XAxisTypes.NumericAxis) {
|
|
261
261
|
var xMax = (0, d3_array_1.max)(_this._points, function (point) { return point.x; });
|
|
@@ -347,6 +347,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-shape", "d3-sele
|
|
|
347
347
|
if (yAxisData && yAxisData.yAxisDomainValues.length) {
|
|
348
348
|
var domainValue = yAxisData.yAxisDomainValues;
|
|
349
349
|
_this._yMax = Math.max(domainValue[domainValue.length - 1], _this.props.yMaxValue || 0);
|
|
350
|
+
_this._yMin = Math.min(domainValue[0], _this.props.yMinValue || 0);
|
|
350
351
|
}
|
|
351
352
|
};
|
|
352
353
|
/**
|
|
@@ -452,6 +453,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-shape", "d3-sele
|
|
|
452
453
|
this._adjustProps();
|
|
453
454
|
this._xAxisLabels = this._points.map(function (point) { return point.x; });
|
|
454
455
|
this._yMax = Math.max((0, d3_array_1.max)(this._points, function (point) { return point.y; }), this.props.yMaxValue || 0);
|
|
456
|
+
this._yMin = Math.min((0, d3_array_1.min)(this._points, function (point) { return point.y; }), this.props.yMinValue || 0);
|
|
455
457
|
var legendBars = this._getLegendData(this._points, this.props.theme.palette);
|
|
456
458
|
this._classNames = getClassNames(this.props.styles, {
|
|
457
459
|
theme: this.props.theme,
|
|
@@ -465,7 +467,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-shape", "d3-sele
|
|
|
465
467
|
tickValues: this.props.tickValues,
|
|
466
468
|
tickFormat: this.props.tickFormat,
|
|
467
469
|
};
|
|
468
|
-
return !this._isChartEmpty() ? (React.createElement(index_1.CartesianChart, tslib_1.__assign({}, this.props, { chartTitle: this._getChartTitle(), points: this._points, chartType: index_2.ChartTypes.VerticalBarChart, xAxisType: this._xAxisType, createYAxis: index_2.createNumericYAxis, calloutProps: calloutProps, tickParams: tickParams }, (this._isHavingLine && this._noLegendHighlighted() && { isCalloutForStack: true }), { legendBars: legendBars, datasetForXAxisDomain: this._xAxisLabels, barwidth: this._barWidth, focusZoneDirection: react_focus_1.FocusZoneDirection.horizontal, customizedCallout: this._getCustomizedCallout(), createStringYAxis: index_2.createStringYAxis, getmargins: this._getMargins, getMinMaxOfYAxis: index_2.findVerticalNumericMinMaxOfY, getGraphData: this._getGraphData, getDomainNRangeValues: this._getDomainNRangeValues, getAxisData: this._getAxisData, onChartMouseLeave: this._handleChartMouseLeave, getDomainMargins: this._getDomainMargins }, (this._xAxisType === index_2.XAxisTypes.StringAxis && {
|
|
470
|
+
return !this._isChartEmpty() ? (React.createElement(index_1.CartesianChart, tslib_1.__assign({}, this.props, { chartTitle: this._getChartTitle(), points: this._points, supportNegativeData: this.props.supportNegativeData, chartType: index_2.ChartTypes.VerticalBarChart, xAxisType: this._xAxisType, createYAxis: index_2.createNumericYAxis, calloutProps: calloutProps, tickParams: tickParams }, (this._isHavingLine && this._noLegendHighlighted() && { isCalloutForStack: true }), { legendBars: legendBars, datasetForXAxisDomain: this._xAxisLabels, barwidth: this._barWidth, focusZoneDirection: react_focus_1.FocusZoneDirection.horizontal, customizedCallout: this._getCustomizedCallout(), createStringYAxis: index_2.createStringYAxis, getmargins: this._getMargins, getMinMaxOfYAxis: index_2.findVerticalNumericMinMaxOfY, getGraphData: this._getGraphData, getDomainNRangeValues: this._getDomainNRangeValues, getAxisData: this._getAxisData, onChartMouseLeave: this._handleChartMouseLeave, getDomainMargins: this._getDomainMargins }, (this._xAxisType === index_2.XAxisTypes.StringAxis && {
|
|
469
471
|
xAxisInnerPadding: this._xAxisInnerPadding,
|
|
470
472
|
xAxisOuterPadding: this._xAxisOuterPadding,
|
|
471
473
|
}), {
|
|
@@ -527,11 +529,19 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-shape", "d3-sele
|
|
|
527
529
|
});
|
|
528
530
|
}
|
|
529
531
|
};
|
|
532
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
533
|
+
VerticalBarChartBase.prototype._calculateMinBarHeight = function (yMin, yMax, yReferencePoint, yBarScale) {
|
|
534
|
+
var maxHeightFromBaseline = yMax < 0
|
|
535
|
+
? Math.abs(yMin - yReferencePoint)
|
|
536
|
+
: Math.max(Math.abs(yMax - yReferencePoint), Math.abs(yMin - yReferencePoint));
|
|
537
|
+
return Math.ceil(yBarScale(maxHeightFromBaseline) / 100.0);
|
|
538
|
+
};
|
|
530
539
|
VerticalBarChartBase.prototype._createNumericBars = function (containerHeight, containerWidth, xElement) {
|
|
531
540
|
var _this = this;
|
|
532
541
|
var _a = this.props.useSingleColor, useSingleColor = _a === void 0 ? false : _a;
|
|
533
542
|
var _b = this._getScales(containerHeight, containerWidth), xBarScale = _b.xBarScale, yBarScale = _b.yBarScale;
|
|
534
543
|
var colorScale = this._createColors();
|
|
544
|
+
var yReferencePoint = this._yMax < 0 ? this._yMax : 0;
|
|
535
545
|
var bars = this._points.map(function (point, index) {
|
|
536
546
|
var _a, _b, _c, _d, _e, _f;
|
|
537
547
|
var shouldHighlight = _this._legendHighlighted(point.legend) || _this._noLegendHighlighted() ? true : false;
|
|
@@ -540,19 +550,25 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-shape", "d3-sele
|
|
|
540
550
|
legendColor: _this.state.color,
|
|
541
551
|
shouldHighlight: shouldHighlight,
|
|
542
552
|
});
|
|
543
|
-
var barHeight =
|
|
544
|
-
var
|
|
545
|
-
|
|
553
|
+
var barHeight = yBarScale(point.y) - yBarScale(yReferencePoint);
|
|
554
|
+
var isHeightNegative = barHeight < 0;
|
|
555
|
+
barHeight = Math.abs(barHeight);
|
|
556
|
+
// Calculate threshold for minimum visible bar height
|
|
557
|
+
var minBarHeight = _this._calculateMinBarHeight(_this._yMin, _this._yMax, yReferencePoint, yBarScale);
|
|
558
|
+
var adjustedBarHeight = barHeight;
|
|
559
|
+
if (barHeight === 0 || (isHeightNegative && !_this.props.supportNegativeData)) {
|
|
546
560
|
return React.createElement(React.Fragment, { key: point.x }, " ");
|
|
547
561
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
else {
|
|
552
|
-
adjustedBarHeight = barHeight;
|
|
562
|
+
// Adjust bar height if it's smaller than the threshold
|
|
563
|
+
else if (barHeight <= minBarHeight) {
|
|
564
|
+
adjustedBarHeight = minBarHeight;
|
|
553
565
|
}
|
|
554
566
|
var xPoint = xBarScale(point.x) - _this._barWidth / 2;
|
|
555
|
-
var yPoint = containerHeight -
|
|
567
|
+
var yPoint = containerHeight -
|
|
568
|
+
_this.margins.bottom -
|
|
569
|
+
(isHeightNegative ? -1 * adjustedBarHeight : adjustedBarHeight) -
|
|
570
|
+
yBarScale(yReferencePoint);
|
|
571
|
+
var baselineHeight = containerHeight - _this.margins.bottom - yBarScale(yReferencePoint);
|
|
556
572
|
var startColor = point.color && !useSingleColor ? point.color : colorScale(point.y);
|
|
557
573
|
var endColor = startColor;
|
|
558
574
|
if (_this.props.enableGradient) {
|
|
@@ -570,10 +586,10 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-shape", "d3-sele
|
|
|
570
586
|
React.createElement("linearGradient", { id: gradientId, x1: "0%", y1: "100%", x2: "0%", y2: "0%" },
|
|
571
587
|
React.createElement("stop", { offset: "0", stopColor: startColor }),
|
|
572
588
|
React.createElement("stop", { offset: "100%", stopColor: endColor })))),
|
|
573
|
-
React.createElement("rect", { id: (0, Utilities_1.getId)('_VBC_bar_'), x: xPoint, className: _this._classNames.opacityChangeOnHover, y: yPoint, width: _this._barWidth, "data-is-focusable": !_this.props.hideTooltip && shouldHighlight, height: adjustedBarHeight, ref: function (e) {
|
|
589
|
+
React.createElement("rect", { id: (0, Utilities_1.getId)('_VBC_bar_'), x: xPoint, className: _this._classNames.opacityChangeOnHover, y: !isHeightNegative ? yPoint : baselineHeight, width: _this._barWidth, "data-is-focusable": !_this.props.hideTooltip && shouldHighlight, height: adjustedBarHeight, ref: function (e) {
|
|
574
590
|
_this._refCallback(e, point.legend);
|
|
575
591
|
}, onClick: point.onClick, onMouseOver: _this._onBarHover.bind(_this, point, startColor), "aria-label": _this._getAriaLabel(point), role: "img", onMouseLeave: _this._onBarLeave, onFocus: _this._onBarFocus.bind(_this, point, index, startColor), onBlur: _this._onBarLeave, fill: _this.props.enableGradient ? "url(#".concat(gradientId, ")") : startColor, rx: _this.props.roundCorners ? 3 : 0 }),
|
|
576
|
-
_this._renderBarLabel(xPoint, yPoint, point.y, point.legend)));
|
|
592
|
+
_this._renderBarLabel(xPoint, yPoint, point.y, point.legend, isHeightNegative)));
|
|
577
593
|
});
|
|
578
594
|
// Removing un wanted tooltip div from DOM, when prop not provided.
|
|
579
595
|
if (!this.props.showXAxisLablesTooltip) {
|
|
@@ -605,21 +621,28 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-shape", "d3-sele
|
|
|
605
621
|
var _a = this.props.useSingleColor, useSingleColor = _a === void 0 ? false : _a;
|
|
606
622
|
var _b = this._getScales(containerHeight, containerWidth), xBarScale = _b.xBarScale, yBarScale = _b.yBarScale;
|
|
607
623
|
var colorScale = this._createColors();
|
|
624
|
+
var yReferencePoint = this._yMax < 0 ? this._yMax : 0;
|
|
608
625
|
var bars = this._points.map(function (point, index) {
|
|
609
626
|
var _a, _b, _c, _d, _e, _f;
|
|
610
|
-
var barHeight =
|
|
611
|
-
var
|
|
612
|
-
|
|
613
|
-
|
|
627
|
+
var barHeight = yBarScale(point.y) - yBarScale(yReferencePoint);
|
|
628
|
+
var isHeightNegative = barHeight < 0;
|
|
629
|
+
barHeight = Math.abs(barHeight);
|
|
630
|
+
// Calculate threshold for minimum visible bar height
|
|
631
|
+
var minBarHeight = _this._calculateMinBarHeight(_this._yMin, _this._yMax, yReferencePoint, yBarScale);
|
|
632
|
+
var adjustedBarHeight = barHeight;
|
|
633
|
+
if (barHeight === 0 || (isHeightNegative && !_this.props.supportNegativeData)) {
|
|
634
|
+
return React.createElement(React.Fragment, { key: point.x }, " ");
|
|
614
635
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
else {
|
|
619
|
-
adjustedBarHeight = barHeight;
|
|
636
|
+
// Adjust bar height if it's smaller than the threshold
|
|
637
|
+
else if (barHeight <= minBarHeight) {
|
|
638
|
+
adjustedBarHeight = minBarHeight;
|
|
620
639
|
}
|
|
621
640
|
var xPoint = xBarScale(point.x);
|
|
622
|
-
var yPoint = containerHeight -
|
|
641
|
+
var yPoint = containerHeight -
|
|
642
|
+
_this.margins.bottom -
|
|
643
|
+
(isHeightNegative ? -1 * adjustedBarHeight : adjustedBarHeight) -
|
|
644
|
+
yBarScale(yReferencePoint);
|
|
645
|
+
var baselineHeight = containerHeight - _this.margins.bottom - yBarScale(yReferencePoint);
|
|
623
646
|
// Setting the bar width here is safe because there are no dependencies earlier in the code
|
|
624
647
|
// that rely on the width of bars in vertical bar charts with string x-axis.
|
|
625
648
|
_this._barWidth = (0, index_2.getBarWidth)(_this.props.barWidth, _this.props.maxBarWidth, xBarScale.bandwidth());
|
|
@@ -640,10 +663,10 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-shape", "d3-sele
|
|
|
640
663
|
React.createElement("linearGradient", { id: gradientId, x1: "0%", y1: "100%", x2: "0%", y2: "0%" },
|
|
641
664
|
React.createElement("stop", { offset: "0", stopColor: startColor }),
|
|
642
665
|
React.createElement("stop", { offset: "100%", stopColor: endColor })))),
|
|
643
|
-
React.createElement("rect", { id: (0, Utilities_1.getId)('_VBC_bar_'), x: xPoint, y: yPoint, width: _this._barWidth, height: adjustedBarHeight, "aria-label": _this._getAriaLabel(point), role: "img", ref: function (e) {
|
|
666
|
+
React.createElement("rect", { id: (0, Utilities_1.getId)('_VBC_bar_'), x: xPoint, y: !isHeightNegative ? yPoint : baselineHeight, width: _this._barWidth, height: adjustedBarHeight, "aria-label": _this._getAriaLabel(point), role: "img", ref: function (e) {
|
|
644
667
|
_this._refCallback(e, point.legend);
|
|
645
668
|
}, onClick: point.onClick, onMouseOver: _this._onBarHover.bind(_this, point, startColor), onMouseLeave: _this._onBarLeave, onBlur: _this._onBarLeave, "data-is-focusable": !_this.props.hideTooltip, onFocus: _this._onBarFocus.bind(_this, point, index, startColor), fill: _this.props.enableGradient ? "url(#".concat(gradientId, ")") : startColor, rx: _this.props.roundCorners ? 3 : 0 }),
|
|
646
|
-
_this._renderBarLabel(xPoint, yPoint, point.y, point.legend)));
|
|
669
|
+
_this._renderBarLabel(xPoint, yPoint, point.y, point.legend, isHeightNegative)));
|
|
647
670
|
});
|
|
648
671
|
// Removing un wanted tooltip div from DOM, when prop not provided.
|
|
649
672
|
if (!this.props.showXAxisLablesTooltip) {
|
|
@@ -676,6 +699,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-shape", "d3-sele
|
|
|
676
699
|
var _a = this.props.useSingleColor, useSingleColor = _a === void 0 ? false : _a;
|
|
677
700
|
var _b = this._getScales(containerHeight, containerWidth), xBarScale = _b.xBarScale, yBarScale = _b.yBarScale;
|
|
678
701
|
var colorScale = this._createColors();
|
|
702
|
+
var yReferencePoint = this._yMax < 0 ? this._yMax : 0;
|
|
679
703
|
var bars = this._points.map(function (point, index) {
|
|
680
704
|
var _a, _b, _c, _d, _e, _f;
|
|
681
705
|
var shouldHighlight = _this._legendHighlighted(point.legend) || _this._noLegendHighlighted() ? true : false;
|
|
@@ -684,19 +708,25 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-shape", "d3-sele
|
|
|
684
708
|
legendColor: _this.state.color,
|
|
685
709
|
shouldHighlight: shouldHighlight,
|
|
686
710
|
});
|
|
687
|
-
var barHeight =
|
|
688
|
-
var
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
711
|
+
var barHeight = yBarScale(point.y) - yBarScale(yReferencePoint);
|
|
712
|
+
var isHeightNegative = barHeight < 0;
|
|
713
|
+
barHeight = Math.abs(barHeight);
|
|
714
|
+
// Calculate threshold for minimum visible bar height
|
|
715
|
+
var minBarHeight = _this._calculateMinBarHeight(_this._yMin, _this._yMax, yReferencePoint, yBarScale);
|
|
716
|
+
var adjustedBarHeight = barHeight;
|
|
717
|
+
if (barHeight === 0 || (isHeightNegative && !_this.props.supportNegativeData)) {
|
|
718
|
+
return React.createElement(React.Fragment, { key: point.x }, " ");
|
|
694
719
|
}
|
|
695
|
-
|
|
696
|
-
|
|
720
|
+
// Adjust bar height if it's smaller than the threshold
|
|
721
|
+
else if (barHeight <= minBarHeight) {
|
|
722
|
+
adjustedBarHeight = minBarHeight;
|
|
697
723
|
}
|
|
698
724
|
var xPoint = xBarScale(point.x) - _this._barWidth / 2;
|
|
699
|
-
var yPoint = containerHeight -
|
|
725
|
+
var yPoint = containerHeight -
|
|
726
|
+
_this.margins.bottom -
|
|
727
|
+
(isHeightNegative ? -1 * adjustedBarHeight : adjustedBarHeight) -
|
|
728
|
+
yBarScale(yReferencePoint);
|
|
729
|
+
var baselineHeight = containerHeight - _this.margins.bottom - yBarScale(yReferencePoint);
|
|
700
730
|
var startColor = point.color && !useSingleColor ? point.color : colorScale(point.y);
|
|
701
731
|
var endColor = startColor;
|
|
702
732
|
if (_this.props.enableGradient) {
|
|
@@ -714,10 +744,10 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-shape", "d3-sele
|
|
|
714
744
|
React.createElement("linearGradient", { id: gradientId, x1: "0%", y1: "100%", x2: "0%", y2: "0%" },
|
|
715
745
|
React.createElement("stop", { offset: "0", stopColor: startColor }),
|
|
716
746
|
React.createElement("stop", { offset: "100%", stopColor: endColor })))),
|
|
717
|
-
React.createElement("rect", { id: (0, Utilities_1.getId)('_VBC_bar_'), x: xPoint, className: _this._classNames.opacityChangeOnHover, y: yPoint, width: _this._barWidth, "data-is-focusable": !_this.props.hideTooltip && shouldHighlight, height: adjustedBarHeight, ref: function (e) {
|
|
747
|
+
React.createElement("rect", { id: (0, Utilities_1.getId)('_VBC_bar_'), x: xPoint, className: _this._classNames.opacityChangeOnHover, y: !isHeightNegative ? yPoint : baselineHeight, width: _this._barWidth, "data-is-focusable": !_this.props.hideTooltip && shouldHighlight, height: adjustedBarHeight, ref: function (e) {
|
|
718
748
|
_this._refCallback(e, point.legend);
|
|
719
749
|
}, onClick: point.onClick, onMouseOver: _this._onBarHover.bind(_this, point, startColor), "aria-label": _this._getAriaLabel(point), role: "img", onMouseLeave: _this._onBarLeave, onFocus: _this._onBarFocus.bind(_this, point, index, startColor), onBlur: _this._onBarLeave, fill: _this.props.enableGradient ? "url(#".concat(gradientId, ")") : startColor, rx: _this.props.roundCorners ? 3 : 0 }),
|
|
720
|
-
_this._renderBarLabel(xPoint, yPoint, point.y, point.legend)));
|
|
750
|
+
_this._renderBarLabel(xPoint, yPoint, point.y, point.legend, isHeightNegative)));
|
|
721
751
|
});
|
|
722
752
|
// Removing un wanted tooltip div from DOM, when prop not provided.
|
|
723
753
|
if (!this.props.showXAxisLablesTooltip) {
|
|
@@ -766,17 +796,16 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-shape", "d3-sele
|
|
|
766
796
|
activeLegend: '',
|
|
767
797
|
});
|
|
768
798
|
};
|
|
769
|
-
VerticalBarChartBase.prototype._renderBarLabel = function (xPoint, yPoint, barValue, legend) {
|
|
799
|
+
VerticalBarChartBase.prototype._renderBarLabel = function (xPoint, yPoint, barValue, legend, isNegativeBar) {
|
|
770
800
|
if (this.props.hideLabels ||
|
|
771
801
|
this._barWidth < 16 ||
|
|
772
802
|
!(this._legendHighlighted(legend) || this._noLegendHighlighted())) {
|
|
773
803
|
return null;
|
|
774
804
|
}
|
|
775
|
-
return (React.createElement("text", { x: xPoint + this._barWidth / 2, y: yPoint - 6, textAnchor: "middle", className: this._classNames.barLabel, "aria-hidden": true }, (0, index_2.formatValueWithSIPrefix)(barValue)));
|
|
805
|
+
return (React.createElement("text", { x: xPoint + this._barWidth / 2, y: isNegativeBar ? yPoint + 12 : yPoint - 6, textAnchor: "middle", className: this._classNames.barLabel, "aria-hidden": true }, (0, index_2.formatValueWithSIPrefix)(barValue)));
|
|
776
806
|
};
|
|
777
807
|
VerticalBarChartBase.prototype._isChartEmpty = function () {
|
|
778
|
-
return
|
|
779
|
-
((0, d3_array_1.max)(this._points, function (point) { return point.y; }) <= 0 && !this._isHavingLine));
|
|
808
|
+
return this._points.length === 0 || (this._points.every(function (point) { return point.y === 0; }) && !this._isHavingLine);
|
|
780
809
|
};
|
|
781
810
|
VerticalBarChartBase.defaultProps = {
|
|
782
811
|
maxBarWidth: 24,
|