@fluentui/react-charts 9.2.1 → 9.2.3
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.md +57 -2
- package/dist/index.d.ts +168 -15
- package/lib/ChartTable.js +1 -0
- package/lib/ChartTable.js.map +1 -0
- package/lib/components/AreaChart/AreaChart.js +4 -1
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +58 -0
- package/lib/components/ChartTable/ChartTable.js.map +1 -0
- package/lib/components/ChartTable/ChartTable.types.js +1 -0
- package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib/components/ChartTable/index.js +3 -0
- package/lib/components/ChartTable/index.js.map +1 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.js +93 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +55 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.js +170 -100
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +180 -102
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +100 -0
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +890 -211
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +2 -2
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js +2 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +185 -144
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +175 -114
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +26 -6
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/Legends/OverflowMenu.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +251 -78
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/LineChart.types.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js +10 -3
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +56 -37
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js +21 -4
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +16 -3
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +38 -14
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +214 -96
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/FocusableTooltipText.js.map +1 -1
- package/lib/utilities/utilities.js +41 -42
- package/lib/utilities/utilities.js.map +1 -1
- package/lib/utilities/vbc-utils.js +24 -0
- package/lib/utilities/vbc-utils.js.map +1 -1
- package/lib-commonjs/ChartTable.js +6 -0
- package/lib-commonjs/ChartTable.js.map +1 -0
- package/lib-commonjs/components/AreaChart/AreaChart.js +4 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +2 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +69 -0
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js +6 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib-commonjs/components/ChartTable/index.js +8 -0
- package/lib-commonjs/components/ChartTable/index.js.map +1 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +196 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +69 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +169 -98
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +176 -100
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +128 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +909 -209
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +2 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +183 -142
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +174 -113
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +25 -5
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +250 -78
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +12 -3
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +56 -37
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +30 -3
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +15 -2
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +37 -13
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +213 -95
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/index.js +1 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +44 -41
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/lib-commonjs/utilities/vbc-utils.js +27 -0
- package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
- package/package.json +10 -10
|
@@ -19,15 +19,15 @@ const _reacttheme = require("@fluentui/react-theme");
|
|
|
19
19
|
const _index = require("../../index");
|
|
20
20
|
const _index1 = require("../../utilities/index");
|
|
21
21
|
const _imageexportutils = require("../../utilities/image-export-utils");
|
|
22
|
+
const _chartutilities = require("@fluentui/chart-utilities");
|
|
22
23
|
const barGapMultiplier = 0.2;
|
|
23
24
|
const barGapMin = 1;
|
|
24
25
|
const MIN_DOMAIN_MARGIN = 8;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
const VerticalStackedBarChart = (props)=>{
|
|
26
|
+
const VerticalStackedBarChart = /*#__PURE__*/ _react.forwardRef((props = {
|
|
27
|
+
xAxisCategoryOrder: 'default',
|
|
28
|
+
yAxisCategoryOrder: 'default',
|
|
29
|
+
data: []
|
|
30
|
+
}, forwardedRef)=>{
|
|
31
31
|
var _props_legendProps;
|
|
32
32
|
const _isRtl = (0, _index1.useRtl)();
|
|
33
33
|
const _createLegendsForLine = (data)=>_getLineLegends(data);
|
|
@@ -51,6 +51,8 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
51
51
|
const cartesianChartRef = _react.useRef(null);
|
|
52
52
|
const Y_ORIGIN = 0;
|
|
53
53
|
const _legendsRef = _react.useRef(null);
|
|
54
|
+
let _yAxisType;
|
|
55
|
+
let _yAxisLabels = [];
|
|
54
56
|
const [selectedLegends, setSelectedLegends] = _react.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
|
|
55
57
|
const [activeLegend, setActiveLegend] = _react.useState(undefined);
|
|
56
58
|
const [dataForHoverCard, setDataForHoverCard] = _react.useState(0);
|
|
@@ -161,19 +163,29 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
161
163
|
activeLegend
|
|
162
164
|
] : [];
|
|
163
165
|
}
|
|
164
|
-
function
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
166
|
+
function _lineHoverFocus(lineData, event) {
|
|
167
|
+
let clientX = 0;
|
|
168
|
+
let clientY = 0;
|
|
169
|
+
if ('clientX' in event) {
|
|
170
|
+
clientX = event.clientX;
|
|
171
|
+
clientY = event.clientY;
|
|
172
|
+
} else {
|
|
173
|
+
const boundingRect = event.target.getBoundingClientRect();
|
|
174
|
+
clientX = boundingRect.left + boundingRect.width / 2;
|
|
175
|
+
clientY = boundingRect.top + boundingRect.height / 2;
|
|
176
|
+
}
|
|
177
|
+
if (_getHighlightedLegend().length === 1) {
|
|
178
|
+
if (_noLegendHighlighted() || _isLegendHighlighted(lineData.legend)) {
|
|
179
|
+
_updatePosition(clientX, clientY);
|
|
180
|
+
setPopoverOpen(true);
|
|
181
|
+
setXCalloutValue(`${lineData.xItem.xAxisPoint}`);
|
|
182
|
+
setYCalloutValue(`${lineData.yAxisCalloutData || lineData.data || lineData.y}`);
|
|
183
|
+
setActiveXAxisDataPoint(lineData.xItem.xAxisPoint);
|
|
184
|
+
setColor(lineData.color);
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
_onStackHoverFocus(lineData.xItem, event);
|
|
188
|
+
}
|
|
177
189
|
}
|
|
178
190
|
function _onStackHoverFocus(stack, mouseEvent) {
|
|
179
191
|
var _stack_lineData;
|
|
@@ -241,21 +253,26 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
241
253
|
_lineObject = _getFormattedLineData(props.data);
|
|
242
254
|
_xAxisInnerPadding = (0, _index1.getScalePadding)(props.xAxisInnerPadding, props.xAxisPadding, _xAxisType === _index1.XAxisTypes.StringAxis ? 2 / 3 : 1 / 2);
|
|
243
255
|
_xAxisOuterPadding = (0, _index1.getScalePadding)(props.xAxisOuterPadding, props.xAxisPadding, 0);
|
|
256
|
+
_initYAxisParams();
|
|
244
257
|
}
|
|
245
258
|
function _createDataSetLayer() {
|
|
246
|
-
const tempArr = [];
|
|
247
259
|
const dataset = _points.map((singlePointData)=>{
|
|
260
|
+
if (_yAxisType === _index1.YAxisType.StringAxis) {
|
|
261
|
+
return {
|
|
262
|
+
x: singlePointData.xAxisPoint,
|
|
263
|
+
y: 0
|
|
264
|
+
};
|
|
265
|
+
}
|
|
248
266
|
let total = 0;
|
|
249
267
|
singlePointData.chartData.forEach((point)=>{
|
|
250
268
|
total = total + point.data;
|
|
251
269
|
});
|
|
252
|
-
tempArr.push(singlePointData.xAxisPoint);
|
|
253
270
|
return {
|
|
254
271
|
x: singlePointData.xAxisPoint,
|
|
255
272
|
y: total
|
|
256
273
|
};
|
|
257
274
|
});
|
|
258
|
-
_xAxisLabels =
|
|
275
|
+
_xAxisLabels = _getOrderedXAxisLabels();
|
|
259
276
|
return dataset;
|
|
260
277
|
}
|
|
261
278
|
function _onLegendHover(legendTitle) {
|
|
@@ -280,7 +297,7 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
280
297
|
}
|
|
281
298
|
function _getGraphData(xScale, yScale, containerHeight, containerWidth, xElement) {
|
|
282
299
|
const { xBarScale, yBarScale } = _getScales(containerHeight, containerWidth);
|
|
283
|
-
return _bars = _createBar(xBarScale, yBarScale, containerHeight, xElement);
|
|
300
|
+
return _bars = _createBar(xBarScale, _yAxisType === _index1.YAxisType.StringAxis ? yScale : yBarScale, containerHeight, xElement);
|
|
284
301
|
}
|
|
285
302
|
function _getAxisData(yAxisData) {
|
|
286
303
|
if (yAxisData && yAxisData.yAxisDomainValues.length) {
|
|
@@ -290,19 +307,19 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
290
307
|
}
|
|
291
308
|
}
|
|
292
309
|
/**
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
310
|
+
* This function checks if the given legend is highlighted or not.
|
|
311
|
+
* A legend can be highlighted in 2 ways:
|
|
312
|
+
* 1. selection: if the user clicks on it
|
|
313
|
+
* 2. hovering: if there is no selected legend and the user hovers over it
|
|
314
|
+
*/ function _isLegendHighlighted(legendTitle) {
|
|
298
315
|
return _getHighlightedLegend().includes(legendTitle);
|
|
299
316
|
}
|
|
300
317
|
/**
|
|
301
|
-
|
|
302
|
-
|
|
318
|
+
* This function checks if none of the legends is selected or hovered.
|
|
319
|
+
*/ function _noLegendHighlighted() {
|
|
303
320
|
return _getHighlightedLegend().length === 0;
|
|
304
321
|
}
|
|
305
|
-
function _getAriaLabel(singleChartData, point) {
|
|
322
|
+
function _getAriaLabel(singleChartData, point, isLinePoint) {
|
|
306
323
|
var _point_callOutAccessibilityData;
|
|
307
324
|
if (!point) {
|
|
308
325
|
var _singleChartData_lineData, _singleChartData_stackCallOutAccessibilityData;
|
|
@@ -310,19 +327,19 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
310
327
|
const pointValues = singleChartData.chartData.map((pt)=>{
|
|
311
328
|
const legend = pt.legend;
|
|
312
329
|
const yValue = pt.yAxisCalloutData || pt.data;
|
|
313
|
-
return `${legend}, ${yValue}
|
|
314
|
-
}).join(' ');
|
|
330
|
+
return _noLegendHighlighted() || _isLegendHighlighted(legend) ? `${legend}, ${yValue}.` : '';
|
|
331
|
+
}).filter((str)=>str !== '').join(' ');
|
|
315
332
|
const lineValues = (_singleChartData_lineData = singleChartData.lineData) === null || _singleChartData_lineData === void 0 ? void 0 : _singleChartData_lineData.map((ln)=>{
|
|
316
333
|
const legend = ln.legend;
|
|
317
334
|
const yValue = ln.yAxisCalloutData || ln.data || ln.y;
|
|
318
|
-
return `${legend}, ${yValue}
|
|
319
|
-
}).join(' ');
|
|
335
|
+
return _noLegendHighlighted() || _isLegendHighlighted(legend) ? `${legend}, ${yValue}.` : '';
|
|
336
|
+
}).filter((str)=>str !== '').join(' ');
|
|
320
337
|
return ((_singleChartData_stackCallOutAccessibilityData = singleChartData.stackCallOutAccessibilityData) === null || _singleChartData_stackCallOutAccessibilityData === void 0 ? void 0 : _singleChartData_stackCallOutAccessibilityData.ariaLabel) || `${xValue}. ${pointValues}` + (lineValues ? ` ${lineValues}` : '');
|
|
321
338
|
}
|
|
322
|
-
/** if shouldFocusWholeStack is false */ const xValue = singleChartData.xAxisCalloutData || point.xAxisCalloutData || (singleChartData.xAxisPoint instanceof Date ? (0, _index1.formatDate)(singleChartData.xAxisPoint) : singleChartData.xAxisPoint);
|
|
339
|
+
/** if shouldFocusWholeStack is false */ const xValue = singleChartData.xAxisCalloutData || !isLinePoint && point.xAxisCalloutData || (singleChartData.xAxisPoint instanceof Date ? (0, _index1.formatDate)(singleChartData.xAxisPoint) : singleChartData.xAxisPoint);
|
|
323
340
|
const legend = point.legend;
|
|
324
|
-
const yValue = point.yAxisCalloutData || point.data;
|
|
325
|
-
return ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ${legend}, ${yValue}.`;
|
|
341
|
+
const yValue = point.yAxisCalloutData || (isLinePoint ? point.data || point.y : point.data);
|
|
342
|
+
return !isLinePoint && ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ${legend}, ${yValue}.`;
|
|
326
343
|
}
|
|
327
344
|
function _getCustomizedCallout() {
|
|
328
345
|
const _isHavingLines = props.data.some((item)=>item.lineData && item.lineData.length > 0);
|
|
@@ -407,6 +424,7 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
407
424
|
const y1 = useSecondaryYScale ? yScaleSecondary(lineObject[item][i - 1].y) : yScalePrimary(lineObject[item][i - 1].y);
|
|
408
425
|
const x2 = xScale(lineObject[item][i].xItem.xAxisPoint);
|
|
409
426
|
const y2 = useSecondaryYScale ? yScaleSecondary(lineObject[item][i].y) : yScalePrimary(lineObject[item][i].y);
|
|
427
|
+
const yScaleBandwidthTranslate = !useSecondaryYScale && _yAxisType === _index1.YAxisType.StringAxis ? yScalePrimary.bandwidth() / 2 : 0;
|
|
410
428
|
if (lineBorderWidth > 0) {
|
|
411
429
|
borderForLines.push(/*#__PURE__*/ _react.createElement("line", {
|
|
412
430
|
key: `${index}-${i}-BorderLine`,
|
|
@@ -419,7 +437,7 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
419
437
|
fill: "transparent",
|
|
420
438
|
strokeLinecap: "round",
|
|
421
439
|
stroke: _reacttheme.tokens.colorNeutralBackground1,
|
|
422
|
-
transform: `translate(${xScaleBandwidthTranslate},
|
|
440
|
+
transform: `translate(${xScaleBandwidthTranslate}, ${yScaleBandwidthTranslate})`
|
|
423
441
|
}));
|
|
424
442
|
}
|
|
425
443
|
var _lineObject_item__lineOptions_strokeWidth, _lineObject_item__lineOptions_strokeLinecap;
|
|
@@ -434,11 +452,9 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
434
452
|
strokeLinecap: (_lineObject_item__lineOptions_strokeLinecap = (_lineObject_item__lineOptions1 = lineObject[item][0].lineOptions) === null || _lineObject_item__lineOptions1 === void 0 ? void 0 : _lineObject_item__lineOptions1.strokeLinecap) !== null && _lineObject_item__lineOptions_strokeLinecap !== void 0 ? _lineObject_item__lineOptions_strokeLinecap : 'round',
|
|
435
453
|
strokeDasharray: (_lineObject_item__lineOptions2 = lineObject[item][0].lineOptions) === null || _lineObject_item__lineOptions2 === void 0 ? void 0 : _lineObject_item__lineOptions2.strokeDasharray,
|
|
436
454
|
stroke: lineObject[item][i].color,
|
|
437
|
-
transform: `translate(${xScaleBandwidthTranslate},
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
onMouseLeave: _lineHoverOut
|
|
441
|
-
}
|
|
455
|
+
transform: `translate(${xScaleBandwidthTranslate}, ${yScaleBandwidthTranslate})`,
|
|
456
|
+
onMouseOver: (event)=>_lineHover(lineObject[item][i - 1], event),
|
|
457
|
+
onMouseLeave: _handleMouseOut
|
|
442
458
|
}));
|
|
443
459
|
}
|
|
444
460
|
});
|
|
@@ -448,20 +464,21 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
448
464
|
refElement: null
|
|
449
465
|
};
|
|
450
466
|
const noBarsAndLinesActive = circlePoint.xItem.chartData.filter((dataPoint)=>_noLegendHighlighted() || _isLegendHighlighted(dataPoint.legend)).length === 0;
|
|
467
|
+
const yScaleBandwidthTranslate = !circlePoint.useSecondaryYScale && _yAxisType === _index1.YAxisType.StringAxis ? yScalePrimary.bandwidth() / 2 : 0;
|
|
451
468
|
dots.push(/*#__PURE__*/ _react.createElement("circle", {
|
|
452
469
|
key: `${index}-${subIndex}-dot`,
|
|
453
470
|
cx: xScale(circlePoint.xItem.xAxisPoint),
|
|
454
471
|
cy: circlePoint.useSecondaryYScale && yScaleSecondary ? yScaleSecondary(circlePoint.y) : yScalePrimary(circlePoint.y),
|
|
455
|
-
onMouseOver:
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
},
|
|
459
|
-
r: _getCircleVisibilityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).radius,
|
|
472
|
+
onMouseOver: (event)=>_lineHover(circlePoint, event),
|
|
473
|
+
onMouseLeave: _handleMouseOut,
|
|
474
|
+
r: _getCircleOpacityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).radius,
|
|
460
475
|
stroke: circlePoint.color,
|
|
461
476
|
fill: _reacttheme.tokens.colorNeutralBackground1,
|
|
462
477
|
strokeWidth: 3,
|
|
463
|
-
visibility:
|
|
464
|
-
|
|
478
|
+
// Elements with visibility: hidden cannot receive focus, so use opacity: 0 instead to hide them.
|
|
479
|
+
// For more information, see https://fuzzbomb.github.io/accessibility-demos/visually-hidden-focus-test.html
|
|
480
|
+
opacity: _getCircleOpacityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).opacity,
|
|
481
|
+
transform: `translate(${xScaleBandwidthTranslate}, ${yScaleBandwidthTranslate})`,
|
|
465
482
|
ref: (e)=>circleRef.refElement = e,
|
|
466
483
|
...noBarsAndLinesActive ? {
|
|
467
484
|
tabIndex: !props.hideTooltip ? 0 : undefined,
|
|
@@ -475,27 +492,27 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
475
492
|
});
|
|
476
493
|
return /*#__PURE__*/ _react.createElement(_react.Fragment, null, borderForLines, lines, dots);
|
|
477
494
|
}
|
|
478
|
-
function
|
|
495
|
+
function _getCircleOpacityAndRadius(xAxisPoint, legend) {
|
|
479
496
|
if (!_noLegendHighlighted()) {
|
|
480
497
|
if (xAxisPoint === activeXAxisDataPoint && _isLegendHighlighted(legend)) {
|
|
481
498
|
return {
|
|
482
|
-
|
|
499
|
+
opacity: 1,
|
|
483
500
|
radius: 8
|
|
484
501
|
};
|
|
485
502
|
} else if (_isLegendHighlighted(legend)) {
|
|
486
503
|
return {
|
|
487
|
-
|
|
504
|
+
opacity: 1,
|
|
488
505
|
radius: 0.3
|
|
489
506
|
};
|
|
490
507
|
} else {
|
|
491
508
|
return {
|
|
492
|
-
|
|
509
|
+
opacity: 0,
|
|
493
510
|
radius: 0
|
|
494
511
|
};
|
|
495
512
|
}
|
|
496
513
|
} else {
|
|
497
514
|
return {
|
|
498
|
-
|
|
515
|
+
opacity: activeXAxisDataPoint === xAxisPoint ? 1 : 0,
|
|
499
516
|
radius: 8
|
|
500
517
|
};
|
|
501
518
|
}
|
|
@@ -533,14 +550,15 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
533
550
|
if ((_calloutAnchorPoint === null || _calloutAnchorPoint === void 0 ? void 0 : _calloutAnchorPoint.chartDataPoint) !== point || (_calloutAnchorPoint === null || _calloutAnchorPoint === void 0 ? void 0 : _calloutAnchorPoint.xAxisDataPoint) !== xAxisPoint) {
|
|
534
551
|
_calloutAnchorPoint = {
|
|
535
552
|
chartDataPoint: point,
|
|
536
|
-
xAxisDataPoint:
|
|
553
|
+
xAxisDataPoint: xAxisPoint instanceof Date ? (0, _chartutilities.formatDateToLocaleString)(xAxisPoint, props.culture, props.useUTC) : xAxisPoint.toString()
|
|
537
554
|
};
|
|
555
|
+
const xCalloutValue = point.xAxisCalloutData || (xAxisPoint instanceof Date ? (0, _chartutilities.formatDateToLocaleString)(xAxisPoint, props.culture, props.useUTC) : xAxisPoint.toString());
|
|
538
556
|
_updatePosition(clientX, clientY);
|
|
539
557
|
setPopoverOpen(_noLegendHighlighted() || _isLegendHighlighted(point.legend));
|
|
540
558
|
setCalloutLegend(point.legend);
|
|
541
559
|
setDataForHoverCard(point.data);
|
|
542
560
|
setColor(color);
|
|
543
|
-
setXCalloutValue(
|
|
561
|
+
setXCalloutValue(xCalloutValue);
|
|
544
562
|
setYCalloutValue(point.yAxisCalloutData);
|
|
545
563
|
setDataPointCalloutProps(point);
|
|
546
564
|
setCallOutAccessibilityData(point.callOutAccessibilityData);
|
|
@@ -548,11 +566,11 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
548
566
|
}
|
|
549
567
|
function _lineHover(lineData, mouseEvent) {
|
|
550
568
|
mouseEvent.persist();
|
|
551
|
-
_lineHoverFocus(lineData);
|
|
569
|
+
_lineHoverFocus(lineData, mouseEvent);
|
|
552
570
|
}
|
|
553
571
|
function _lineFocus(event, lineData, ref) {
|
|
554
572
|
if (ref.refElement) {
|
|
555
|
-
_lineHoverFocus(lineData);
|
|
573
|
+
_lineHoverFocus(lineData, event);
|
|
556
574
|
}
|
|
557
575
|
}
|
|
558
576
|
function _onStackHover(stack, mouseEvent) {
|
|
@@ -574,22 +592,29 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
574
592
|
}
|
|
575
593
|
function _getBarGapAndScale(bars, yBarScale, defaultTotalHeight) {
|
|
576
594
|
const { barGapMax = 0 } = props;
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
const totalData = bars.reduce((iter, value)=>iter + Math.abs(value.data), 0);
|
|
580
|
-
const totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : Math.abs(yBarScale(totalData) - yBarScale(Y_ORIGIN));
|
|
595
|
+
let totalData = 0;
|
|
596
|
+
let totalHeight;
|
|
581
597
|
let sumOfPercent = 0;
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
598
|
+
let scalingRatio;
|
|
599
|
+
if (_yAxisType === _index1.YAxisType.StringAxis) {
|
|
600
|
+
totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : bars.reduce((total, bar)=>total + yBarScale(bar.data), 0);
|
|
601
|
+
} else {
|
|
602
|
+
// When displaying gaps between the bars, the height of each bar is
|
|
603
|
+
// adjusted so that the total of all bars is not changed by the gaps
|
|
604
|
+
totalData = bars.reduce((iter, value)=>iter + Math.abs(value.data), 0);
|
|
605
|
+
totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : Math.abs(yBarScale(totalData) - yBarScale(Y_ORIGIN));
|
|
606
|
+
bars.forEach((point)=>{
|
|
607
|
+
let value = Math.abs(point.data) / totalData * 100;
|
|
608
|
+
if (value < 1 && value !== 0) {
|
|
609
|
+
value = 1;
|
|
610
|
+
}
|
|
611
|
+
sumOfPercent += value;
|
|
612
|
+
});
|
|
613
|
+
scalingRatio = sumOfPercent !== 0 ? sumOfPercent / 100 : 1;
|
|
614
|
+
}
|
|
590
615
|
const gaps = barGapMax && bars.length - 1;
|
|
591
616
|
const gapHeight = gaps && Math.max(barGapMin, Math.min(barGapMax, totalHeight * barGapMultiplier / gaps));
|
|
592
|
-
const heightValueScale = (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
|
|
617
|
+
const heightValueScale = _yAxisType === _index1.YAxisType.StringAxis ? 0 : (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
|
|
593
618
|
return {
|
|
594
619
|
gapHeight,
|
|
595
620
|
heightValueScale,
|
|
@@ -680,8 +705,7 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
680
705
|
}
|
|
681
706
|
function _getDomainMargins(containerWidth) {
|
|
682
707
|
_domainMargin = MIN_DOMAIN_MARGIN;
|
|
683
|
-
|
|
684
|
-
/** Rate at which the space between the bars changes wrt the bar width */ const barGapRate = _xAxisInnerPadding / (1 - _xAxisInnerPadding);
|
|
708
|
+
const totalWidth = (0, _index1.calcTotalWidth)(containerWidth, _margins, MIN_DOMAIN_MARGIN);
|
|
685
709
|
if (_xAxisType === _index1.XAxisTypes.StringAxis) {
|
|
686
710
|
if ((0, _index1.isScalePaddingDefined)(props.xAxisOuterPadding, props.xAxisPadding)) {
|
|
687
711
|
// Setting the domain margin for string x-axis to 0 because the xAxisOuterPadding prop is now available
|
|
@@ -691,16 +715,16 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
691
715
|
// Update the bar width so that when CartesianChart rerenders,
|
|
692
716
|
// the following calculations don't use the previous bar width.
|
|
693
717
|
_barWidth = (0, _index1.getBarWidth)(props.barWidth, props.maxBarWidth);
|
|
694
|
-
/** Total width required to render the bars. Directly proportional to bar width */ const reqWidth = (
|
|
718
|
+
/** Total width required to render the bars. Directly proportional to bar width */ const reqWidth = (0, _index1.calcRequiredWidth)(_barWidth, _xAxisLabels.length, _xAxisInnerPadding);
|
|
695
719
|
if (totalWidth >= reqWidth) {
|
|
696
720
|
// Center align the chart by setting equal left and right margins for domain
|
|
697
721
|
_domainMargin = MIN_DOMAIN_MARGIN + (totalWidth - reqWidth) / 2;
|
|
698
722
|
}
|
|
699
723
|
} else if (props.mode === 'plotly' && _xAxisLabels.length > 1) {
|
|
700
724
|
// Calculate the remaining width after rendering bars at their maximum allowable width
|
|
701
|
-
const bandwidth =
|
|
725
|
+
const bandwidth = (0, _index1.calcBandwidth)(totalWidth, _xAxisLabels.length, _xAxisInnerPadding);
|
|
702
726
|
const barWidth = (0, _index1.getBarWidth)(props.barWidth, props.maxBarWidth, bandwidth);
|
|
703
|
-
let reqWidth = (
|
|
727
|
+
let reqWidth = (0, _index1.calcRequiredWidth)(barWidth, _xAxisLabels.length, _xAxisInnerPadding);
|
|
704
728
|
const margin1 = (totalWidth - reqWidth) / 2;
|
|
705
729
|
let margin2 = Number.POSITIVE_INFINITY;
|
|
706
730
|
if (!props.hideTickOverlap) {
|
|
@@ -740,7 +764,7 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
740
764
|
const xPoint = xBarScale(_xAxisType === _index1.XAxisTypes.NumericAxis ? singleChartData.xAxisPoint : _xAxisType === _index1.XAxisTypes.DateAxis ? singleChartData.xAxisPoint : singleChartData.xAxisPoint);
|
|
741
765
|
const xScaleBandwidthTranslate = _xAxisType !== _index1.XAxisTypes.StringAxis ? -_barWidth / 2 : (xBarScale.bandwidth() - _barWidth) / 2;
|
|
742
766
|
let barTotalValue = 0;
|
|
743
|
-
const barsToDisplay = singleChartData.chartData.filter((point)=>point.data !== 0);
|
|
767
|
+
const barsToDisplay = singleChartData.chartData.filter((point)=>point.data !== 0 && point.data !== '' && !(_yAxisType === _index1.YAxisType.StringAxis && typeof yBarScale(point.data) === 'undefined'));
|
|
744
768
|
if (!barsToDisplay.length) {
|
|
745
769
|
return undefined;
|
|
746
770
|
}
|
|
@@ -748,7 +772,7 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
748
772
|
if (heightValueScale < 0) {
|
|
749
773
|
return undefined;
|
|
750
774
|
}
|
|
751
|
-
const yBaseline = containerHeight - _margins.bottom - yBarScale(Y_ORIGIN);
|
|
775
|
+
const yBaseline = containerHeight - _margins.bottom - (_yAxisType === _index1.YAxisType.StringAxis ? 0 : yBarScale(Y_ORIGIN));
|
|
752
776
|
let yPositiveStart = yBaseline;
|
|
753
777
|
let yNegativeStart = yBaseline;
|
|
754
778
|
let yPoint = 0;
|
|
@@ -757,7 +781,7 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
757
781
|
const startColor = point.color ? point.color : _colors[index];
|
|
758
782
|
const ref = {};
|
|
759
783
|
const shouldHighlight = _isLegendHighlighted(point.legend) || _noLegendHighlighted() ? true : false;
|
|
760
|
-
const rectFocusProps = !shouldFocusWholeStack && {
|
|
784
|
+
const rectFocusProps = !shouldFocusWholeStack && shouldHighlight && {
|
|
761
785
|
'aria-label': _getAriaLabel(singleChartData, point),
|
|
762
786
|
onMouseOver: (event)=>_onRectHover(singleChartData.xAxisPoint, point, startColor, event),
|
|
763
787
|
onMouseMove: (event)=>_onRectHover(singleChartData.xAxisPoint, point, startColor, event),
|
|
@@ -768,22 +792,29 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
768
792
|
role: 'img',
|
|
769
793
|
tabIndex: !props.hideTooltip && shouldHighlight ? 0 : undefined
|
|
770
794
|
};
|
|
771
|
-
let barHeight
|
|
772
|
-
// FIXME: The current scaling logic may produce different min and gap heights for each bar stack.
|
|
773
|
-
const minHeight = Math.max(heightValueScale * absStackTotal / 100.0, barMinimumHeight);
|
|
774
|
-
if (barHeight < minHeight) {
|
|
775
|
-
barHeight = minHeight;
|
|
776
|
-
}
|
|
795
|
+
let barHeight;
|
|
777
796
|
const gapOffset = index ? gapHeight : 0;
|
|
778
|
-
if (
|
|
797
|
+
if (_yAxisType === _index1.YAxisType.StringAxis) {
|
|
798
|
+
barHeight = Math.max(containerHeight - _margins.bottom - (yBarScale(point.data) + yBarScale.bandwidth() / 2) - gapOffset, barMinimumHeight, 1);
|
|
779
799
|
yPositiveStart -= barHeight + gapOffset;
|
|
780
800
|
yPoint = yPositiveStart;
|
|
781
801
|
} else {
|
|
782
|
-
|
|
783
|
-
|
|
802
|
+
barHeight = Math.abs(heightValueScale * point.data);
|
|
803
|
+
// FIXME: The current scaling logic may produce different min and gap heights for each bar stack.
|
|
804
|
+
const minHeight = Math.max(heightValueScale * absStackTotal / 100.0, barMinimumHeight);
|
|
805
|
+
if (barHeight < minHeight) {
|
|
806
|
+
barHeight = minHeight;
|
|
807
|
+
}
|
|
808
|
+
if (point.data >= Y_ORIGIN) {
|
|
809
|
+
yPositiveStart -= barHeight + gapOffset;
|
|
810
|
+
yPoint = yPositiveStart;
|
|
811
|
+
} else {
|
|
812
|
+
yPoint = yNegativeStart + gapOffset;
|
|
813
|
+
yNegativeStart = yPoint + barHeight;
|
|
814
|
+
}
|
|
815
|
+
barTotalValue += point.data;
|
|
816
|
+
heightOfLastBar = index === barsToDisplay.length - 1 ? barHeight : 0;
|
|
784
817
|
}
|
|
785
|
-
barTotalValue += point.data;
|
|
786
|
-
heightOfLastBar = index === barsToDisplay.length - 1 ? barHeight : 0;
|
|
787
818
|
if (barCornerRadius && barHeight > barCornerRadius && index === barsToDisplay.length - 1) {
|
|
788
819
|
return /*#__PURE__*/ _react.createElement(_react.Fragment, {
|
|
789
820
|
key: index + indexNumber + `${shouldFocusWholeStack}`
|
|
@@ -829,7 +860,11 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
829
860
|
}));
|
|
830
861
|
});
|
|
831
862
|
const groupRef = {};
|
|
832
|
-
const
|
|
863
|
+
const someBarsActive = singleChartData.chartData.filter((dataPoint)=>_noLegendHighlighted() || _isLegendHighlighted(dataPoint.legend)).length > 0;
|
|
864
|
+
// FIXME: Making the entire stack focusable when stack callout is enabled adds unnecessary complexity
|
|
865
|
+
// and can reduce usability in certain scenarios. Instead, each individual element within the stack
|
|
866
|
+
// should be focusable on its own, with its own aria-label. This behavior is also seen in Highcharts.
|
|
867
|
+
const stackFocusProps = shouldFocusWholeStack && someBarsActive && {
|
|
833
868
|
'aria-label': _getAriaLabel(singleChartData),
|
|
834
869
|
onMouseOver: (event)=>_onStackHover(singleChartData, event),
|
|
835
870
|
onMouseMove: (event)=>_onStackHover(singleChartData, event),
|
|
@@ -842,7 +877,7 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
842
877
|
};
|
|
843
878
|
let showLabel = false;
|
|
844
879
|
let barLabel = 0;
|
|
845
|
-
if (!props.hideLabels) {
|
|
880
|
+
if (!props.hideLabels && _yAxisType !== _index1.YAxisType.StringAxis) {
|
|
846
881
|
if (_noLegendHighlighted()) {
|
|
847
882
|
showLabel = true;
|
|
848
883
|
barLabel = barTotalValue;
|
|
@@ -912,6 +947,83 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
912
947
|
endValue: (0, _d3array.max)(values)
|
|
913
948
|
};
|
|
914
949
|
}
|
|
950
|
+
function _initYAxisParams() {
|
|
951
|
+
if (_points[0].chartData.length > 0) {
|
|
952
|
+
_yAxisType = (0, _index1.getTypeOfAxis)(_points[0].chartData[0].data, false);
|
|
953
|
+
} else {
|
|
954
|
+
Object.keys(_lineObject).forEach((lineLegend)=>{
|
|
955
|
+
if (!_lineObject[lineLegend][0].useSecondaryYScale) {
|
|
956
|
+
_yAxisType = (0, _index1.getTypeOfAxis)(_lineObject[lineLegend][0].y, false);
|
|
957
|
+
}
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
_yAxisLabels = _getOrderedYAxisLabels();
|
|
961
|
+
}
|
|
962
|
+
function _getYDomainMargins(containerHeight) {
|
|
963
|
+
/**
|
|
964
|
+
* Specifies the extra top margin to apply above the highest y-axis tick label.
|
|
965
|
+
* Useful when stacked bars extend beyond the combined height of all y-axis labels (or categories).
|
|
966
|
+
*/ let yAxisTickMarginTop = 0;
|
|
967
|
+
/** Total height available to render the bars */ const totalHeight = containerHeight - _margins.bottom - _margins.top;
|
|
968
|
+
if (_yAxisType === _index1.YAxisType.StringAxis) {
|
|
969
|
+
/** Maximum height of the stacked bars, expressed in multiples of the height of a y-axis label (or category) */ let maxBarHeightInLabels = 0;
|
|
970
|
+
_points.forEach((xPoint)=>{
|
|
971
|
+
/** Height of the stacked bar, expressed in multiples of the height of a y-axis label (or category) */ let barHeightInLabels = 0;
|
|
972
|
+
xPoint.chartData.forEach((bar)=>{
|
|
973
|
+
barHeightInLabels += _yAxisLabels.indexOf(`${bar.data}`) + 1;
|
|
974
|
+
});
|
|
975
|
+
maxBarHeightInLabels = Math.max(maxBarHeightInLabels, barHeightInLabels);
|
|
976
|
+
});
|
|
977
|
+
/** Height of a y-axis label (or category) */ const yAxisLabelHeight = maxBarHeightInLabels === 0 ? 0 : totalHeight / maxBarHeightInLabels;
|
|
978
|
+
yAxisTickMarginTop += yAxisLabelHeight * (maxBarHeightInLabels - _yAxisLabels.length);
|
|
979
|
+
}
|
|
980
|
+
return {
|
|
981
|
+
..._margins,
|
|
982
|
+
top: _margins.top + yAxisTickMarginTop
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
function _getOrderedXAxisLabels() {
|
|
986
|
+
if (_xAxisType !== _index1.XAxisTypes.StringAxis) {
|
|
987
|
+
return [];
|
|
988
|
+
}
|
|
989
|
+
return (0, _index1.sortAxisCategories)(_mapCategoryToValues(), props.xAxisCategoryOrder);
|
|
990
|
+
}
|
|
991
|
+
function _getOrderedYAxisLabels() {
|
|
992
|
+
if (_yAxisType !== _index1.YAxisType.StringAxis) {
|
|
993
|
+
return [];
|
|
994
|
+
}
|
|
995
|
+
return (0, _index1.sortAxisCategories)(_mapCategoryToValues(true), props.yAxisCategoryOrder);
|
|
996
|
+
}
|
|
997
|
+
function _mapCategoryToValues(isYAxis = false) {
|
|
998
|
+
const categoryToValues = {};
|
|
999
|
+
_points.forEach((point)=>{
|
|
1000
|
+
var _point_lineData;
|
|
1001
|
+
point.chartData.forEach((bar)=>{
|
|
1002
|
+
const category = isYAxis ? bar.data : point.xAxisPoint;
|
|
1003
|
+
const value = isYAxis ? point.xAxisPoint : bar.data;
|
|
1004
|
+
if (!categoryToValues[category]) {
|
|
1005
|
+
categoryToValues[category] = [];
|
|
1006
|
+
}
|
|
1007
|
+
if (typeof value === 'number') {
|
|
1008
|
+
categoryToValues[category].push(value);
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
(_point_lineData = point.lineData) === null || _point_lineData === void 0 ? void 0 : _point_lineData.forEach((linePoint)=>{
|
|
1012
|
+
if (isYAxis && linePoint.useSecondaryYScale) {
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
const category = isYAxis ? linePoint.y : point.xAxisPoint;
|
|
1016
|
+
const value = isYAxis ? point.xAxisPoint : linePoint.y;
|
|
1017
|
+
if (!categoryToValues[category]) {
|
|
1018
|
+
categoryToValues[category] = [];
|
|
1019
|
+
}
|
|
1020
|
+
if (typeof value === 'number') {
|
|
1021
|
+
categoryToValues[category].push(value);
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
});
|
|
1025
|
+
return categoryToValues;
|
|
1026
|
+
}
|
|
915
1027
|
if (!_isChartEmpty()) {
|
|
916
1028
|
_adjustProps();
|
|
917
1029
|
const _isHavingLines = props.data.some((item)=>item.lineData && item.lineData.length > 0);
|
|
@@ -967,6 +1079,12 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
967
1079
|
},
|
|
968
1080
|
componentRef: cartesianChartRef,
|
|
969
1081
|
showRoundOffXTickValues: !(0, _index1.isScalePaddingDefined)(props.xAxisInnerPadding, props.xAxisPadding),
|
|
1082
|
+
yAxisType: _yAxisType,
|
|
1083
|
+
stringDatasetForYAxisDomain: [
|
|
1084
|
+
'',
|
|
1085
|
+
..._yAxisLabels
|
|
1086
|
+
],
|
|
1087
|
+
getYDomainMargins: _getYDomainMargins,
|
|
970
1088
|
/* eslint-disable react/jsx-no-bind */ children: (props)=>{
|
|
971
1089
|
return /*#__PURE__*/ _react.createElement(_react.Fragment, null, /*#__PURE__*/ _react.createElement("g", null, _bars), /*#__PURE__*/ _react.createElement("g", null, _isHavingLines && _createLines(props.xScale, props.yScalePrimary, props.containerHeight, props.containerWidth, props.yScaleSecondary)));
|
|
972
1090
|
}
|
|
@@ -980,5 +1098,5 @@ const VerticalStackedBarChart = (props)=>{
|
|
|
980
1098
|
},
|
|
981
1099
|
"aria-label": 'Graph has no data to display'
|
|
982
1100
|
});
|
|
983
|
-
};
|
|
1101
|
+
});
|
|
984
1102
|
VerticalStackedBarChart.displayName = 'VerticalStackedBarChart';
|