@fluentui/react-charting 5.23.97 → 5.24.0
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 +36 -1
- package/CHANGELOG.md +17 -2
- package/dist/react-charting.d.ts +16 -7
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +9 -7
- package/lib/components/AreaChart/AreaChart.base.js +7 -4
- package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.base.d.ts +1 -2
- package/lib/components/CommonComponents/CartesianChart.base.js +31 -27
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.d.ts +2 -2
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +3 -2
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +1 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +10 -8
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.js +2 -2
- package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.base.js +6 -4
- package/lib/components/DonutChart/DonutChart.base.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.base.js +9 -9
- package/lib/components/GaugeChart/GaugeChart.base.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +2 -2
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.base.js +2 -2
- package/lib/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.base.js +7 -7
- package/lib/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib/components/LineChart/LineChart.base.js +8 -5
- package/lib/components/LineChart/LineChart.base.js.map +1 -1
- package/lib/components/PieChart/Arc/Arc.js +3 -3
- package/lib/components/PieChart/Arc/Arc.js.map +1 -1
- package/lib/components/StackedBarChart/MultiStackedBarChart.base.js +5 -5
- package/lib/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib/components/StackedBarChart/StackedBarChart.base.js +3 -5
- package/lib/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js +16 -7
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +4 -0
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +155 -40
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.d.ts +9 -0
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib/types/IDataPoint.d.ts +5 -5
- package/lib/types/IDataPoint.js.map +1 -1
- package/lib/utilities/ChartHoverCard/ChartHoverCard.base.js +5 -5
- package/lib/utilities/ChartHoverCard/ChartHoverCard.base.js.map +1 -1
- package/lib/utilities/utilities.d.ts +3 -6
- package/lib/utilities/utilities.js +22 -49
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/components/AreaChart/AreaChart.base.js +6 -4
- package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.d.ts +1 -2
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +31 -27
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +2 -2
- package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +2 -1
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +1 -0
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +15 -12
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/DonutChart/Arc/Arc.js +1 -1
- package/lib-amd/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-amd/components/DonutChart/DonutChart.base.js +5 -3
- package/lib-amd/components/DonutChart/DonutChart.base.js.map +1 -1
- package/lib-amd/components/GaugeChart/GaugeChart.base.js +8 -8
- package/lib-amd/components/GaugeChart/GaugeChart.base.js.map +1 -1
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +1 -1
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/HeatMapChart/HeatMapChart.base.js +2 -2
- package/lib-amd/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.js +6 -6
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.base.js +7 -5
- package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-amd/components/PieChart/Arc/Arc.js +3 -3
- package/lib-amd/components/PieChart/Arc/Arc.js.map +1 -1
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.js +4 -4
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib-amd/components/StackedBarChart/StackedBarChart.base.js +3 -5
- package/lib-amd/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +15 -7
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +4 -0
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +154 -40
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.types.d.ts +9 -0
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib-amd/types/IDataPoint.d.ts +5 -5
- package/lib-amd/types/IDataPoint.js.map +1 -1
- package/lib-amd/utilities/ChartHoverCard/ChartHoverCard.base.js +5 -5
- package/lib-amd/utilities/ChartHoverCard/ChartHoverCard.base.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +3 -6
- package/lib-amd/utilities/utilities.js +25 -55
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.base.js +6 -3
- package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.d.ts +1 -2
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +31 -27
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +2 -2
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +2 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +1 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +15 -12
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.base.js +5 -3
- package/lib-commonjs/components/DonutChart/DonutChart.base.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.base.js +8 -8
- package/lib-commonjs/components/GaugeChart/GaugeChart.base.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js +2 -2
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.js +6 -6
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.base.js +7 -4
- package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-commonjs/components/PieChart/Arc/Arc.js +3 -3
- package/lib-commonjs/components/PieChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.js +4 -4
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/components/StackedBarChart/StackedBarChart.base.js +3 -5
- package/lib-commonjs/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +15 -6
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +4 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +154 -39
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.d.ts +9 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib-commonjs/types/IDataPoint.d.ts +5 -5
- package/lib-commonjs/types/IDataPoint.js.map +1 -1
- package/lib-commonjs/utilities/ChartHoverCard/ChartHoverCard.base.js +5 -5
- package/lib-commonjs/utilities/ChartHoverCard/ChartHoverCard.base.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +3 -6
- package/lib-commonjs/utilities/utilities.js +26 -55
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +2 -2
- package/src/components/CommonComponents/CartesianChart.types.ts +2 -1
- package/src/components/VerticalStackedBarChart/VerticalStackedBarChart.types.ts +11 -0
- package/lib/utilities/locale-util.d.ts +0 -3
- package/lib/utilities/locale-util.js +0 -18
- package/lib/utilities/locale-util.js.map +0 -1
- package/lib-amd/utilities/locale-util.d.ts +0 -3
- package/lib-amd/utilities/locale-util.js +0 -24
- package/lib-amd/utilities/locale-util.js.map +0 -1
- package/lib-commonjs/utilities/locale-util.d.ts +0 -3
- package/lib-commonjs/utilities/locale-util.js +0 -22
- package/lib-commonjs/utilities/locale-util.js.map +0 -1
|
@@ -11,6 +11,7 @@ var Callout_1 = require("@fluentui/react/lib/Callout");
|
|
|
11
11
|
var index_1 = require("../Legends/index");
|
|
12
12
|
var index_2 = require("../../index");
|
|
13
13
|
var react_focus_1 = require("@fluentui/react-focus");
|
|
14
|
+
var chart_utilities_1 = require("@fluentui/chart-utilities");
|
|
14
15
|
var index_3 = require("../../utilities/index");
|
|
15
16
|
var image_export_utils_1 = require("../../utilities/image-export-utils");
|
|
16
17
|
var getClassNames = (0, Utilities_1.classNamesFunction)();
|
|
@@ -28,6 +29,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
28
29
|
var _this = _super.call(this, props) || this;
|
|
29
30
|
_this._isRtl = (0, Utilities_1.getRTL)();
|
|
30
31
|
_this.Y_ORIGIN = 0;
|
|
32
|
+
_this._yAxisLabels = [];
|
|
31
33
|
_this.toImage = function (opts) {
|
|
32
34
|
var _a, _b;
|
|
33
35
|
return (0, image_export_utils_1.toImage)((_a = _this._cartesianChartRef.current) === null || _a === void 0 ? void 0 : _a.chartContainer, (_b = _this._legendsRef.current) === null || _b === void 0 ? void 0 : _b.toSVG, _this._isRtl, opts);
|
|
@@ -124,13 +126,20 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
124
126
|
var useSecondaryYScale = lineObject[item][i - 1].useSecondaryYScale && lineObject[item][i].useSecondaryYScale && yScaleSecondary;
|
|
125
127
|
var y1 = useSecondaryYScale
|
|
126
128
|
? yScaleSecondary(lineObject[item][i - 1].y)
|
|
127
|
-
:
|
|
129
|
+
: //eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
130
|
+
yScalePrimary(lineObject[item][i - 1].y);
|
|
128
131
|
var x2 = xScale(lineObject[item][i].xItem.xAxisPoint);
|
|
129
|
-
var y2 = useSecondaryYScale
|
|
132
|
+
var y2 = useSecondaryYScale
|
|
133
|
+
? yScaleSecondary(lineObject[item][i].y)
|
|
134
|
+
: //eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
135
|
+
yScalePrimary(lineObject[item][i].y);
|
|
136
|
+
var yScaleBandwidthTranslate = !useSecondaryYScale && _this._yAxisType === index_3.YAxisType.StringAxis
|
|
137
|
+
? yScalePrimary.bandwidth() / 2
|
|
138
|
+
: 0;
|
|
130
139
|
if (lineBorderWidth > 0) {
|
|
131
|
-
borderForLines.push(React.createElement("line", { key: "".concat(index, "-").concat(i, "-BorderLine"), x1: x1, y1: y1, x2: x2, y2: y2, opacity: shouldHighlight ? 1 : 0.1, strokeWidth: 3 + lineBorderWidth * 2, fill: "transparent", strokeLinecap: "round", stroke: theme.semanticColors.bodyBackground, transform: "translate(".concat(xScaleBandwidthTranslate, ",
|
|
140
|
+
borderForLines.push(React.createElement("line", { key: "".concat(index, "-").concat(i, "-BorderLine"), x1: x1, y1: y1, x2: x2, y2: y2, opacity: shouldHighlight ? 1 : 0.1, strokeWidth: 3 + lineBorderWidth * 2, fill: "transparent", strokeLinecap: "round", stroke: theme.semanticColors.bodyBackground, transform: "translate(".concat(xScaleBandwidthTranslate, ", ").concat(yScaleBandwidthTranslate, ")") }));
|
|
132
141
|
}
|
|
133
|
-
lines.push(React.createElement("line", { key: "".concat(index, "-").concat(i, "-line"), x1: x1, y1: y1, x2: x2, y2: y2, opacity: shouldHighlight ? 1 : 0.1, strokeWidth: (_b = (_a = lineObject[item][0].lineOptions) === null || _a === void 0 ? void 0 : _a.strokeWidth) !== null && _b !== void 0 ? _b : 3, strokeLinecap: (_d = (_c = lineObject[item][0].lineOptions) === null || _c === void 0 ? void 0 : _c.strokeLinecap) !== null && _d !== void 0 ? _d : 'round', strokeDasharray: (_e = lineObject[item][0].lineOptions) === null || _e === void 0 ? void 0 : _e.strokeDasharray, stroke: lineObject[item][i].color, transform: "translate(".concat(xScaleBandwidthTranslate, ",
|
|
142
|
+
lines.push(React.createElement("line", { key: "".concat(index, "-").concat(i, "-line"), x1: x1, y1: y1, x2: x2, y2: y2, opacity: shouldHighlight ? 1 : 0.1, strokeWidth: (_b = (_a = lineObject[item][0].lineOptions) === null || _a === void 0 ? void 0 : _a.strokeWidth) !== null && _b !== void 0 ? _b : 3, strokeLinecap: (_d = (_c = lineObject[item][0].lineOptions) === null || _c === void 0 ? void 0 : _c.strokeLinecap) !== null && _d !== void 0 ? _d : 'round', strokeDasharray: (_e = lineObject[item][0].lineOptions) === null || _e === void 0 ? void 0 : _e.strokeDasharray, stroke: lineObject[item][i].color, transform: "translate(".concat(xScaleBandwidthTranslate, ", ").concat(yScaleBandwidthTranslate, ")"), onMouseOver: _this._lineHover.bind(_this, lineObject[item][i - 1]), onMouseLeave: _this._handleMouseOut }));
|
|
134
143
|
}
|
|
135
144
|
});
|
|
136
145
|
Object.keys(lineObject).forEach(function (item, index) {
|
|
@@ -138,12 +147,16 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
138
147
|
// Create an object to store line point ref so that the object can be passed by reference to the focus handler
|
|
139
148
|
var circleRef = { refElement: null };
|
|
140
149
|
var noBarsActive = circlePoint.xItem.chartData.filter(function (dataPoint) { return _this._noLegendHighlighted() || _this._isLegendHighlighted(dataPoint.legend); }).length === 0;
|
|
150
|
+
var yScaleBandwidthTranslate = !circlePoint.useSecondaryYScale && _this._yAxisType === index_3.YAxisType.StringAxis
|
|
151
|
+
? yScalePrimary.bandwidth() / 2
|
|
152
|
+
: 0;
|
|
141
153
|
dots.push(React.createElement("circle", tslib_1.__assign({ key: "".concat(index, "-").concat(subIndex, "-dot"), cx: xScale(circlePoint.xItem.xAxisPoint), cy: circlePoint.useSecondaryYScale && yScaleSecondary
|
|
142
154
|
? yScaleSecondary(circlePoint.y)
|
|
143
|
-
:
|
|
155
|
+
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
156
|
+
yScalePrimary(circlePoint.y), onMouseOver: _this._lineHover.bind(_this, circlePoint), onMouseLeave: _this._handleMouseOut, r: _this._getCircleOpacityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).radius, stroke: circlePoint.color, fill: _this.props.theme.semanticColors.bodyBackground, strokeWidth: 3,
|
|
144
157
|
// Elements with visibility: hidden cannot receive focus, so use opacity: 0 instead to hide them.
|
|
145
158
|
// For more information, see https://fuzzbomb.github.io/accessibility-demos/visually-hidden-focus-test.html
|
|
146
|
-
opacity: _this._getCircleOpacityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).opacity, transform: "translate(".concat(xScaleBandwidthTranslate, ",
|
|
159
|
+
opacity: _this._getCircleOpacityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).opacity, transform: "translate(".concat(xScaleBandwidthTranslate, ", ").concat(yScaleBandwidthTranslate, ")"), ref: function (e) { return (circleRef.refElement = e); } }, (noBarsActive && (_this._noLegendHighlighted() || _this._isLegendHighlighted(item))
|
|
147
160
|
? {
|
|
148
161
|
'data-is-focusable': !_this.props.hideTooltip,
|
|
149
162
|
onFocus: _this._lineFocus.bind(_this, circlePoint, circleRef),
|
|
@@ -246,7 +259,12 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
246
259
|
var xScaleBandwidthTranslate = _this._xAxisType !== index_3.XAxisTypes.StringAxis ? -_this._barWidth / 2 : (xBarScale.bandwidth() - _this._barWidth) / 2;
|
|
247
260
|
var barTotalValue = 0;
|
|
248
261
|
// Removing datapoints with zero data
|
|
249
|
-
var barsToDisplay = singleChartData.chartData.filter(function (point) {
|
|
262
|
+
var barsToDisplay = singleChartData.chartData.filter(function (point) {
|
|
263
|
+
return point.data !== 0 &&
|
|
264
|
+
point.data !== '' &&
|
|
265
|
+
!(_this._yAxisType === index_3.YAxisType.StringAxis &&
|
|
266
|
+
typeof yBarScale(point.data) === 'undefined');
|
|
267
|
+
});
|
|
250
268
|
if (!barsToDisplay.length) {
|
|
251
269
|
return undefined;
|
|
252
270
|
}
|
|
@@ -254,7 +272,9 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
254
272
|
if (heightValueScale < 0) {
|
|
255
273
|
return undefined;
|
|
256
274
|
}
|
|
257
|
-
var yBaseline = containerHeight -
|
|
275
|
+
var yBaseline = containerHeight -
|
|
276
|
+
_this.margins.bottom -
|
|
277
|
+
(_this._yAxisType === index_3.YAxisType.StringAxis ? 0 : yBarScale(_this.Y_ORIGIN));
|
|
258
278
|
var yPositiveStart = yBaseline;
|
|
259
279
|
var yNegativeStart = yBaseline;
|
|
260
280
|
var yPoint = 0;
|
|
@@ -287,22 +307,33 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
287
307
|
onClick: _this._onClick.bind(_this, point),
|
|
288
308
|
role: 'img',
|
|
289
309
|
};
|
|
290
|
-
var barHeight
|
|
291
|
-
var minHeight = Math.max((heightValueScale * adjustedTotalHeight) / 100.0, barMinimumHeight);
|
|
292
|
-
if (barHeight < minHeight) {
|
|
293
|
-
barHeight = minHeight;
|
|
294
|
-
}
|
|
310
|
+
var barHeight;
|
|
295
311
|
var gapOffset = index ? gapHeight : 0;
|
|
296
|
-
if (
|
|
312
|
+
if (_this._yAxisType === index_3.YAxisType.StringAxis) {
|
|
313
|
+
barHeight = Math.max(containerHeight -
|
|
314
|
+
_this.margins.bottom -
|
|
315
|
+
(yBarScale(point.data) + yBarScale.bandwidth() / 2) -
|
|
316
|
+
gapOffset, barMinimumHeight, 1);
|
|
297
317
|
yPositiveStart -= barHeight + gapOffset;
|
|
298
318
|
yPoint = yPositiveStart;
|
|
299
319
|
}
|
|
300
320
|
else {
|
|
301
|
-
|
|
302
|
-
|
|
321
|
+
barHeight = Math.abs(heightValueScale * point.data);
|
|
322
|
+
var minHeight = Math.max((heightValueScale * adjustedTotalHeight) / 100.0, barMinimumHeight);
|
|
323
|
+
if (barHeight < minHeight) {
|
|
324
|
+
barHeight = minHeight;
|
|
325
|
+
}
|
|
326
|
+
if (point.data >= _this.Y_ORIGIN) {
|
|
327
|
+
yPositiveStart -= barHeight + gapOffset;
|
|
328
|
+
yPoint = yPositiveStart;
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
yPoint = yNegativeStart + gapOffset;
|
|
332
|
+
yNegativeStart = yPoint + barHeight;
|
|
333
|
+
}
|
|
334
|
+
barTotalValue += point.data;
|
|
335
|
+
heightOfLastBar = index === barsToDisplay.length - 1 ? barHeight : 0;
|
|
303
336
|
}
|
|
304
|
-
barTotalValue += point.data;
|
|
305
|
-
heightOfLastBar = index === barsToDisplay.length - 1 ? barHeight : 0;
|
|
306
337
|
var gradientId = (0, Utilities_1.getId)('VSBC_Gradient') + "_".concat(indexNumber, "_").concat(index);
|
|
307
338
|
// If set, apply the corner radius to the top of the final bar
|
|
308
339
|
if (barCornerRadius && barHeight > barCornerRadius && index === barsToDisplay.length - 1) {
|
|
@@ -342,7 +373,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
342
373
|
};
|
|
343
374
|
var showLabel = false;
|
|
344
375
|
var barLabel = 0;
|
|
345
|
-
if (!_this.props.hideLabels) {
|
|
376
|
+
if (!_this.props.hideLabels && _this._yAxisType !== index_3.YAxisType.StringAxis) {
|
|
346
377
|
if (_this._noLegendHighlighted()) {
|
|
347
378
|
showLabel = true;
|
|
348
379
|
barLabel = barTotalValue;
|
|
@@ -360,7 +391,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
360
391
|
React.createElement("g", tslib_1.__assign({ id: "".concat(indexNumber, "-singleBar"), ref: function (e) { return (groupRef.refElement = e); } }, stackFocusProps), singleBar),
|
|
361
392
|
!_this.props.hideLabels && _this._barWidth >= 16 && showLabel && (React.createElement("text", { x: xPoint + _this._barWidth / 2,
|
|
362
393
|
//if total bar value >=0, show label above top bar, otherwise below bottom bar
|
|
363
|
-
y: barLabel >= _this.Y_ORIGIN ? yPoint - 6 : yPoint + heightOfLastBar + 12, textAnchor: "middle", className: _this._classNames.barLabel, "aria-label": "Total: ".concat(barLabel), role: "img", transform: "translate(".concat(xScaleBandwidthTranslate, ", 0)") }, (0, index_3.
|
|
394
|
+
y: barLabel >= _this.Y_ORIGIN ? yPoint - 6 : yPoint + heightOfLastBar + 12, textAnchor: "middle", className: _this._classNames.barLabel, "aria-label": "Total: ".concat(barLabel), role: "img", transform: "translate(".concat(xScaleBandwidthTranslate, ", 0)") }, (0, index_3.formatScientificLimitWidth)(barLabel)))));
|
|
364
395
|
});
|
|
365
396
|
// Removing un wanted tooltip div from DOM, when prop not provided.
|
|
366
397
|
if (!_this.props.showXAxisLablesTooltip) {
|
|
@@ -429,7 +460,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
429
460
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
430
461
|
xScale, yScale, containerHeight, containerWidth, xElement) {
|
|
431
462
|
var _a = _this._getScales(containerHeight, containerWidth), xBarScale = _a.xBarScale, yBarScale = _a.yBarScale;
|
|
432
|
-
return (_this._bars = _this._createBar(xBarScale, yBarScale, containerHeight, xElement));
|
|
463
|
+
return (_this._bars = _this._createBar(xBarScale, _this._yAxisType === index_3.YAxisType.StringAxis ? yScale : yBarScale, containerHeight, xElement));
|
|
433
464
|
};
|
|
434
465
|
_this._closeCallout = function () {
|
|
435
466
|
_this.setState({
|
|
@@ -464,7 +495,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
464
495
|
/** if shouldFocusWholeStack is true */
|
|
465
496
|
var xValue_1 = singleChartData.xAxisCalloutData ||
|
|
466
497
|
(singleChartData.xAxisPoint instanceof Date
|
|
467
|
-
? (0,
|
|
498
|
+
? (0, chart_utilities_1.formatDateToLocaleString)(singleChartData.xAxisPoint, _this.props.culture, _this.props.useUTC)
|
|
468
499
|
: singleChartData.xAxisPoint);
|
|
469
500
|
var pointValues = singleChartData.chartData
|
|
470
501
|
.map(function (pt) {
|
|
@@ -486,7 +517,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
486
517
|
var xValue = singleChartData.xAxisCalloutData ||
|
|
487
518
|
(!isLinePoint && point.xAxisCalloutData) ||
|
|
488
519
|
(singleChartData.xAxisPoint instanceof Date
|
|
489
|
-
? (0,
|
|
520
|
+
? (0, chart_utilities_1.formatDateToLocaleString)(singleChartData.xAxisPoint, _this.props.culture, _this.props.useUTC)
|
|
490
521
|
: singleChartData.xAxisPoint);
|
|
491
522
|
var legend = point.legend;
|
|
492
523
|
var yValue = point.yAxisCalloutData ||
|
|
@@ -564,6 +595,70 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
564
595
|
});
|
|
565
596
|
return { startValue: (0, d3_array_1.min)(values), endValue: (0, d3_array_1.max)(values) };
|
|
566
597
|
};
|
|
598
|
+
_this._initYAxisParams = function () {
|
|
599
|
+
if (_this._points[0].chartData.length > 0) {
|
|
600
|
+
_this._yAxisType = (0, index_3.getTypeOfAxis)(_this._points[0].chartData[0].data, false);
|
|
601
|
+
}
|
|
602
|
+
else {
|
|
603
|
+
Object.keys(_this._lineObject).forEach(function (lineLegend) {
|
|
604
|
+
if (!_this._lineObject[lineLegend][0].useSecondaryYScale) {
|
|
605
|
+
_this._yAxisType = (0, index_3.getTypeOfAxis)(_this._lineObject[lineLegend][0].y, false);
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
if (_this._yAxisType === index_3.YAxisType.StringAxis) {
|
|
610
|
+
var legendToYValues_1 = {};
|
|
611
|
+
_this._points.forEach(function (xPoint) {
|
|
612
|
+
xPoint.chartData.forEach(function (bar) {
|
|
613
|
+
if (!legendToYValues_1[bar.legend]) {
|
|
614
|
+
legendToYValues_1[bar.legend] = ["".concat(bar.data)];
|
|
615
|
+
}
|
|
616
|
+
else {
|
|
617
|
+
legendToYValues_1[bar.legend].push("".concat(bar.data));
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
});
|
|
621
|
+
var yAxisLabels_1 = new Set();
|
|
622
|
+
Object.values(legendToYValues_1).forEach(function (yValues) {
|
|
623
|
+
yValues.forEach(function (yVal) {
|
|
624
|
+
yAxisLabels_1.add(yVal);
|
|
625
|
+
});
|
|
626
|
+
});
|
|
627
|
+
Object.values(_this._lineObject).forEach(function (linePoints) {
|
|
628
|
+
linePoints.forEach(function (linePoint) {
|
|
629
|
+
if (!linePoint.useSecondaryYScale) {
|
|
630
|
+
yAxisLabels_1.add("".concat(linePoint.y));
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
_this._yAxisLabels = Array.from(yAxisLabels_1);
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
_this._getYDomainMargins = function (containerHeight) {
|
|
638
|
+
/**
|
|
639
|
+
* Specifies the extra top margin to apply above the highest y-axis tick label.
|
|
640
|
+
* Useful when stacked bars extend beyond the combined height of all y-axis labels (or categories).
|
|
641
|
+
*/
|
|
642
|
+
var yAxisTickMarginTop = 0;
|
|
643
|
+
/** Total height available to render the bars */
|
|
644
|
+
var totalHeight = containerHeight - _this.margins.bottom - _this.margins.top;
|
|
645
|
+
if (_this._yAxisType === index_3.YAxisType.StringAxis) {
|
|
646
|
+
/** Maximum height of the stacked bars, expressed in multiples of the height of a y-axis label (or category) */
|
|
647
|
+
var maxBarHeightInLabels_1 = 0;
|
|
648
|
+
_this._points.forEach(function (xPoint) {
|
|
649
|
+
/** Height of the stacked bar, expressed in multiples of the height of a y-axis label (or category) */
|
|
650
|
+
var barHeightInLabels = 0;
|
|
651
|
+
xPoint.chartData.forEach(function (bar) {
|
|
652
|
+
barHeightInLabels += _this._yAxisLabels.indexOf("".concat(bar.data)) + 1;
|
|
653
|
+
});
|
|
654
|
+
maxBarHeightInLabels_1 = Math.max(maxBarHeightInLabels_1, barHeightInLabels);
|
|
655
|
+
});
|
|
656
|
+
/** Height of a y-axis label (or category) */
|
|
657
|
+
var yAxisLabelHeight = maxBarHeightInLabels_1 === 0 ? 0 : totalHeight / maxBarHeightInLabels_1;
|
|
658
|
+
yAxisTickMarginTop += yAxisLabelHeight * (maxBarHeightInLabels_1 - _this._yAxisLabels.length);
|
|
659
|
+
}
|
|
660
|
+
return tslib_1.__assign(tslib_1.__assign({}, _this.margins), { top: _this.margins.top + yAxisTickMarginTop });
|
|
661
|
+
};
|
|
567
662
|
(0, Utilities_1.initializeComponentRef)(_this);
|
|
568
663
|
_this.state = {
|
|
569
664
|
isCalloutVisible: false,
|
|
@@ -632,7 +727,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
632
727
|
return (React.createElement(index_2.CartesianChart, tslib_1.__assign({}, this.props, { chartTitle: this._getChartTitle(), points: this._dataset, chartType: index_3.ChartTypes.VerticalStackedBarChart, xAxisType: this._xAxisType, calloutProps: calloutProps, createYAxis: index_3.createNumericYAxis, tickParams: tickParams, legendBars: legendBars, getMinMaxOfYAxis: this._getMinMaxOfYAxis, datasetForXAxisDomain: this._xAxisLabels, isCalloutForStack: shouldFocusWholeStack, getDomainNRangeValues: this._getDomainNRangeValues, createStringYAxis: index_3.createStringYAxis, barwidth: this._barWidth, focusZoneDirection: isCalloutForStack || _isHavingLines_1 ? react_focus_1.FocusZoneDirection.horizontal : react_focus_1.FocusZoneDirection.vertical, getmargins: this._getMargins, getGraphData: this._getGraphData, getAxisData: this._getAxisData, customizedCallout: this._getCustomizedCallout(), onChartMouseLeave: this._handleChartMouseLeave, getDomainMargins: this._getDomainMargins }, (this._xAxisType === index_3.XAxisTypes.StringAxis && {
|
|
633
728
|
xAxisInnerPadding: this._xAxisInnerPadding,
|
|
634
729
|
xAxisOuterPadding: this._xAxisOuterPadding,
|
|
635
|
-
}), { ref: this._cartesianChartRef, showRoundOffXTickValues: !(0, index_3.isScalePaddingDefined)(this.props.xAxisInnerPadding, this.props.xAxisPadding),
|
|
730
|
+
}), { ref: this._cartesianChartRef, showRoundOffXTickValues: !(0, index_3.isScalePaddingDefined)(this.props.xAxisInnerPadding, this.props.xAxisPadding), yAxisType: this._yAxisType, stringDatasetForYAxisDomain: tslib_1.__spreadArray([''], this._yAxisLabels, true), getYDomainMargins: this._getYDomainMargins,
|
|
636
731
|
/* eslint-disable react/jsx-no-bind */
|
|
637
732
|
children: function (props) {
|
|
638
733
|
return (React.createElement(React.Fragment, null,
|
|
@@ -662,15 +757,23 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
662
757
|
this._lineObject = this._getFormattedLineData(this.props.data);
|
|
663
758
|
this._xAxisInnerPadding = (0, index_3.getScalePadding)(this.props.xAxisInnerPadding, this.props.xAxisPadding, this._xAxisType === index_3.XAxisTypes.StringAxis ? 2 / 3 : 1 / 2);
|
|
664
759
|
this._xAxisOuterPadding = (0, index_3.getScalePadding)(this.props.xAxisOuterPadding, this.props.xAxisPadding, 0);
|
|
760
|
+
this._initYAxisParams();
|
|
665
761
|
};
|
|
666
762
|
VerticalStackedBarChartBase.prototype._createDataSetLayer = function () {
|
|
763
|
+
var _this = this;
|
|
667
764
|
var tempArr = [];
|
|
668
765
|
var dataset = this._points.map(function (singlePointData) {
|
|
766
|
+
tempArr.push(singlePointData.xAxisPoint);
|
|
767
|
+
if (_this._yAxisType === index_3.YAxisType.StringAxis) {
|
|
768
|
+
return {
|
|
769
|
+
x: singlePointData.xAxisPoint,
|
|
770
|
+
y: 0,
|
|
771
|
+
};
|
|
772
|
+
}
|
|
669
773
|
var total = 0;
|
|
670
774
|
singlePointData.chartData.forEach(function (point) {
|
|
671
775
|
total = total + point.data;
|
|
672
776
|
});
|
|
673
|
-
tempArr.push(singlePointData.xAxisPoint);
|
|
674
777
|
return {
|
|
675
778
|
x: singlePointData.xAxisPoint,
|
|
676
779
|
y: total,
|
|
@@ -817,7 +920,9 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
817
920
|
isCalloutVisible: stack.chartData.length > 0 || ((_c = (_b = stack.lineData) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 0,
|
|
818
921
|
YValueHover: isLinesPresent
|
|
819
922
|
? tslib_1.__spreadArray(tslib_1.__spreadArray([], lineData.sort(function (a, b) { return (a.data < b.data ? 1 : -1); }), true), stack.chartData.slice().reverse(), true) : stack.chartData.slice().reverse(),
|
|
820
|
-
hoverXValue: stack.xAxisPoint instanceof Date
|
|
923
|
+
hoverXValue: stack.xAxisPoint instanceof Date
|
|
924
|
+
? (0, chart_utilities_1.formatDateToLocaleString)(stack.xAxisPoint, this.props.culture, this.props.useUTC)
|
|
925
|
+
: stack.xAxisPoint,
|
|
821
926
|
stackCalloutProps: stack,
|
|
822
927
|
activeXAxisDataPoint: stack.xAxisPoint,
|
|
823
928
|
callOutAccessibilityData: stack.stackCallOutAccessibilityData,
|
|
@@ -840,22 +945,32 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
|
|
|
840
945
|
};
|
|
841
946
|
VerticalStackedBarChartBase.prototype._getBarGapAndScale = function (bars, yBarScale, defaultTotalHeight) {
|
|
842
947
|
var _a = this.props.barGapMax, barGapMax = _a === void 0 ? 0 : _a;
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
var totalData = bars.reduce(function (iter, value) { return iter + Math.abs(value.data); }, 0);
|
|
846
|
-
var totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : Math.abs(yBarScale(totalData) - yBarScale(this.Y_ORIGIN));
|
|
948
|
+
var totalData = 0;
|
|
949
|
+
var totalHeight;
|
|
847
950
|
var sumOfPercent = 0;
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
951
|
+
var scalingRatio;
|
|
952
|
+
if (this._yAxisType === index_3.YAxisType.StringAxis) {
|
|
953
|
+
totalHeight =
|
|
954
|
+
defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : bars.reduce(function (total, bar) { return total + yBarScale(bar.data); }, 0);
|
|
955
|
+
}
|
|
956
|
+
else {
|
|
957
|
+
// When displaying gaps between the bars, the height of each bar is
|
|
958
|
+
// adjusted so that the total of all bars is not changed by the gaps
|
|
959
|
+
totalData = bars.reduce(function (iter, value) { return iter + Math.abs(value.data); }, 0);
|
|
960
|
+
totalHeight =
|
|
961
|
+
defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : Math.abs(yBarScale(totalData) - yBarScale(this.Y_ORIGIN));
|
|
962
|
+
bars.forEach(function (point) {
|
|
963
|
+
var value = (Math.abs(point.data) / totalData) * 100;
|
|
964
|
+
if (value < 1 && value !== 0) {
|
|
965
|
+
value = 1;
|
|
966
|
+
}
|
|
967
|
+
sumOfPercent += value;
|
|
968
|
+
});
|
|
969
|
+
scalingRatio = sumOfPercent !== 0 ? sumOfPercent / 100 : 1;
|
|
970
|
+
}
|
|
856
971
|
var gaps = barGapMax && bars.length - 1;
|
|
857
972
|
var gapHeight = gaps && Math.max(barGapMin, Math.min(barGapMax, (totalHeight * barGapMultiplier) / gaps));
|
|
858
|
-
var heightValueScale = (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
|
|
973
|
+
var heightValueScale = this._yAxisType === index_3.YAxisType.StringAxis ? 0 : (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
|
|
859
974
|
return {
|
|
860
975
|
gapHeight: gapHeight,
|
|
861
976
|
heightValueScale: heightValueScale,
|