@fluentui/react-charting 5.23.97 → 5.24.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/CHANGELOG.json +51 -1
- package/CHANGELOG.md +26 -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 +19 -12
- 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 +24 -16
- 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 +24 -16
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-scale", "@fluentui/react/lib/Utilities", "@fluentui/react/lib/Callout", "../Legends/index", "../../index", "@fluentui/react-focus", "../../utilities/index", "../../utilities/image-export-utils"], function (require, exports, tslib_1, React, d3_array_1, d3_selection_1, d3_scale_1, Utilities_1, Callout_1, index_1, index_2, react_focus_1, index_3, image_export_utils_1) {
|
|
1
|
+
define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-scale", "@fluentui/react/lib/Utilities", "@fluentui/react/lib/Callout", "../Legends/index", "../../index", "@fluentui/react-focus", "@fluentui/chart-utilities", "../../utilities/index", "../../utilities/image-export-utils"], function (require, exports, tslib_1, React, d3_array_1, d3_selection_1, d3_scale_1, Utilities_1, Callout_1, index_1, index_2, react_focus_1, chart_utilities_1, index_3, image_export_utils_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.VerticalStackedBarChartBase = void 0;
|
|
@@ -17,6 +17,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
17
17
|
var _this = _super.call(this, props) || this;
|
|
18
18
|
_this._isRtl = (0, Utilities_1.getRTL)();
|
|
19
19
|
_this.Y_ORIGIN = 0;
|
|
20
|
+
_this._yAxisLabels = [];
|
|
20
21
|
_this.toImage = function (opts) {
|
|
21
22
|
var _a, _b;
|
|
22
23
|
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);
|
|
@@ -113,13 +114,20 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
113
114
|
var useSecondaryYScale = lineObject[item][i - 1].useSecondaryYScale && lineObject[item][i].useSecondaryYScale && yScaleSecondary;
|
|
114
115
|
var y1 = useSecondaryYScale
|
|
115
116
|
? yScaleSecondary(lineObject[item][i - 1].y)
|
|
116
|
-
:
|
|
117
|
+
: //eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
+
yScalePrimary(lineObject[item][i - 1].y);
|
|
117
119
|
var x2 = xScale(lineObject[item][i].xItem.xAxisPoint);
|
|
118
|
-
var y2 = useSecondaryYScale
|
|
120
|
+
var y2 = useSecondaryYScale
|
|
121
|
+
? yScaleSecondary(lineObject[item][i].y)
|
|
122
|
+
: //eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
123
|
+
yScalePrimary(lineObject[item][i].y);
|
|
124
|
+
var yScaleBandwidthTranslate = !useSecondaryYScale && _this._yAxisType === index_3.YAxisType.StringAxis
|
|
125
|
+
? yScalePrimary.bandwidth() / 2
|
|
126
|
+
: 0;
|
|
119
127
|
if (lineBorderWidth > 0) {
|
|
120
|
-
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, ",
|
|
128
|
+
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, ")") }));
|
|
121
129
|
}
|
|
122
|
-
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, ",
|
|
130
|
+
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 }));
|
|
123
131
|
}
|
|
124
132
|
});
|
|
125
133
|
Object.keys(lineObject).forEach(function (item, index) {
|
|
@@ -127,12 +135,16 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
127
135
|
// Create an object to store line point ref so that the object can be passed by reference to the focus handler
|
|
128
136
|
var circleRef = { refElement: null };
|
|
129
137
|
var noBarsActive = circlePoint.xItem.chartData.filter(function (dataPoint) { return _this._noLegendHighlighted() || _this._isLegendHighlighted(dataPoint.legend); }).length === 0;
|
|
138
|
+
var yScaleBandwidthTranslate = !circlePoint.useSecondaryYScale && _this._yAxisType === index_3.YAxisType.StringAxis
|
|
139
|
+
? yScalePrimary.bandwidth() / 2
|
|
140
|
+
: 0;
|
|
130
141
|
dots.push(React.createElement("circle", tslib_1.__assign({ key: "".concat(index, "-").concat(subIndex, "-dot"), cx: xScale(circlePoint.xItem.xAxisPoint), cy: circlePoint.useSecondaryYScale && yScaleSecondary
|
|
131
142
|
? yScaleSecondary(circlePoint.y)
|
|
132
|
-
:
|
|
143
|
+
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
144
|
+
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,
|
|
133
145
|
// Elements with visibility: hidden cannot receive focus, so use opacity: 0 instead to hide them.
|
|
134
146
|
// For more information, see https://fuzzbomb.github.io/accessibility-demos/visually-hidden-focus-test.html
|
|
135
|
-
opacity: _this._getCircleOpacityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).opacity, transform: "translate(".concat(xScaleBandwidthTranslate, ",
|
|
147
|
+
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))
|
|
136
148
|
? {
|
|
137
149
|
'data-is-focusable': !_this.props.hideTooltip,
|
|
138
150
|
onFocus: _this._lineFocus.bind(_this, circlePoint, circleRef),
|
|
@@ -235,7 +247,12 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
235
247
|
var xScaleBandwidthTranslate = _this._xAxisType !== index_3.XAxisTypes.StringAxis ? -_this._barWidth / 2 : (xBarScale.bandwidth() - _this._barWidth) / 2;
|
|
236
248
|
var barTotalValue = 0;
|
|
237
249
|
// Removing datapoints with zero data
|
|
238
|
-
var barsToDisplay = singleChartData.chartData.filter(function (point) {
|
|
250
|
+
var barsToDisplay = singleChartData.chartData.filter(function (point) {
|
|
251
|
+
return point.data !== 0 &&
|
|
252
|
+
point.data !== '' &&
|
|
253
|
+
!(_this._yAxisType === index_3.YAxisType.StringAxis &&
|
|
254
|
+
typeof yBarScale(point.data) === 'undefined');
|
|
255
|
+
});
|
|
239
256
|
if (!barsToDisplay.length) {
|
|
240
257
|
return undefined;
|
|
241
258
|
}
|
|
@@ -243,7 +260,9 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
243
260
|
if (heightValueScale < 0) {
|
|
244
261
|
return undefined;
|
|
245
262
|
}
|
|
246
|
-
var yBaseline = containerHeight -
|
|
263
|
+
var yBaseline = containerHeight -
|
|
264
|
+
_this.margins.bottom -
|
|
265
|
+
(_this._yAxisType === index_3.YAxisType.StringAxis ? 0 : yBarScale(_this.Y_ORIGIN));
|
|
247
266
|
var yPositiveStart = yBaseline;
|
|
248
267
|
var yNegativeStart = yBaseline;
|
|
249
268
|
var yPoint = 0;
|
|
@@ -276,22 +295,33 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
276
295
|
onClick: _this._onClick.bind(_this, point),
|
|
277
296
|
role: 'img',
|
|
278
297
|
};
|
|
279
|
-
var barHeight
|
|
280
|
-
var minHeight = Math.max((heightValueScale * adjustedTotalHeight) / 100.0, barMinimumHeight);
|
|
281
|
-
if (barHeight < minHeight) {
|
|
282
|
-
barHeight = minHeight;
|
|
283
|
-
}
|
|
298
|
+
var barHeight;
|
|
284
299
|
var gapOffset = index ? gapHeight : 0;
|
|
285
|
-
if (
|
|
300
|
+
if (_this._yAxisType === index_3.YAxisType.StringAxis) {
|
|
301
|
+
barHeight = Math.max(containerHeight -
|
|
302
|
+
_this.margins.bottom -
|
|
303
|
+
(yBarScale(point.data) + yBarScale.bandwidth() / 2) -
|
|
304
|
+
gapOffset, barMinimumHeight, 1);
|
|
286
305
|
yPositiveStart -= barHeight + gapOffset;
|
|
287
306
|
yPoint = yPositiveStart;
|
|
288
307
|
}
|
|
289
308
|
else {
|
|
290
|
-
|
|
291
|
-
|
|
309
|
+
barHeight = Math.abs(heightValueScale * point.data);
|
|
310
|
+
var minHeight = Math.max((heightValueScale * adjustedTotalHeight) / 100.0, barMinimumHeight);
|
|
311
|
+
if (barHeight < minHeight) {
|
|
312
|
+
barHeight = minHeight;
|
|
313
|
+
}
|
|
314
|
+
if (point.data >= _this.Y_ORIGIN) {
|
|
315
|
+
yPositiveStart -= barHeight + gapOffset;
|
|
316
|
+
yPoint = yPositiveStart;
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
yPoint = yNegativeStart + gapOffset;
|
|
320
|
+
yNegativeStart = yPoint + barHeight;
|
|
321
|
+
}
|
|
322
|
+
barTotalValue += point.data;
|
|
323
|
+
heightOfLastBar = index === barsToDisplay.length - 1 ? barHeight : 0;
|
|
292
324
|
}
|
|
293
|
-
barTotalValue += point.data;
|
|
294
|
-
heightOfLastBar = index === barsToDisplay.length - 1 ? barHeight : 0;
|
|
295
325
|
var gradientId = (0, Utilities_1.getId)('VSBC_Gradient') + "_".concat(indexNumber, "_").concat(index);
|
|
296
326
|
// If set, apply the corner radius to the top of the final bar
|
|
297
327
|
if (barCornerRadius && barHeight > barCornerRadius && index === barsToDisplay.length - 1) {
|
|
@@ -331,7 +361,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
331
361
|
};
|
|
332
362
|
var showLabel = false;
|
|
333
363
|
var barLabel = 0;
|
|
334
|
-
if (!_this.props.hideLabels) {
|
|
364
|
+
if (!_this.props.hideLabels && _this._yAxisType !== index_3.YAxisType.StringAxis) {
|
|
335
365
|
if (_this._noLegendHighlighted()) {
|
|
336
366
|
showLabel = true;
|
|
337
367
|
barLabel = barTotalValue;
|
|
@@ -349,7 +379,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
349
379
|
React.createElement("g", tslib_1.__assign({ id: "".concat(indexNumber, "-singleBar"), ref: function (e) { return (groupRef.refElement = e); } }, stackFocusProps), singleBar),
|
|
350
380
|
!_this.props.hideLabels && _this._barWidth >= 16 && showLabel && (React.createElement("text", { x: xPoint + _this._barWidth / 2,
|
|
351
381
|
//if total bar value >=0, show label above top bar, otherwise below bottom bar
|
|
352
|
-
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.
|
|
382
|
+
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)))));
|
|
353
383
|
});
|
|
354
384
|
// Removing un wanted tooltip div from DOM, when prop not provided.
|
|
355
385
|
if (!_this.props.showXAxisLablesTooltip) {
|
|
@@ -418,7 +448,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
418
448
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
419
449
|
xScale, yScale, containerHeight, containerWidth, xElement) {
|
|
420
450
|
var _a = _this._getScales(containerHeight, containerWidth), xBarScale = _a.xBarScale, yBarScale = _a.yBarScale;
|
|
421
|
-
return (_this._bars = _this._createBar(xBarScale, yBarScale, containerHeight, xElement));
|
|
451
|
+
return (_this._bars = _this._createBar(xBarScale, _this._yAxisType === index_3.YAxisType.StringAxis ? yScale : yBarScale, containerHeight, xElement));
|
|
422
452
|
};
|
|
423
453
|
_this._closeCallout = function () {
|
|
424
454
|
_this.setState({
|
|
@@ -453,7 +483,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
453
483
|
/** if shouldFocusWholeStack is true */
|
|
454
484
|
var xValue_1 = singleChartData.xAxisCalloutData ||
|
|
455
485
|
(singleChartData.xAxisPoint instanceof Date
|
|
456
|
-
? (0,
|
|
486
|
+
? (0, chart_utilities_1.formatDateToLocaleString)(singleChartData.xAxisPoint, _this.props.culture, _this.props.useUTC)
|
|
457
487
|
: singleChartData.xAxisPoint);
|
|
458
488
|
var pointValues = singleChartData.chartData
|
|
459
489
|
.map(function (pt) {
|
|
@@ -475,7 +505,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
475
505
|
var xValue = singleChartData.xAxisCalloutData ||
|
|
476
506
|
(!isLinePoint && point.xAxisCalloutData) ||
|
|
477
507
|
(singleChartData.xAxisPoint instanceof Date
|
|
478
|
-
? (0,
|
|
508
|
+
? (0, chart_utilities_1.formatDateToLocaleString)(singleChartData.xAxisPoint, _this.props.culture, _this.props.useUTC)
|
|
479
509
|
: singleChartData.xAxisPoint);
|
|
480
510
|
var legend = point.legend;
|
|
481
511
|
var yValue = point.yAxisCalloutData ||
|
|
@@ -553,6 +583,70 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
553
583
|
});
|
|
554
584
|
return { startValue: (0, d3_array_1.min)(values), endValue: (0, d3_array_1.max)(values) };
|
|
555
585
|
};
|
|
586
|
+
_this._initYAxisParams = function () {
|
|
587
|
+
if (_this._points[0].chartData.length > 0) {
|
|
588
|
+
_this._yAxisType = (0, index_3.getTypeOfAxis)(_this._points[0].chartData[0].data, false);
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
Object.keys(_this._lineObject).forEach(function (lineLegend) {
|
|
592
|
+
if (!_this._lineObject[lineLegend][0].useSecondaryYScale) {
|
|
593
|
+
_this._yAxisType = (0, index_3.getTypeOfAxis)(_this._lineObject[lineLegend][0].y, false);
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
if (_this._yAxisType === index_3.YAxisType.StringAxis) {
|
|
598
|
+
var legendToYValues_1 = {};
|
|
599
|
+
_this._points.forEach(function (xPoint) {
|
|
600
|
+
xPoint.chartData.forEach(function (bar) {
|
|
601
|
+
if (!legendToYValues_1[bar.legend]) {
|
|
602
|
+
legendToYValues_1[bar.legend] = ["".concat(bar.data)];
|
|
603
|
+
}
|
|
604
|
+
else {
|
|
605
|
+
legendToYValues_1[bar.legend].push("".concat(bar.data));
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
});
|
|
609
|
+
var yAxisLabels_1 = new Set();
|
|
610
|
+
Object.values(legendToYValues_1).forEach(function (yValues) {
|
|
611
|
+
yValues.forEach(function (yVal) {
|
|
612
|
+
yAxisLabels_1.add(yVal);
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
Object.values(_this._lineObject).forEach(function (linePoints) {
|
|
616
|
+
linePoints.forEach(function (linePoint) {
|
|
617
|
+
if (!linePoint.useSecondaryYScale) {
|
|
618
|
+
yAxisLabels_1.add("".concat(linePoint.y));
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
});
|
|
622
|
+
_this._yAxisLabels = Array.from(yAxisLabels_1);
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
_this._getYDomainMargins = function (containerHeight) {
|
|
626
|
+
/**
|
|
627
|
+
* Specifies the extra top margin to apply above the highest y-axis tick label.
|
|
628
|
+
* Useful when stacked bars extend beyond the combined height of all y-axis labels (or categories).
|
|
629
|
+
*/
|
|
630
|
+
var yAxisTickMarginTop = 0;
|
|
631
|
+
/** Total height available to render the bars */
|
|
632
|
+
var totalHeight = containerHeight - _this.margins.bottom - _this.margins.top;
|
|
633
|
+
if (_this._yAxisType === index_3.YAxisType.StringAxis) {
|
|
634
|
+
/** Maximum height of the stacked bars, expressed in multiples of the height of a y-axis label (or category) */
|
|
635
|
+
var maxBarHeightInLabels_1 = 0;
|
|
636
|
+
_this._points.forEach(function (xPoint) {
|
|
637
|
+
/** Height of the stacked bar, expressed in multiples of the height of a y-axis label (or category) */
|
|
638
|
+
var barHeightInLabels = 0;
|
|
639
|
+
xPoint.chartData.forEach(function (bar) {
|
|
640
|
+
barHeightInLabels += _this._yAxisLabels.indexOf("".concat(bar.data)) + 1;
|
|
641
|
+
});
|
|
642
|
+
maxBarHeightInLabels_1 = Math.max(maxBarHeightInLabels_1, barHeightInLabels);
|
|
643
|
+
});
|
|
644
|
+
/** Height of a y-axis label (or category) */
|
|
645
|
+
var yAxisLabelHeight = maxBarHeightInLabels_1 === 0 ? 0 : totalHeight / maxBarHeightInLabels_1;
|
|
646
|
+
yAxisTickMarginTop += yAxisLabelHeight * (maxBarHeightInLabels_1 - _this._yAxisLabels.length);
|
|
647
|
+
}
|
|
648
|
+
return tslib_1.__assign(tslib_1.__assign({}, _this.margins), { top: _this.margins.top + yAxisTickMarginTop });
|
|
649
|
+
};
|
|
556
650
|
(0, Utilities_1.initializeComponentRef)(_this);
|
|
557
651
|
_this.state = {
|
|
558
652
|
isCalloutVisible: false,
|
|
@@ -621,7 +715,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
621
715
|
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 && {
|
|
622
716
|
xAxisInnerPadding: this._xAxisInnerPadding,
|
|
623
717
|
xAxisOuterPadding: this._xAxisOuterPadding,
|
|
624
|
-
}), { ref: this._cartesianChartRef, showRoundOffXTickValues: !(0, index_3.isScalePaddingDefined)(this.props.xAxisInnerPadding, this.props.xAxisPadding),
|
|
718
|
+
}), { 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,
|
|
625
719
|
/* eslint-disable react/jsx-no-bind */
|
|
626
720
|
children: function (props) {
|
|
627
721
|
return (React.createElement(React.Fragment, null,
|
|
@@ -651,15 +745,23 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
651
745
|
this._lineObject = this._getFormattedLineData(this.props.data);
|
|
652
746
|
this._xAxisInnerPadding = (0, index_3.getScalePadding)(this.props.xAxisInnerPadding, this.props.xAxisPadding, this._xAxisType === index_3.XAxisTypes.StringAxis ? 2 / 3 : 1 / 2);
|
|
653
747
|
this._xAxisOuterPadding = (0, index_3.getScalePadding)(this.props.xAxisOuterPadding, this.props.xAxisPadding, 0);
|
|
748
|
+
this._initYAxisParams();
|
|
654
749
|
};
|
|
655
750
|
VerticalStackedBarChartBase.prototype._createDataSetLayer = function () {
|
|
751
|
+
var _this = this;
|
|
656
752
|
var tempArr = [];
|
|
657
753
|
var dataset = this._points.map(function (singlePointData) {
|
|
754
|
+
tempArr.push(singlePointData.xAxisPoint);
|
|
755
|
+
if (_this._yAxisType === index_3.YAxisType.StringAxis) {
|
|
756
|
+
return {
|
|
757
|
+
x: singlePointData.xAxisPoint,
|
|
758
|
+
y: 0,
|
|
759
|
+
};
|
|
760
|
+
}
|
|
658
761
|
var total = 0;
|
|
659
762
|
singlePointData.chartData.forEach(function (point) {
|
|
660
763
|
total = total + point.data;
|
|
661
764
|
});
|
|
662
|
-
tempArr.push(singlePointData.xAxisPoint);
|
|
663
765
|
return {
|
|
664
766
|
x: singlePointData.xAxisPoint,
|
|
665
767
|
y: total,
|
|
@@ -806,7 +908,9 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
806
908
|
isCalloutVisible: stack.chartData.length > 0 || ((_c = (_b = stack.lineData) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 0,
|
|
807
909
|
YValueHover: isLinesPresent
|
|
808
910
|
? 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(),
|
|
809
|
-
hoverXValue: stack.xAxisPoint instanceof Date
|
|
911
|
+
hoverXValue: stack.xAxisPoint instanceof Date
|
|
912
|
+
? (0, chart_utilities_1.formatDateToLocaleString)(stack.xAxisPoint, this.props.culture, this.props.useUTC)
|
|
913
|
+
: stack.xAxisPoint,
|
|
810
914
|
stackCalloutProps: stack,
|
|
811
915
|
activeXAxisDataPoint: stack.xAxisPoint,
|
|
812
916
|
callOutAccessibilityData: stack.stackCallOutAccessibilityData,
|
|
@@ -829,22 +933,32 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
829
933
|
};
|
|
830
934
|
VerticalStackedBarChartBase.prototype._getBarGapAndScale = function (bars, yBarScale, defaultTotalHeight) {
|
|
831
935
|
var _a = this.props.barGapMax, barGapMax = _a === void 0 ? 0 : _a;
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
var totalData = bars.reduce(function (iter, value) { return iter + Math.abs(value.data); }, 0);
|
|
835
|
-
var totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : Math.abs(yBarScale(totalData) - yBarScale(this.Y_ORIGIN));
|
|
936
|
+
var totalData = 0;
|
|
937
|
+
var totalHeight;
|
|
836
938
|
var sumOfPercent = 0;
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
939
|
+
var scalingRatio;
|
|
940
|
+
if (this._yAxisType === index_3.YAxisType.StringAxis) {
|
|
941
|
+
totalHeight =
|
|
942
|
+
defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : bars.reduce(function (total, bar) { return total + yBarScale(bar.data); }, 0);
|
|
943
|
+
}
|
|
944
|
+
else {
|
|
945
|
+
// When displaying gaps between the bars, the height of each bar is
|
|
946
|
+
// adjusted so that the total of all bars is not changed by the gaps
|
|
947
|
+
totalData = bars.reduce(function (iter, value) { return iter + Math.abs(value.data); }, 0);
|
|
948
|
+
totalHeight =
|
|
949
|
+
defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : Math.abs(yBarScale(totalData) - yBarScale(this.Y_ORIGIN));
|
|
950
|
+
bars.forEach(function (point) {
|
|
951
|
+
var value = (Math.abs(point.data) / totalData) * 100;
|
|
952
|
+
if (value < 1 && value !== 0) {
|
|
953
|
+
value = 1;
|
|
954
|
+
}
|
|
955
|
+
sumOfPercent += value;
|
|
956
|
+
});
|
|
957
|
+
scalingRatio = sumOfPercent !== 0 ? sumOfPercent / 100 : 1;
|
|
958
|
+
}
|
|
845
959
|
var gaps = barGapMax && bars.length - 1;
|
|
846
960
|
var gapHeight = gaps && Math.max(barGapMin, Math.min(barGapMax, (totalHeight * barGapMultiplier) / gaps));
|
|
847
|
-
var heightValueScale = (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
|
|
961
|
+
var heightValueScale = this._yAxisType === index_3.YAxisType.StringAxis ? 0 : (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
|
|
848
962
|
return {
|
|
849
963
|
gapHeight: gapHeight,
|
|
850
964
|
heightValueScale: heightValueScale,
|