@fluentui/react-charts 9.3.6 → 9.3.8
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 +46 -2
- package/dist/index.d.ts +70 -17
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js +2 -16
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -1
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -1
- package/lib/components/AreaChart/AreaChart.js +3 -43
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +1 -2
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +8 -11
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.types.js.map +1 -1
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +107 -67
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -1
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +7 -1
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -1
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +7 -1
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +52 -32
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.js +1 -2
- package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +9 -7
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +8 -5
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js +0 -2
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +48 -25
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +309 -209
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +9 -15
- 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 +4 -2
- package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js +8 -13
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.types.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.js +4 -17
- package/lib/components/GanttChart/GanttChart.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +8 -13
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +24 -36
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +1 -2
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +3 -16
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +5 -25
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/Legends/Legends.js +3 -4
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/Legends/Legends.types.js.map +1 -1
- package/lib/components/Legends/OverflowMenu.js.map +1 -1
- package/lib/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +68 -75
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/LineChart.types.js +1 -1
- package/lib/components/LineChart/LineChart.types.js.map +1 -1
- package/lib/components/LineChart/eventAnnotation/EventAnnotation.js +3 -4
- package/lib/components/LineChart/eventAnnotation/EventAnnotation.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js +1 -2
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.js +4 -10
- package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +1 -2
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +41 -49
- 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 +1 -2
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/Sparkline/Sparkline.js +11 -7
- package/lib/components/Sparkline/Sparkline.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +15 -92
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +1 -2
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +28 -49
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +1 -2
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib/types/ChartAnnotation.js.map +1 -1
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/Common.styles.js +0 -1
- package/lib/utilities/Common.styles.js.map +1 -1
- package/lib/utilities/Common.styles.raw.js +0 -1
- package/lib/utilities/Common.styles.raw.js.map +1 -1
- package/lib/utilities/FocusableTooltipText.js +1 -1
- package/lib/utilities/FocusableTooltipText.js.map +1 -1
- package/lib/utilities/getWindow.js +0 -1
- package/lib/utilities/getWindow.js.map +1 -1
- package/lib/utilities/hooks.js +34 -0
- package/lib/utilities/hooks.js.map +1 -0
- package/lib/utilities/image-export-utils.js +118 -78
- package/lib/utilities/image-export-utils.js.map +1 -1
- package/lib/utilities/utilities.js +243 -102
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js +2 -16
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -1
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +2 -41
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +0 -2
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +9 -11
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +107 -67
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +7 -1
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +7 -1
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +51 -31
- 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.js +1 -2
- package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +7 -6
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +7 -4
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js +0 -2
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +48 -25
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +309 -208
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +7 -13
- 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 +4 -2
- package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js +7 -12
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.types.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.js +3 -16
- package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +7 -12
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +22 -34
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +0 -2
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +2 -15
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +4 -23
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js +3 -4
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.types.js.map +1 -1
- package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +67 -74
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.js +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
- package/lib-commonjs/components/LineChart/eventAnnotation/EventAnnotation.js +2 -2
- package/lib-commonjs/components/LineChart/eventAnnotation/EventAnnotation.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +0 -2
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.js +4 -10
- package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +0 -2
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +38 -46
- 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 +0 -2
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/Sparkline/Sparkline.js +11 -7
- package/lib-commonjs/components/Sparkline/Sparkline.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +14 -91
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +0 -2
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +26 -47
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +0 -2
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/types/ChartAnnotation.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/Common.styles.js +0 -1
- package/lib-commonjs/utilities/Common.styles.js.map +1 -1
- package/lib-commonjs/utilities/Common.styles.raw.js +0 -1
- package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -1
- package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/getWindow.js +0 -1
- package/lib-commonjs/utilities/getWindow.js.map +1 -1
- package/lib-commonjs/utilities/hooks.js +45 -0
- package/lib-commonjs/utilities/hooks.js.map +1 -0
- package/lib-commonjs/utilities/image-export-utils.js +119 -79
- package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +253 -101
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +9 -9
- package/lib/components/DeclarativeChart/imageExporter.js +0 -223
- package/lib/components/DeclarativeChart/imageExporter.js.map +0 -1
- package/lib-commonjs/components/DeclarativeChart/imageExporter.js +0 -233
- package/lib-commonjs/components/DeclarativeChart/imageExporter.js.map +0 -1
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { max as d3Max, min as d3Min } from 'd3-array';
|
|
4
|
-
import { select as d3Select } from 'd3-selection';
|
|
5
4
|
import { useVerticalStackedBarChartStyles } from './useVerticalStackedBarChartStyles.styles';
|
|
6
5
|
import { scaleLinear as d3ScaleLinear, scaleBand as d3ScaleBand, scaleUtc as d3ScaleUtc, scaleTime as d3ScaleTime } from 'd3-scale';
|
|
7
6
|
import { useId } from '@fluentui/react-utilities';
|
|
8
7
|
import { tokens } from '@fluentui/react-theme';
|
|
9
8
|
import { CartesianChart, ChartPopover, Legends } from '../../index';
|
|
10
|
-
import { ChartTypes, getAccessibleDataObject, XAxisTypes, getTypeOfAxis,
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
import { ChartTypes, getAccessibleDataObject, XAxisTypes, getTypeOfAxis, formatScientificLimitWidth, getBarWidth, getScalePadding, isScalePaddingDefined, calculateAppropriateBarWidth, areArraysEqual, calculateLongestLabelWidth, useRtl, DataVizPalette, getColorFromToken, findVSBCNumericMinMaxOfY, YAxisType, createNumericYAxis, domainRangeOfDateForAreaLineScatterVerticalBarCharts, domainRangeOfVSBCNumeric, domainRangeOfXStringAxis, createStringYAxis, calcTotalWidth, calcBandwidth, calcRequiredWidth, sortAxisCategories } from '../../utilities/index';
|
|
10
|
+
import { formatDateToLocaleString, isInvalidValue } from '@fluentui/chart-utilities';
|
|
11
|
+
import { useImageExport } from '../../utilities/hooks';
|
|
13
12
|
const barGapMultiplier = 0.2;
|
|
14
13
|
const barGapMin = 1;
|
|
15
14
|
const MIN_DOMAIN_MARGIN = 8;
|
|
@@ -23,7 +22,6 @@ export const VerticalStackedBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
23
22
|
};
|
|
24
23
|
const _isRtl = useRtl();
|
|
25
24
|
const _createLegendsForLine = (data)=>_getLineLegends(data);
|
|
26
|
-
const _tooltipId = useId('VSBCTooltipId_');
|
|
27
25
|
const _emptyChartId = useId('_VSBC_empty');
|
|
28
26
|
let _points = [];
|
|
29
27
|
let _dataset;
|
|
@@ -40,9 +38,8 @@ export const VerticalStackedBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
40
38
|
let _domainMargin = MIN_DOMAIN_MARGIN;
|
|
41
39
|
let _xAxisInnerPadding = 0;
|
|
42
40
|
let _xAxisOuterPadding = 0;
|
|
43
|
-
const cartesianChartRef =
|
|
41
|
+
const { cartesianChartRef, legendsRef: _legendsRef } = useImageExport(props.componentRef, props.hideLegend);
|
|
44
42
|
const Y_ORIGIN = 0;
|
|
45
|
-
const _legendsRef = React.useRef(null);
|
|
46
43
|
let _yAxisType;
|
|
47
44
|
let _yAxisLabels = [];
|
|
48
45
|
const [selectedLegends, setSelectedLegends] = React.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
|
|
@@ -81,17 +78,6 @@ export const VerticalStackedBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
81
78
|
}, [
|
|
82
79
|
props
|
|
83
80
|
]);
|
|
84
|
-
React.useImperativeHandle(props.componentRef, ()=>{
|
|
85
|
-
var _cartesianChartRef_current;
|
|
86
|
-
var _cartesianChartRef_current_chartContainer;
|
|
87
|
-
return {
|
|
88
|
-
chartContainer: (_cartesianChartRef_current_chartContainer = (_cartesianChartRef_current = cartesianChartRef.current) === null || _cartesianChartRef_current === void 0 ? void 0 : _cartesianChartRef_current.chartContainer) !== null && _cartesianChartRef_current_chartContainer !== void 0 ? _cartesianChartRef_current_chartContainer : null,
|
|
89
|
-
toImage: (opts)=>{
|
|
90
|
-
var _cartesianChartRef_current, _legendsRef_current;
|
|
91
|
-
return toImage((_cartesianChartRef_current = cartesianChartRef.current) === null || _cartesianChartRef_current === void 0 ? void 0 : _cartesianChartRef_current.chartContainer, (_legendsRef_current = _legendsRef.current) === null || _legendsRef_current === void 0 ? void 0 : _legendsRef_current.toSVG, _isRtl, opts);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}, []);
|
|
95
81
|
function _getLegendData(data, lineLegends) {
|
|
96
82
|
if (props.hideLegend) {
|
|
97
83
|
return /*#__PURE__*/ React.createElement(React.Fragment, null);
|
|
@@ -140,7 +126,7 @@ export const VerticalStackedBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
140
126
|
legendsOfLine.push(legend);
|
|
141
127
|
});
|
|
142
128
|
}
|
|
143
|
-
const totalLegends =
|
|
129
|
+
const totalLegends = actions.concat(legendsOfLine);
|
|
144
130
|
return /*#__PURE__*/ React.createElement(Legends, {
|
|
145
131
|
legends: totalLegends,
|
|
146
132
|
enabledWrapLines: props.enabledLegendsWrapLines,
|
|
@@ -179,16 +165,17 @@ export const VerticalStackedBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
179
165
|
_onStackHoverFocus(lineData.xItem, event);
|
|
180
166
|
}
|
|
181
167
|
}
|
|
182
|
-
function _onStackHoverFocus(stack,
|
|
168
|
+
function _onStackHoverFocus(stack, event) {
|
|
183
169
|
var _stack_lineData;
|
|
184
170
|
let clientX = 0;
|
|
185
171
|
let clientY = 0;
|
|
186
|
-
if ('clientX' in
|
|
187
|
-
clientX =
|
|
188
|
-
clientY =
|
|
172
|
+
if ('clientX' in event) {
|
|
173
|
+
clientX = event.clientX;
|
|
174
|
+
clientY = event.clientY;
|
|
189
175
|
} else {
|
|
190
|
-
// Handle
|
|
191
|
-
const
|
|
176
|
+
// Handle React FocusEvent or SVGGElement
|
|
177
|
+
const element = 'target' in event ? event.target : event;
|
|
178
|
+
const boundingRect = element.getBoundingClientRect();
|
|
192
179
|
clientX = boundingRect.left + boundingRect.width / 2;
|
|
193
180
|
clientY = boundingRect.top + boundingRect.height / 2;
|
|
194
181
|
}
|
|
@@ -231,6 +218,7 @@ export const VerticalStackedBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
231
218
|
props.href ? window.location.href = props.href : '';
|
|
232
219
|
};
|
|
233
220
|
function _adjustProps() {
|
|
221
|
+
var _points_;
|
|
234
222
|
_points = props.data || [];
|
|
235
223
|
_barWidth = getBarWidth(props.barWidth, props.maxBarWidth);
|
|
236
224
|
const defaultColors = [
|
|
@@ -241,7 +229,8 @@ export const VerticalStackedBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
241
229
|
getColorFromToken(DataVizPalette.color10)
|
|
242
230
|
];
|
|
243
231
|
_colors = defaultColors;
|
|
244
|
-
|
|
232
|
+
const firstXValue = (_points_ = _points[0]) === null || _points_ === void 0 ? void 0 : _points_.xAxisPoint;
|
|
233
|
+
_xAxisType = isInvalidValue(firstXValue) ? XAxisTypes.StringAxis : getTypeOfAxis(firstXValue, true);
|
|
245
234
|
_lineObject = _getFormattedLineData(props.data);
|
|
246
235
|
_xAxisInnerPadding = getScalePadding(props.xAxisInnerPadding, props.xAxisPadding, _xAxisType === XAxisTypes.StringAxis ? 2 / 3 : 1 / 2);
|
|
247
236
|
_xAxisOuterPadding = getScalePadding(props.xAxisOuterPadding, props.xAxisPadding, 0);
|
|
@@ -873,17 +862,26 @@ export const VerticalStackedBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
873
862
|
};
|
|
874
863
|
let showLabel = false;
|
|
875
864
|
let barLabel = 0;
|
|
865
|
+
let selectedBarTotalValue = 0;
|
|
866
|
+
let customBarLabel = undefined;
|
|
876
867
|
if (!props.hideLabels && _yAxisType !== YAxisType.StringAxis) {
|
|
868
|
+
// Collect all bars with barLabel that match the legend filter
|
|
869
|
+
const barLabelsToDisplay = barsToDisplay.filter((point)=>point.barLabel && (_noLegendHighlighted() || _isLegendHighlighted(point.legend)));
|
|
870
|
+
if (barLabelsToDisplay.length > 0) {
|
|
871
|
+
customBarLabel = barLabelsToDisplay[barLabelsToDisplay.length - 1].barLabel;
|
|
872
|
+
}
|
|
877
873
|
if (_noLegendHighlighted()) {
|
|
878
874
|
showLabel = true;
|
|
879
|
-
barLabel = barTotalValue;
|
|
875
|
+
barLabel = customBarLabel !== null && customBarLabel !== void 0 ? customBarLabel : barTotalValue;
|
|
876
|
+
selectedBarTotalValue = barTotalValue;
|
|
880
877
|
} else {
|
|
881
878
|
barsToDisplay.forEach((point)=>{
|
|
882
879
|
if (_isLegendHighlighted(point.legend)) {
|
|
883
880
|
showLabel = true;
|
|
884
|
-
|
|
881
|
+
selectedBarTotalValue += point.data;
|
|
885
882
|
}
|
|
886
883
|
});
|
|
884
|
+
barLabel = customBarLabel !== null && customBarLabel !== void 0 ? customBarLabel : selectedBarTotalValue;
|
|
887
885
|
}
|
|
888
886
|
}
|
|
889
887
|
return /*#__PURE__*/ React.createElement("g", {
|
|
@@ -897,7 +895,7 @@ export const VerticalStackedBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
897
895
|
}, singleBar), !props.hideLabels && _barWidth >= 16 && showLabel && /*#__PURE__*/ React.createElement("text", {
|
|
898
896
|
x: xPoint + _barWidth / 2,
|
|
899
897
|
//if total bar value >=0, show label above top bar, otherwise below bottom bar
|
|
900
|
-
y:
|
|
898
|
+
y: selectedBarTotalValue >= Y_ORIGIN ? yPoint - 6 : yPoint + heightOfLastBar + 12,
|
|
901
899
|
textAnchor: "middle",
|
|
902
900
|
className: classes.barLabel,
|
|
903
901
|
"aria-label": `Total: ${barLabel}`,
|
|
@@ -907,27 +905,8 @@ export const VerticalStackedBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
907
905
|
direction: 'ltr',
|
|
908
906
|
unicodeBidi: 'isolate'
|
|
909
907
|
}
|
|
910
|
-
}, typeof props.yAxisTickFormat === 'function' ? props.yAxisTickFormat(barLabel) : formatScientificLimitWidth(barLabel)));
|
|
908
|
+
}, typeof barLabel === 'string' ? barLabel : typeof props.yAxisTickFormat === 'function' ? props.yAxisTickFormat(barLabel) : formatScientificLimitWidth(barLabel)));
|
|
911
909
|
});
|
|
912
|
-
if (!props.showXAxisLablesTooltip) {
|
|
913
|
-
try {
|
|
914
|
-
document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
|
|
915
|
-
// eslint-disable-next-line no-empty
|
|
916
|
-
} catch (e) {}
|
|
917
|
-
}
|
|
918
|
-
if (!props.wrapXAxisLables && props.showXAxisLablesTooltip) {
|
|
919
|
-
const xAxisElement = d3Select(xElement).call(xBarScale);
|
|
920
|
-
try {
|
|
921
|
-
document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
|
|
922
|
-
// eslint-disable-next-line no-empty
|
|
923
|
-
} catch (e) {}
|
|
924
|
-
const tooltipProps = {
|
|
925
|
-
tooltipCls: classes.tooltip,
|
|
926
|
-
id: _tooltipId,
|
|
927
|
-
axis: xAxisElement
|
|
928
|
-
};
|
|
929
|
-
xAxisElement && tooltipOfAxislabels(tooltipProps);
|
|
930
|
-
}
|
|
931
910
|
return bars.filter((bar)=>!!bar);
|
|
932
911
|
}
|
|
933
912
|
function _getMinMaxOfYAxis(dataset, yAxisType, useSecondaryYScale) {
|