@fluentui/react-charts 9.0.2 → 9.0.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 +48 -7
- package/dist/index.d.ts +767 -0
- package/lib/AreaChart.js +1 -0
- package/lib/AreaChart.js.map +1 -0
- package/lib/HeatMapChart.js +1 -0
- package/lib/HeatMapChart.js.map +1 -0
- package/lib/HorizontalBarChartWithAxis.js +1 -0
- package/lib/HorizontalBarChartWithAxis.js.map +1 -0
- package/lib/SankeyChart.js +1 -0
- package/lib/SankeyChart.js.map +1 -0
- package/lib/VerticalStackedBarChart.js +1 -0
- package/lib/VerticalStackedBarChart.js.map +1 -0
- package/lib/components/AreaChart/AreaChart.js +775 -0
- package/lib/components/AreaChart/AreaChart.js.map +1 -0
- package/lib/components/AreaChart/AreaChart.types.js +4 -0
- package/lib/components/AreaChart/AreaChart.types.js.map +1 -0
- package/lib/components/AreaChart/index.js +3 -0
- package/lib/components/AreaChart/index.js.map +1 -0
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +64 -0
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.js +30 -14
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +112 -65
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +570 -159
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.js +1 -1
- package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +1 -1
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +3 -0
- 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 +9 -0
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +588 -0
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -0
- package/lib/components/HeatMapChart/HeatMapChart.types.js +4 -0
- package/lib/components/HeatMapChart/HeatMapChart.types.js.map +1 -0
- package/lib/components/HeatMapChart/index.js +3 -0
- package/lib/components/HeatMapChart/index.js.map +1 -0
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +46 -0
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -0
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +571 -0
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -0
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +4 -0
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -0
- package/lib/components/HorizontalBarChartWithAxis/index.js +3 -0
- package/lib/components/HorizontalBarChartWithAxis/index.js.map +1 -0
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +76 -0
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -0
- package/lib/components/Legends/Legends.js +38 -37
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +43 -35
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.js +1022 -0
- package/lib/components/SankeyChart/SankeyChart.js.map +1 -0
- package/lib/components/SankeyChart/SankeyChart.types.js +3 -0
- package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -0
- package/lib/components/SankeyChart/index.js +3 -0
- package/lib/components/SankeyChart/index.js.map +1 -0
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +109 -0
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -0
- package/lib/components/ScatterChart/ScatterChart.js +46 -59
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +165 -88
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +904 -0
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -0
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +1 -0
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -0
- package/lib/components/VerticalStackedBarChart/index.js +3 -0
- package/lib/components/VerticalStackedBarChart/index.js.map +1 -0
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +73 -0
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -0
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -1
- package/lib/types/DataPoint.js +1 -3
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/SVGTooltipText.js +49 -4
- package/lib/utilities/SVGTooltipText.js.map +1 -1
- package/lib/utilities/colors.js +20 -0
- package/lib/utilities/colors.js.map +1 -1
- package/lib/utilities/string.js +32 -0
- package/lib/utilities/string.js.map +1 -0
- package/lib/utilities/test-data.js +53 -0
- package/lib/utilities/test-data.js.map +1 -1
- package/lib/utilities/utilities.js +90 -18
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/AreaChart.js +6 -0
- package/lib-commonjs/AreaChart.js.map +1 -0
- package/lib-commonjs/HeatMapChart.js +6 -0
- package/lib-commonjs/HeatMapChart.js.map +1 -0
- package/lib-commonjs/HorizontalBarChartWithAxis.js +6 -0
- package/lib-commonjs/HorizontalBarChartWithAxis.js.map +1 -0
- package/lib-commonjs/SankeyChart.js +6 -0
- package/lib-commonjs/SankeyChart.js.map +1 -0
- package/lib-commonjs/VerticalStackedBarChart.js +6 -0
- package/lib-commonjs/VerticalStackedBarChart.js.map +1 -0
- package/lib-commonjs/components/AreaChart/AreaChart.js +781 -0
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -0
- package/lib-commonjs/components/AreaChart/AreaChart.types.js +7 -0
- package/lib-commonjs/components/AreaChart/AreaChart.types.js.map +1 -0
- package/lib-commonjs/components/AreaChart/index.js +8 -0
- package/lib-commonjs/components/AreaChart/index.js.map +1 -0
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +104 -0
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +29 -14
- 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/DeclarativeChart/DeclarativeChart.js +120 -73
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +592 -178
- 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.js +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +3 -0
- 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 +9 -0
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +599 -0
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -0
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js +7 -0
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js.map +1 -0
- package/lib-commonjs/components/HeatMapChart/index.js +8 -0
- package/lib-commonjs/components/HeatMapChart/index.js.map +1 -0
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +68 -0
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +580 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +7 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js +8 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js.map +1 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +116 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -0
- package/lib-commonjs/components/Legends/Legends.js +37 -37
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +41 -33
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.js +1038 -0
- package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -0
- package/lib-commonjs/components/SankeyChart/SankeyChart.types.js +6 -0
- package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -0
- package/lib-commonjs/components/SankeyChart/index.js +8 -0
- package/lib-commonjs/components/SankeyChart/index.js.map +1 -0
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +179 -0
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +45 -58
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +164 -87
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +915 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +6 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -0
- package/lib-commonjs/components/VerticalStackedBarChart/index.js +8 -0
- package/lib-commonjs/components/VerticalStackedBarChart/index.js.map +1 -0
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +120 -0
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -0
- package/lib-commonjs/index.js +5 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js +1 -3
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/SVGTooltipText.js +49 -4
- package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/colors.js +23 -0
- package/lib-commonjs/utilities/colors.js.map +1 -1
- package/lib-commonjs/utilities/string.js +29 -0
- package/lib-commonjs/utilities/string.js.map +1 -0
- package/lib-commonjs/utilities/test-data.js +59 -0
- package/lib-commonjs/utilities/test-data.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +94 -17
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +11 -8
- package/lib/components/DeclarativeChart/PlotlySchema.js +0 -7
- package/lib/components/DeclarativeChart/PlotlySchema.js.map +0 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js +0 -10
- package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js.map +0 -1
|
@@ -0,0 +1,904 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { max as d3Max, min as d3Min } from 'd3-array';
|
|
3
|
+
import { select as d3Select } from 'd3-selection';
|
|
4
|
+
import { useVerticalStackedBarChartStyles } from './useVerticalStackedBarChartStyles.styles';
|
|
5
|
+
import { scaleLinear as d3ScaleLinear, scaleBand as d3ScaleBand, scaleUtc as d3ScaleUtc, scaleTime as d3ScaleTime } from 'd3-scale';
|
|
6
|
+
import { useId } from '@fluentui/react-utilities';
|
|
7
|
+
import { tokens } from '@fluentui/react-theme';
|
|
8
|
+
import { CartesianChart, ChartPopover, Legends } from '../../index';
|
|
9
|
+
import { ChartTypes, getAccessibleDataObject, XAxisTypes, getTypeOfAxis, tooltipOfXAxislabels, formatValueWithSIPrefix, getBarWidth, getScalePadding, isScalePaddingDefined, calculateAppropriateBarWidth, formatDate, areArraysEqual, calculateLongestLabelWidth, useRtl, DataVizPalette, getColorFromToken } from '../../utilities/index';
|
|
10
|
+
const barGapMultiplier = 0.2;
|
|
11
|
+
const barGapMin = 1;
|
|
12
|
+
const MIN_DOMAIN_MARGIN = 8;
|
|
13
|
+
var CircleVisbility;
|
|
14
|
+
(function(CircleVisbility) {
|
|
15
|
+
CircleVisbility["show"] = "visibility";
|
|
16
|
+
CircleVisbility["hide"] = "hidden";
|
|
17
|
+
})(CircleVisbility || (CircleVisbility = {}));
|
|
18
|
+
export const VerticalStackedBarChart = (props)=>{
|
|
19
|
+
var _props_legendProps;
|
|
20
|
+
const _isRtl = useRtl();
|
|
21
|
+
const _createLegendsForLine = (data)=>_getLineLegends(data);
|
|
22
|
+
const _tooltipId = useId('VSBCTooltipId_');
|
|
23
|
+
const _emptyChartId = useId('_VSBC_empty');
|
|
24
|
+
let _points = [];
|
|
25
|
+
let _dataset;
|
|
26
|
+
let _xAxisLabels = [];
|
|
27
|
+
let _bars;
|
|
28
|
+
let _xAxisType = props.data && props.data.length > 0 ? getTypeOfAxis(props.data[0].xAxisPoint, true) : XAxisTypes.StringAxis;
|
|
29
|
+
let _barWidth = 0;
|
|
30
|
+
let _colors;
|
|
31
|
+
let _margins;
|
|
32
|
+
let _lineObject;
|
|
33
|
+
let _yMax;
|
|
34
|
+
let _calloutAnchorPoint;
|
|
35
|
+
let _domainMargin = MIN_DOMAIN_MARGIN;
|
|
36
|
+
let _xAxisInnerPadding = 0;
|
|
37
|
+
let _xAxisOuterPadding = 0;
|
|
38
|
+
const cartesianChartRef = React.useRef(null);
|
|
39
|
+
const [selectedLegends, setSelectedLegends] = React.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
|
|
40
|
+
const [activeLegend, setActiveLegend] = React.useState(undefined);
|
|
41
|
+
const [dataForHoverCard, setDataForHoverCard] = React.useState(0);
|
|
42
|
+
const [color, setColor] = React.useState('');
|
|
43
|
+
const [hoverXValue, setHoverXValue] = React.useState('');
|
|
44
|
+
const [YValueHover, setYValueHover] = React.useState([]);
|
|
45
|
+
const [xCalloutValue, setXCalloutValue] = React.useState('');
|
|
46
|
+
const [yCalloutValue, setYCalloutValue] = React.useState('');
|
|
47
|
+
const [activeXAxisDataPoint, setActiveXAxisDataPoint] = React.useState('');
|
|
48
|
+
const [calloutLegend, setCalloutLegend] = React.useState('');
|
|
49
|
+
const [stackCalloutProps, setStackCalloutProps] = React.useState();
|
|
50
|
+
const [dataPointCalloutProps, setDataPointCalloutProps] = React.useState();
|
|
51
|
+
const [callOutAccessibilityData, setCallOutAccessibilityData] = React.useState();
|
|
52
|
+
const [clickPosition, setClickPosition] = React.useState({
|
|
53
|
+
x: 0,
|
|
54
|
+
y: 0
|
|
55
|
+
});
|
|
56
|
+
const [isPopoverOpen, setPopoverOpen] = React.useState(false);
|
|
57
|
+
const prevPropsRef = React.useRef(null);
|
|
58
|
+
React.useEffect(()=>{
|
|
59
|
+
if (prevPropsRef.current) {
|
|
60
|
+
var _prevProps_legendProps, _props_legendProps;
|
|
61
|
+
const prevProps = prevPropsRef.current;
|
|
62
|
+
if (!areArraysEqual((_prevProps_legendProps = prevProps.legendProps) === null || _prevProps_legendProps === void 0 ? void 0 : _prevProps_legendProps.selectedLegends, (_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends)) {
|
|
63
|
+
var _props_legendProps1;
|
|
64
|
+
setSelectedLegends(((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.selectedLegends) || []);
|
|
65
|
+
}
|
|
66
|
+
if (prevProps.height !== props.height || prevProps.width !== props.width || prevProps.data !== props.data) {
|
|
67
|
+
_adjustProps();
|
|
68
|
+
_dataset = _createDataSetLayer();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
prevPropsRef.current = props;
|
|
72
|
+
}, [
|
|
73
|
+
props
|
|
74
|
+
]);
|
|
75
|
+
React.useImperativeHandle(props.componentRef, ()=>{
|
|
76
|
+
var _cartesianChartRef_current;
|
|
77
|
+
var _cartesianChartRef_current_chartContainer;
|
|
78
|
+
return {
|
|
79
|
+
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
|
|
80
|
+
};
|
|
81
|
+
}, []);
|
|
82
|
+
function _getLegendData(data, lineLegends) {
|
|
83
|
+
if (props.hideLegend) {
|
|
84
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null);
|
|
85
|
+
}
|
|
86
|
+
const defaultPalette = [
|
|
87
|
+
getColorFromToken(DataVizPalette.color6),
|
|
88
|
+
getColorFromToken(DataVizPalette.color1),
|
|
89
|
+
getColorFromToken(DataVizPalette.color5),
|
|
90
|
+
getColorFromToken(DataVizPalette.color7),
|
|
91
|
+
getColorFromToken(DataVizPalette.color10)
|
|
92
|
+
];
|
|
93
|
+
const actions = [];
|
|
94
|
+
const { allowHoverOnLegend = true } = props;
|
|
95
|
+
data.forEach((singleChartData)=>{
|
|
96
|
+
singleChartData.chartData.forEach((point)=>{
|
|
97
|
+
const color = point.color ? point.color : defaultPalette[Math.floor(Math.random() * 4 + 1)];
|
|
98
|
+
const checkSimilarLegends = actions.filter((leg)=>leg.title === point.legend && leg.color === color);
|
|
99
|
+
if (checkSimilarLegends.length > 0) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const legend = {
|
|
103
|
+
title: point.legend,
|
|
104
|
+
color,
|
|
105
|
+
hoverAction: allowHoverOnLegend ? ()=>{
|
|
106
|
+
_handleChartMouseLeave();
|
|
107
|
+
_onLegendHover(point.legend);
|
|
108
|
+
} : undefined,
|
|
109
|
+
onMouseOutAction: allowHoverOnLegend ? ()=>_onLegendLeave() : undefined
|
|
110
|
+
};
|
|
111
|
+
actions.push(legend);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
const legendsOfLine = [];
|
|
115
|
+
if (lineLegends && lineLegends.length > 0) {
|
|
116
|
+
lineLegends.forEach((point)=>{
|
|
117
|
+
const legend = {
|
|
118
|
+
title: point.title,
|
|
119
|
+
color: point.color,
|
|
120
|
+
isLineLegendInBarChart: true,
|
|
121
|
+
hoverAction: allowHoverOnLegend ? ()=>{
|
|
122
|
+
_handleChartMouseLeave();
|
|
123
|
+
_onLegendHover(point.title);
|
|
124
|
+
} : undefined,
|
|
125
|
+
onMouseOutAction: allowHoverOnLegend ? ()=>_onLegendLeave() : undefined
|
|
126
|
+
};
|
|
127
|
+
legendsOfLine.push(legend);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const totalLegends = legendsOfLine.concat(actions);
|
|
131
|
+
return /*#__PURE__*/ React.createElement(Legends, {
|
|
132
|
+
legends: totalLegends,
|
|
133
|
+
enabledWrapLines: props.enabledLegendsWrapLines,
|
|
134
|
+
overflowText: props.legendsOverflowText,
|
|
135
|
+
...props.legendProps,
|
|
136
|
+
onChange: _onLegendSelectionChange
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function _getHighlightedLegend() {
|
|
140
|
+
return selectedLegends.length > 0 ? selectedLegends : activeLegend ? [
|
|
141
|
+
activeLegend
|
|
142
|
+
] : [];
|
|
143
|
+
}
|
|
144
|
+
function _lineHoverOut() {
|
|
145
|
+
setPopoverOpen(false);
|
|
146
|
+
setXCalloutValue('');
|
|
147
|
+
setYCalloutValue('');
|
|
148
|
+
setActiveXAxisDataPoint('');
|
|
149
|
+
setColor('');
|
|
150
|
+
}
|
|
151
|
+
function _lineHoverFocus(lineData) {
|
|
152
|
+
setPopoverOpen(true);
|
|
153
|
+
setXCalloutValue(`${lineData.xItem.xAxisPoint}`);
|
|
154
|
+
setYCalloutValue(`${lineData.yAxisCalloutData || lineData.data || lineData.y}`);
|
|
155
|
+
setActiveXAxisDataPoint(lineData.xItem.xAxisPoint);
|
|
156
|
+
setColor(lineData.color);
|
|
157
|
+
}
|
|
158
|
+
function _onStackHoverFocus(stack, mouseEvent) {
|
|
159
|
+
var _stack_lineData;
|
|
160
|
+
let clientX = 0;
|
|
161
|
+
let clientY = 0;
|
|
162
|
+
if ('clientX' in mouseEvent) {
|
|
163
|
+
clientX = mouseEvent.clientX;
|
|
164
|
+
clientY = mouseEvent.clientY;
|
|
165
|
+
} else {
|
|
166
|
+
// Handle case where mouseEvent is an SVGGElement
|
|
167
|
+
const boundingRect = mouseEvent.getBoundingClientRect();
|
|
168
|
+
clientX = boundingRect.left + boundingRect.width / 2;
|
|
169
|
+
clientY = boundingRect.top + boundingRect.height / 2;
|
|
170
|
+
}
|
|
171
|
+
if (!_noLegendHighlighted()) {
|
|
172
|
+
var _stack_lineData1;
|
|
173
|
+
stack = {
|
|
174
|
+
...stack,
|
|
175
|
+
chartData: stack.chartData.filter((dataPoint)=>_isLegendHighlighted(dataPoint.legend)),
|
|
176
|
+
lineData: (_stack_lineData1 = stack.lineData) === null || _stack_lineData1 === void 0 ? void 0 : _stack_lineData1.filter((dataPoint)=>_isLegendHighlighted(dataPoint.legend))
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const lineData = stack.lineData;
|
|
180
|
+
const isLinesPresent = lineData !== undefined && lineData.length > 0;
|
|
181
|
+
if (isLinesPresent) {
|
|
182
|
+
lineData.forEach((item)=>{
|
|
183
|
+
item.data = item.data || item.y;
|
|
184
|
+
item.shouldDrawBorderBottom = true;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
_updatePosition(clientX, clientY);
|
|
188
|
+
var _stack_lineData_length;
|
|
189
|
+
setPopoverOpen(stack.chartData.length > 0 || ((_stack_lineData_length = (_stack_lineData = stack.lineData) === null || _stack_lineData === void 0 ? void 0 : _stack_lineData.length) !== null && _stack_lineData_length !== void 0 ? _stack_lineData_length : 0) > 0);
|
|
190
|
+
setYValueHover(isLinesPresent ? [
|
|
191
|
+
...lineData.sort((a, b)=>a.data < b.data ? 1 : -1),
|
|
192
|
+
...stack.chartData.slice().reverse()
|
|
193
|
+
] : stack.chartData.slice().reverse());
|
|
194
|
+
setHoverXValue(stack.xAxisPoint instanceof Date ? formatDate(stack.xAxisPoint, props.useUTC) : stack.xAxisPoint);
|
|
195
|
+
setStackCalloutProps(stack);
|
|
196
|
+
setActiveXAxisDataPoint(stack.xAxisPoint);
|
|
197
|
+
setCallOutAccessibilityData(stack.stackCallOutAccessibilityData);
|
|
198
|
+
}
|
|
199
|
+
function _handleChartMouseLeave() {
|
|
200
|
+
_calloutAnchorPoint = null;
|
|
201
|
+
setPopoverOpen(false);
|
|
202
|
+
setActiveXAxisDataPoint('');
|
|
203
|
+
}
|
|
204
|
+
const _onClick = (data, mouseEvent)=>{
|
|
205
|
+
var _props_onBarClick;
|
|
206
|
+
(_props_onBarClick = props.onBarClick) === null || _props_onBarClick === void 0 ? void 0 : _props_onBarClick.call(props, mouseEvent, data);
|
|
207
|
+
props.href ? window.location.href = props.href : '';
|
|
208
|
+
};
|
|
209
|
+
function _adjustProps() {
|
|
210
|
+
_points = props.data || [];
|
|
211
|
+
_barWidth = getBarWidth(props.barWidth, props.maxBarWidth);
|
|
212
|
+
const defaultColors = [
|
|
213
|
+
getColorFromToken(DataVizPalette.color6),
|
|
214
|
+
getColorFromToken(DataVizPalette.color1),
|
|
215
|
+
getColorFromToken(DataVizPalette.color5),
|
|
216
|
+
getColorFromToken(DataVizPalette.color7),
|
|
217
|
+
getColorFromToken(DataVizPalette.color10)
|
|
218
|
+
];
|
|
219
|
+
_colors = defaultColors;
|
|
220
|
+
_xAxisType = getTypeOfAxis(props.data[0].xAxisPoint, true);
|
|
221
|
+
_lineObject = _getFormattedLineData(props.data);
|
|
222
|
+
_xAxisInnerPadding = getScalePadding(props.xAxisInnerPadding, props.xAxisPadding, 2 / 3);
|
|
223
|
+
_xAxisOuterPadding = getScalePadding(props.xAxisOuterPadding, props.xAxisPadding, 0);
|
|
224
|
+
}
|
|
225
|
+
function _createDataSetLayer() {
|
|
226
|
+
const tempArr = [];
|
|
227
|
+
const dataset = _points.map((singlePointData)=>{
|
|
228
|
+
let total = 0;
|
|
229
|
+
singlePointData.chartData.forEach((point)=>{
|
|
230
|
+
total = total + point.data;
|
|
231
|
+
});
|
|
232
|
+
tempArr.push(singlePointData.xAxisPoint);
|
|
233
|
+
return {
|
|
234
|
+
x: singlePointData.xAxisPoint,
|
|
235
|
+
y: total
|
|
236
|
+
};
|
|
237
|
+
});
|
|
238
|
+
_xAxisLabels = tempArr;
|
|
239
|
+
return dataset;
|
|
240
|
+
}
|
|
241
|
+
function _onLegendHover(legendTitle) {
|
|
242
|
+
setActiveLegend(legendTitle);
|
|
243
|
+
}
|
|
244
|
+
function _onLegendLeave() {
|
|
245
|
+
setActiveLegend(undefined);
|
|
246
|
+
}
|
|
247
|
+
function _onLegendSelectionChange(_selectedLegends, event, currentLegend) {
|
|
248
|
+
var _props_legendProps, _props_legendProps1;
|
|
249
|
+
if ((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.canSelectMultipleLegends) {
|
|
250
|
+
setSelectedLegends(_selectedLegends);
|
|
251
|
+
} else {
|
|
252
|
+
setSelectedLegends(_selectedLegends.slice(-1));
|
|
253
|
+
}
|
|
254
|
+
if ((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.onChange) {
|
|
255
|
+
props.legendProps.onChange(_selectedLegends, event, currentLegend);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function _getMargins(margins) {
|
|
259
|
+
_margins = margins;
|
|
260
|
+
}
|
|
261
|
+
function _getGraphData(xScale, yScale, containerHeight, containerWidth, xElement) {
|
|
262
|
+
const { xBarScale, yBarScale } = _getScales(containerHeight, containerWidth);
|
|
263
|
+
return _bars = _createBar(xBarScale, yBarScale, containerHeight, xElement);
|
|
264
|
+
}
|
|
265
|
+
function _getAxisData(yAxisData) {
|
|
266
|
+
if (yAxisData && yAxisData.yAxisDomainValues.length) {
|
|
267
|
+
const { yAxisDomainValues: domainValue } = yAxisData;
|
|
268
|
+
_yMax = Math.max(domainValue[domainValue.length - 1], props.yMaxValue || 0);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* This function checks if the given legend is highlighted or not.
|
|
273
|
+
* A legend can be highlighted in 2 ways:
|
|
274
|
+
* 1. selection: if the user clicks on it
|
|
275
|
+
* 2. hovering: if there is no selected legend and the user hovers over it
|
|
276
|
+
*/ function _isLegendHighlighted(legendTitle) {
|
|
277
|
+
return _getHighlightedLegend().includes(legendTitle);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* This function checks if none of the legends is selected or hovered.
|
|
281
|
+
*/ function _noLegendHighlighted() {
|
|
282
|
+
return _getHighlightedLegend().length === 0;
|
|
283
|
+
}
|
|
284
|
+
function _getAriaLabel(singleChartData, point) {
|
|
285
|
+
var _point_callOutAccessibilityData;
|
|
286
|
+
if (!point) {
|
|
287
|
+
var _singleChartData_lineData, _singleChartData_stackCallOutAccessibilityData;
|
|
288
|
+
/** if shouldFocusWholeStack is true */ const xValue = singleChartData.xAxisCalloutData || (singleChartData.xAxisPoint instanceof Date ? formatDate(singleChartData.xAxisPoint) : singleChartData.xAxisPoint);
|
|
289
|
+
const pointValues = singleChartData.chartData.map((pt)=>{
|
|
290
|
+
const legend = pt.legend;
|
|
291
|
+
const yValue = pt.yAxisCalloutData || pt.data;
|
|
292
|
+
return `${legend}, ${yValue}.`;
|
|
293
|
+
}).join(' ');
|
|
294
|
+
const lineValues = (_singleChartData_lineData = singleChartData.lineData) === null || _singleChartData_lineData === void 0 ? void 0 : _singleChartData_lineData.map((ln)=>{
|
|
295
|
+
const legend = ln.legend;
|
|
296
|
+
const yValue = ln.yAxisCalloutData || ln.data || ln.y;
|
|
297
|
+
return `${legend}, ${yValue}.`;
|
|
298
|
+
}).join(' ');
|
|
299
|
+
return ((_singleChartData_stackCallOutAccessibilityData = singleChartData.stackCallOutAccessibilityData) === null || _singleChartData_stackCallOutAccessibilityData === void 0 ? void 0 : _singleChartData_stackCallOutAccessibilityData.ariaLabel) || `${xValue}. ${pointValues}` + (lineValues ? ` ${lineValues}` : '');
|
|
300
|
+
}
|
|
301
|
+
/** if shouldFocusWholeStack is false */ const xValue = singleChartData.xAxisCalloutData || point.xAxisCalloutData || (singleChartData.xAxisPoint instanceof Date ? formatDate(singleChartData.xAxisPoint) : singleChartData.xAxisPoint);
|
|
302
|
+
const legend = point.legend;
|
|
303
|
+
const yValue = point.yAxisCalloutData || point.data;
|
|
304
|
+
return ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ${legend}, ${yValue}.`;
|
|
305
|
+
}
|
|
306
|
+
function _getCustomizedCallout() {
|
|
307
|
+
const _isHavingLines = props.data.some((item)=>item.lineData && item.lineData.length > 0);
|
|
308
|
+
return props.onRenderCalloutPerStack ? props.onRenderCalloutPerStack(stackCalloutProps) : props.onRenderCalloutPerDataPoint && !_isHavingLines ? props.onRenderCalloutPerDataPoint(dataPointCalloutProps, _renderCallout) : null;
|
|
309
|
+
}
|
|
310
|
+
function _toFocusWholeStack(_isHavingLines) {
|
|
311
|
+
const { isCalloutForStack = false } = props;
|
|
312
|
+
let shouldFocusStackOnly = false;
|
|
313
|
+
if (_isHavingLines) {
|
|
314
|
+
if (_getHighlightedLegend().length === 1) {
|
|
315
|
+
shouldFocusStackOnly = false;
|
|
316
|
+
} else {
|
|
317
|
+
shouldFocusStackOnly = true;
|
|
318
|
+
}
|
|
319
|
+
} else {
|
|
320
|
+
shouldFocusStackOnly = isCalloutForStack;
|
|
321
|
+
}
|
|
322
|
+
return shouldFocusStackOnly;
|
|
323
|
+
}
|
|
324
|
+
function _getFormattedLineData(data) {
|
|
325
|
+
const linesData = [];
|
|
326
|
+
const formattedLineData = {};
|
|
327
|
+
data.forEach((item, index)=>{
|
|
328
|
+
if (item.lineData) {
|
|
329
|
+
item.lineData.forEach((line)=>{
|
|
330
|
+
linesData.push({
|
|
331
|
+
...line,
|
|
332
|
+
index,
|
|
333
|
+
xItem: item
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
linesData.forEach((item)=>{
|
|
339
|
+
if (formattedLineData[item.legend]) {
|
|
340
|
+
formattedLineData[item.legend].push(item);
|
|
341
|
+
} else {
|
|
342
|
+
formattedLineData[item.legend] = [
|
|
343
|
+
item
|
|
344
|
+
];
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
return formattedLineData;
|
|
348
|
+
}
|
|
349
|
+
function _getLineLegends(data) {
|
|
350
|
+
const lineObject = _lineObject;
|
|
351
|
+
const lineLegends = [];
|
|
352
|
+
Object.keys(lineObject).forEach((item)=>{
|
|
353
|
+
lineLegends.push({
|
|
354
|
+
title: item,
|
|
355
|
+
color: lineObject[item][0].color
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
return lineLegends;
|
|
359
|
+
}
|
|
360
|
+
function _createLines(xScale, yScale, containerHeight, containerWidth, secondaryYScale) {
|
|
361
|
+
var _props_lineOptions;
|
|
362
|
+
const lineObject = _getFormattedLineData(props.data);
|
|
363
|
+
const lines = [];
|
|
364
|
+
const borderForLines = [];
|
|
365
|
+
const dots = [];
|
|
366
|
+
//const { theme } = props;
|
|
367
|
+
const lineBorderWidth = ((_props_lineOptions = props.lineOptions) === null || _props_lineOptions === void 0 ? void 0 : _props_lineOptions.lineBorderWidth) ? Number.parseFloat(props.lineOptions.lineBorderWidth.toString()) : 0;
|
|
368
|
+
const xScaleBandwidthTranslate = _xAxisType !== XAxisTypes.StringAxis ? 0 : xScale.bandwidth() / 2;
|
|
369
|
+
Object.keys(lineObject).forEach((item, index)=>{
|
|
370
|
+
const shouldHighlight = _isLegendHighlighted(item) || _noLegendHighlighted();
|
|
371
|
+
for(let i = 1; i < lineObject[item].length; i++){
|
|
372
|
+
var _lineObject_item__lineOptions, _lineObject_item__lineOptions1, _lineObject_item__lineOptions2;
|
|
373
|
+
const x1 = xScale(lineObject[item][i - 1].xItem.xAxisPoint);
|
|
374
|
+
const useSecondaryYScale = lineObject[item][i - 1].useSecondaryYScale && lineObject[item][i].useSecondaryYScale && secondaryYScale;
|
|
375
|
+
const y1 = useSecondaryYScale ? secondaryYScale(lineObject[item][i - 1].y) : yScale(lineObject[item][i - 1].y);
|
|
376
|
+
const x2 = xScale(lineObject[item][i].xItem.xAxisPoint);
|
|
377
|
+
const y2 = useSecondaryYScale ? secondaryYScale(lineObject[item][i].y) : yScale(lineObject[item][i].y);
|
|
378
|
+
if (lineBorderWidth > 0) {
|
|
379
|
+
borderForLines.push(/*#__PURE__*/ React.createElement("line", {
|
|
380
|
+
key: `${index}-${i}-BorderLine`,
|
|
381
|
+
x1: x1,
|
|
382
|
+
y1: y1,
|
|
383
|
+
x2: x2,
|
|
384
|
+
y2: y2,
|
|
385
|
+
opacity: shouldHighlight ? 1 : 0.1,
|
|
386
|
+
strokeWidth: 3 + lineBorderWidth * 2,
|
|
387
|
+
fill: "transparent",
|
|
388
|
+
strokeLinecap: "round",
|
|
389
|
+
stroke: tokens.colorNeutralBackground1,
|
|
390
|
+
transform: `translate(${xScaleBandwidthTranslate}, 0)`
|
|
391
|
+
}));
|
|
392
|
+
}
|
|
393
|
+
var _lineObject_item__lineOptions_strokeWidth, _lineObject_item__lineOptions_strokeLinecap;
|
|
394
|
+
lines.push(/*#__PURE__*/ React.createElement("line", {
|
|
395
|
+
key: `${index}-${i}-line`,
|
|
396
|
+
x1: x1,
|
|
397
|
+
y1: y1,
|
|
398
|
+
x2: x2,
|
|
399
|
+
y2: y2,
|
|
400
|
+
opacity: shouldHighlight ? 1 : 0.1,
|
|
401
|
+
strokeWidth: (_lineObject_item__lineOptions_strokeWidth = (_lineObject_item__lineOptions = lineObject[item][0].lineOptions) === null || _lineObject_item__lineOptions === void 0 ? void 0 : _lineObject_item__lineOptions.strokeWidth) !== null && _lineObject_item__lineOptions_strokeWidth !== void 0 ? _lineObject_item__lineOptions_strokeWidth : 3,
|
|
402
|
+
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',
|
|
403
|
+
strokeDasharray: (_lineObject_item__lineOptions2 = lineObject[item][0].lineOptions) === null || _lineObject_item__lineOptions2 === void 0 ? void 0 : _lineObject_item__lineOptions2.strokeDasharray,
|
|
404
|
+
stroke: lineObject[item][i].color,
|
|
405
|
+
transform: `translate(${xScaleBandwidthTranslate}, 0)`,
|
|
406
|
+
..._isLegendHighlighted(item) && {
|
|
407
|
+
onMouseOver: _lineHover.bind(lineObject[item][i - 1]),
|
|
408
|
+
onMouseLeave: _lineHoverOut
|
|
409
|
+
}
|
|
410
|
+
}));
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
Object.keys(lineObject).forEach((item, index)=>{
|
|
414
|
+
lineObject[item].forEach((circlePoint, subIndex)=>{
|
|
415
|
+
const circleRef = {
|
|
416
|
+
refElement: null
|
|
417
|
+
};
|
|
418
|
+
dots.push(/*#__PURE__*/ React.createElement("circle", {
|
|
419
|
+
key: `${index}-${subIndex}-dot`,
|
|
420
|
+
cx: xScale(circlePoint.xItem.xAxisPoint),
|
|
421
|
+
cy: circlePoint.useSecondaryYScale && secondaryYScale ? secondaryYScale(circlePoint.y) : yScale(circlePoint.y),
|
|
422
|
+
onMouseOver: _isLegendHighlighted(item) ? (event)=>_lineHover(circlePoint, event) : (event)=>_onStackHover(circlePoint.xItem, event),
|
|
423
|
+
..._isLegendHighlighted(item) && {
|
|
424
|
+
onMouseLeave: _lineHoverOut
|
|
425
|
+
},
|
|
426
|
+
r: _getCircleVisibilityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).radius,
|
|
427
|
+
stroke: circlePoint.color,
|
|
428
|
+
fill: tokens.colorNeutralBackground1,
|
|
429
|
+
strokeWidth: 3,
|
|
430
|
+
visibility: _getCircleVisibilityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).visibility,
|
|
431
|
+
transform: `translate(${xScaleBandwidthTranslate}, 0)`,
|
|
432
|
+
"data-is-focusable": _isLegendHighlighted(item),
|
|
433
|
+
ref: (e)=>circleRef.refElement = e,
|
|
434
|
+
onFocus: _lineFocus.bind(circlePoint, circleRef),
|
|
435
|
+
onBlur: _lineHoverOut,
|
|
436
|
+
tabIndex: circlePoint.legend !== '' ? 0 : undefined
|
|
437
|
+
}));
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, borderForLines, lines, dots);
|
|
441
|
+
}
|
|
442
|
+
function _getCircleVisibilityAndRadius(xAxisPoint, legend) {
|
|
443
|
+
if (!_noLegendHighlighted()) {
|
|
444
|
+
if (xAxisPoint === activeXAxisDataPoint && _isLegendHighlighted(legend)) {
|
|
445
|
+
return {
|
|
446
|
+
visibility: "visibility",
|
|
447
|
+
radius: 8
|
|
448
|
+
};
|
|
449
|
+
} else if (_isLegendHighlighted(legend)) {
|
|
450
|
+
return {
|
|
451
|
+
visibility: "visibility",
|
|
452
|
+
radius: 0.3
|
|
453
|
+
};
|
|
454
|
+
} else {
|
|
455
|
+
return {
|
|
456
|
+
visibility: "hidden",
|
|
457
|
+
radius: 0
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
} else {
|
|
461
|
+
return {
|
|
462
|
+
visibility: activeXAxisDataPoint === xAxisPoint ? "visibility" : "hidden",
|
|
463
|
+
radius: 8
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
function _renderCallout(props) {
|
|
468
|
+
var _props_culture;
|
|
469
|
+
return props ? /*#__PURE__*/ React.createElement(ChartPopover, {
|
|
470
|
+
culture: (_props_culture = props.culture) !== null && _props_culture !== void 0 ? _props_culture : 'en-us',
|
|
471
|
+
XValue: props.xAxisCalloutData,
|
|
472
|
+
xCalloutValue: xCalloutValue,
|
|
473
|
+
yCalloutValue: yCalloutValue,
|
|
474
|
+
clickPosition: clickPosition,
|
|
475
|
+
isPopoverOpen: isPopoverOpen,
|
|
476
|
+
legend: props.legend,
|
|
477
|
+
YValue: props.yAxisCalloutData,
|
|
478
|
+
color: props.color
|
|
479
|
+
}) : null;
|
|
480
|
+
}
|
|
481
|
+
function _onRectHover(xAxisPoint, point, color, mouseEvent) {
|
|
482
|
+
mouseEvent.persist();
|
|
483
|
+
_onRectFocusHover(xAxisPoint, point, color, mouseEvent);
|
|
484
|
+
}
|
|
485
|
+
function _onRectFocusHover(xAxisPoint, point, color, mouseEvent) {
|
|
486
|
+
let clientX = 0;
|
|
487
|
+
let clientY = 0;
|
|
488
|
+
if ('clientX' in mouseEvent) {
|
|
489
|
+
clientX = mouseEvent.clientX;
|
|
490
|
+
clientY = mouseEvent.clientY;
|
|
491
|
+
} else {
|
|
492
|
+
// Handle case where mouseEvent is an SVGGElement
|
|
493
|
+
const boundingRect = mouseEvent.getBoundingClientRect();
|
|
494
|
+
clientX = boundingRect.left + boundingRect.width / 2;
|
|
495
|
+
clientY = boundingRect.top + boundingRect.height / 2;
|
|
496
|
+
}
|
|
497
|
+
if ((_calloutAnchorPoint === null || _calloutAnchorPoint === void 0 ? void 0 : _calloutAnchorPoint.chartDataPoint) !== point || (_calloutAnchorPoint === null || _calloutAnchorPoint === void 0 ? void 0 : _calloutAnchorPoint.xAxisDataPoint) !== xAxisPoint) {
|
|
498
|
+
_calloutAnchorPoint = {
|
|
499
|
+
chartDataPoint: point,
|
|
500
|
+
xAxisDataPoint: `${xAxisPoint}`
|
|
501
|
+
};
|
|
502
|
+
_updatePosition(clientX, clientY);
|
|
503
|
+
setPopoverOpen(_noLegendHighlighted() || _isLegendHighlighted(point.legend));
|
|
504
|
+
setCalloutLegend(point.legend);
|
|
505
|
+
setDataForHoverCard(point.data);
|
|
506
|
+
setColor(color);
|
|
507
|
+
setXCalloutValue(point.xAxisCalloutData ? point.xAxisCalloutData : `${xAxisPoint}`);
|
|
508
|
+
setYCalloutValue(point.yAxisCalloutData);
|
|
509
|
+
setDataPointCalloutProps(point);
|
|
510
|
+
setCallOutAccessibilityData(point.callOutAccessibilityData);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
function _lineHover(lineData, mouseEvent) {
|
|
514
|
+
mouseEvent.persist();
|
|
515
|
+
_lineHoverFocus(lineData);
|
|
516
|
+
}
|
|
517
|
+
function _lineFocus(lineData, ref) {
|
|
518
|
+
if (ref.refElement) {
|
|
519
|
+
_lineHoverFocus(lineData);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
function _onStackHover(stack, mouseEvent) {
|
|
523
|
+
mouseEvent.persist();
|
|
524
|
+
_onStackHoverFocus(stack, mouseEvent);
|
|
525
|
+
}
|
|
526
|
+
function _onRectFocus(point, xAxisPoint, color, ref) {
|
|
527
|
+
if (ref.refElement) {
|
|
528
|
+
_onRectFocusHover(xAxisPoint, point, color, ref.refElement);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
function _onStackFocus(stack, groupRef) {
|
|
532
|
+
if (groupRef.refElement) {
|
|
533
|
+
_onStackHoverFocus(stack, groupRef.refElement);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function _handleMouseOut() {
|
|
537
|
+
setPopoverOpen(false);
|
|
538
|
+
}
|
|
539
|
+
function _getBarGapAndScale(bars, yBarScale, defaultTotalHeight) {
|
|
540
|
+
const { barGapMax = 0 } = props;
|
|
541
|
+
// When displaying gaps between the bars, the height of each bar is
|
|
542
|
+
// adjusted so that the total of all bars is not changed by the gaps
|
|
543
|
+
const totalData = bars.reduce((iter, value)=>iter + Math.abs(value.data), 0);
|
|
544
|
+
const totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : yBarScale(totalData);
|
|
545
|
+
let sumOfPercent = 0;
|
|
546
|
+
bars.forEach((point)=>{
|
|
547
|
+
let value = Math.abs(point.data) / totalData * 100;
|
|
548
|
+
if (value < 1 && value !== 0) {
|
|
549
|
+
value = 1;
|
|
550
|
+
}
|
|
551
|
+
sumOfPercent += value;
|
|
552
|
+
});
|
|
553
|
+
const scalingRatio = sumOfPercent !== 0 ? sumOfPercent / 100 : 1;
|
|
554
|
+
const gaps = barGapMax && bars.length - 1;
|
|
555
|
+
const gapHeight = gaps && Math.max(barGapMin, Math.min(barGapMax, totalHeight * barGapMultiplier / gaps));
|
|
556
|
+
const heightValueScale = (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
|
|
557
|
+
return {
|
|
558
|
+
gapHeight,
|
|
559
|
+
heightValueScale,
|
|
560
|
+
adjustedTotalHeight: sumOfPercent
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
function _getScales(containerHeight, containerWidth) {
|
|
564
|
+
const yMax = _yMax;
|
|
565
|
+
const yBarScale = d3ScaleLinear().domain([
|
|
566
|
+
0,
|
|
567
|
+
yMax
|
|
568
|
+
]).range([
|
|
569
|
+
0,
|
|
570
|
+
containerHeight - _margins.bottom - _margins.top
|
|
571
|
+
]);
|
|
572
|
+
if (_xAxisType === XAxisTypes.NumericAxis) {
|
|
573
|
+
const xMax = d3Max(_dataset, (point)=>point.x);
|
|
574
|
+
const xMin = d3Min(_dataset, (point)=>point.x);
|
|
575
|
+
const xBarScale = d3ScaleLinear().domain(_isRtl ? [
|
|
576
|
+
xMax,
|
|
577
|
+
xMin
|
|
578
|
+
] : [
|
|
579
|
+
xMin,
|
|
580
|
+
xMax
|
|
581
|
+
]).nice().range([
|
|
582
|
+
_margins.left + _domainMargin,
|
|
583
|
+
containerWidth - _margins.right - _domainMargin
|
|
584
|
+
]);
|
|
585
|
+
return {
|
|
586
|
+
xBarScale,
|
|
587
|
+
yBarScale
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
if (_xAxisType === XAxisTypes.DateAxis) {
|
|
591
|
+
const sDate = d3Min(_dataset, (point)=>{
|
|
592
|
+
return point.x;
|
|
593
|
+
});
|
|
594
|
+
const lDate = d3Max(_dataset, (point)=>{
|
|
595
|
+
return point.x;
|
|
596
|
+
});
|
|
597
|
+
const xBarScale = props.useUTC ? d3ScaleUtc() : d3ScaleTime();
|
|
598
|
+
xBarScale.domain(_isRtl ? [
|
|
599
|
+
lDate,
|
|
600
|
+
sDate
|
|
601
|
+
] : [
|
|
602
|
+
sDate,
|
|
603
|
+
lDate
|
|
604
|
+
]).range([
|
|
605
|
+
_margins.left + _domainMargin,
|
|
606
|
+
containerWidth - _margins.right - _domainMargin
|
|
607
|
+
]);
|
|
608
|
+
return {
|
|
609
|
+
xBarScale,
|
|
610
|
+
yBarScale
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
const xBarScale = d3ScaleBand().domain(_xAxisLabels).range(_isRtl ? [
|
|
614
|
+
containerWidth - _margins.right - _domainMargin,
|
|
615
|
+
_margins.left + _domainMargin
|
|
616
|
+
] : [
|
|
617
|
+
_margins.left + _domainMargin,
|
|
618
|
+
containerWidth - _margins.right - _domainMargin
|
|
619
|
+
]).paddingInner(_xAxisInnerPadding).paddingOuter(_xAxisOuterPadding);
|
|
620
|
+
return {
|
|
621
|
+
xBarScale,
|
|
622
|
+
yBarScale
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
const _isChartEmpty = ()=>{
|
|
626
|
+
return !(props.data && props.data.length > 0 && props.data.some((item)=>item.chartData.length > 0 || item.lineData && item.lineData.length > 0));
|
|
627
|
+
};
|
|
628
|
+
function _updatePosition(newX, newY) {
|
|
629
|
+
const threshold = 1; // Set a threshold for movement
|
|
630
|
+
const { x, y } = clickPosition;
|
|
631
|
+
// Calculate the distance moved
|
|
632
|
+
const distance = Math.sqrt(Math.pow(newX - x, 2) + Math.pow(newY - y, 2));
|
|
633
|
+
// Update the position only if the distance moved is greater than the threshold
|
|
634
|
+
if (distance > threshold) {
|
|
635
|
+
setClickPosition({
|
|
636
|
+
x: newX,
|
|
637
|
+
y: newY
|
|
638
|
+
});
|
|
639
|
+
setPopoverOpen(true);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
function _getDomainMargins(containerWidth) {
|
|
643
|
+
_domainMargin = MIN_DOMAIN_MARGIN;
|
|
644
|
+
/** Total width available to render the bars */ const totalWidth = containerWidth - (_margins.left + MIN_DOMAIN_MARGIN) - (_margins.right + MIN_DOMAIN_MARGIN);
|
|
645
|
+
/** Rate at which the space between the bars changes wrt the bar width */ const barGapRate = _xAxisInnerPadding / (1 - _xAxisInnerPadding);
|
|
646
|
+
if (_xAxisType === XAxisTypes.StringAxis) {
|
|
647
|
+
if (isScalePaddingDefined(props.xAxisOuterPadding, props.xAxisPadding)) {
|
|
648
|
+
// Setting the domain margin for string x-axis to 0 because the xAxisOuterPadding prop is now available
|
|
649
|
+
// to adjust the space before the first bar and after the last bar.
|
|
650
|
+
_domainMargin = 0;
|
|
651
|
+
} else if (props.barWidth !== 'auto') {
|
|
652
|
+
// Update the bar width so that when CartesianChart rerenders,
|
|
653
|
+
// the following calculations don't use the previous bar width.
|
|
654
|
+
_barWidth = getBarWidth(props.barWidth, props.maxBarWidth);
|
|
655
|
+
/** Total width required to render the bars. Directly proportional to bar width */ const reqWidth = (_xAxisLabels.length + (_xAxisLabels.length - 1) * barGapRate) * _barWidth;
|
|
656
|
+
if (totalWidth >= reqWidth) {
|
|
657
|
+
// Center align the chart by setting equal left and right margins for domain
|
|
658
|
+
_domainMargin = MIN_DOMAIN_MARGIN + (totalWidth - reqWidth) / 2;
|
|
659
|
+
}
|
|
660
|
+
} else if (props.mode === 'plotly' && _xAxisLabels.length > 1) {
|
|
661
|
+
// Calculate the remaining width after rendering bars at their maximum allowable width
|
|
662
|
+
const bandwidth = totalWidth / (_xAxisLabels.length + (_xAxisLabels.length - 1) * barGapRate);
|
|
663
|
+
const barWidth = getBarWidth(props.barWidth, props.maxBarWidth, bandwidth);
|
|
664
|
+
let reqWidth = (_xAxisLabels.length + (_xAxisLabels.length - 1) * barGapRate) * barWidth;
|
|
665
|
+
const margin1 = (totalWidth - reqWidth) / 2;
|
|
666
|
+
// Calculate the remaining width after accounting for the space required to render x-axis labels
|
|
667
|
+
const step = calculateLongestLabelWidth(_xAxisLabels) + 20;
|
|
668
|
+
reqWidth = (_xAxisLabels.length - _xAxisInnerPadding) * step;
|
|
669
|
+
const margin2 = (totalWidth - reqWidth) / 2;
|
|
670
|
+
_domainMargin = MIN_DOMAIN_MARGIN + Math.max(0, Math.min(margin1, margin2));
|
|
671
|
+
}
|
|
672
|
+
} else {
|
|
673
|
+
var _props_data;
|
|
674
|
+
const data = ((_props_data = props.data) === null || _props_data === void 0 ? void 0 : _props_data.map((point)=>point.xAxisPoint)) || [];
|
|
675
|
+
_barWidth = getBarWidth(props.barWidth, props.maxBarWidth, calculateAppropriateBarWidth(data, totalWidth));
|
|
676
|
+
_domainMargin = MIN_DOMAIN_MARGIN + _barWidth / 2;
|
|
677
|
+
}
|
|
678
|
+
return {
|
|
679
|
+
..._margins,
|
|
680
|
+
left: _margins.left + _domainMargin,
|
|
681
|
+
right: _margins.right + _domainMargin
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
function _getChartTitle() {
|
|
685
|
+
const { chartTitle, data } = props;
|
|
686
|
+
const numLines = Object.keys(_lineObject).length;
|
|
687
|
+
return (chartTitle ? `${chartTitle}. ` : '') + `Vertical bar chart with ${(data === null || data === void 0 ? void 0 : data.length) || 0} stacked bars` + (numLines > 0 ? ` and ${numLines} lines` : '') + '. ';
|
|
688
|
+
}
|
|
689
|
+
const classes = useVerticalStackedBarChartStyles(props);
|
|
690
|
+
function _createBar(xBarScale, yBarScale, containerHeight, xElement) {
|
|
691
|
+
const { barCornerRadius = 0, barMinimumHeight = 0 } = props;
|
|
692
|
+
const _isHavingLines = props.data.some((item)=>item.lineData && item.lineData.length > 0);
|
|
693
|
+
const shouldFocusWholeStack = _toFocusWholeStack(_isHavingLines);
|
|
694
|
+
if (_xAxisType === XAxisTypes.StringAxis) {
|
|
695
|
+
_barWidth = getBarWidth(props.barWidth, props.maxBarWidth, xBarScale.bandwidth());
|
|
696
|
+
}
|
|
697
|
+
const bars = _points.map((singleChartData, indexNumber)=>{
|
|
698
|
+
let yPoint = containerHeight - _margins.bottom;
|
|
699
|
+
const xPoint = xBarScale(_xAxisType === XAxisTypes.NumericAxis ? singleChartData.xAxisPoint : _xAxisType === XAxisTypes.DateAxis ? singleChartData.xAxisPoint : singleChartData.xAxisPoint);
|
|
700
|
+
const xScaleBandwidthTranslate = _xAxisType !== XAxisTypes.StringAxis ? -_barWidth / 2 : (xBarScale.bandwidth() - _barWidth) / 2;
|
|
701
|
+
let barTotalValue = 0;
|
|
702
|
+
const barsToDisplay = singleChartData.chartData.filter((point)=>point.data > 0);
|
|
703
|
+
if (!barsToDisplay.length) {
|
|
704
|
+
return undefined;
|
|
705
|
+
}
|
|
706
|
+
const { gapHeight, heightValueScale, adjustedTotalHeight } = _getBarGapAndScale(barsToDisplay, yBarScale);
|
|
707
|
+
if (heightValueScale < 0) {
|
|
708
|
+
return undefined;
|
|
709
|
+
}
|
|
710
|
+
const singleBar = barsToDisplay.map((point, index)=>{
|
|
711
|
+
const startColor = point.color ? point.color : _colors[index];
|
|
712
|
+
const ref = {};
|
|
713
|
+
const shouldHighlight = _isLegendHighlighted(point.legend) || _noLegendHighlighted() ? true : false;
|
|
714
|
+
const rectFocusProps = !shouldFocusWholeStack && {
|
|
715
|
+
'data-is-focusable': !props.hideTooltip && shouldHighlight,
|
|
716
|
+
'aria-label': _getAriaLabel(singleChartData, point),
|
|
717
|
+
onMouseOver: (event)=>_onRectHover(singleChartData.xAxisPoint, point, startColor, event),
|
|
718
|
+
onMouseMove: (event)=>_onRectHover(singleChartData.xAxisPoint, point, startColor, event),
|
|
719
|
+
onMouseLeave: _handleMouseOut,
|
|
720
|
+
onFocus: ()=>_onRectFocus(point, singleChartData.xAxisPoint, startColor, ref),
|
|
721
|
+
onBlur: _handleMouseOut,
|
|
722
|
+
onClick: (event)=>_onClick(point, event),
|
|
723
|
+
role: 'img'
|
|
724
|
+
};
|
|
725
|
+
let barHeight = heightValueScale * point.data;
|
|
726
|
+
if (barHeight < Math.max(heightValueScale * adjustedTotalHeight / 100.0, barMinimumHeight)) {
|
|
727
|
+
barHeight = Math.max(heightValueScale * adjustedTotalHeight / 100.0, barMinimumHeight);
|
|
728
|
+
}
|
|
729
|
+
yPoint = yPoint - barHeight - (index ? gapHeight : 0);
|
|
730
|
+
barTotalValue += point.data;
|
|
731
|
+
if (barCornerRadius && barHeight > barCornerRadius && index === barsToDisplay.length - 1) {
|
|
732
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, {
|
|
733
|
+
key: index + indexNumber + `${shouldFocusWholeStack}`
|
|
734
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
735
|
+
className: classes.opacityChangeOnHover,
|
|
736
|
+
d: `
|
|
737
|
+
M ${xPoint} ${yPoint + barCornerRadius}
|
|
738
|
+
a ${barCornerRadius} ${barCornerRadius} 0 0 1 ${barCornerRadius} ${-barCornerRadius}
|
|
739
|
+
h ${_barWidth - 2 * barCornerRadius}
|
|
740
|
+
a ${barCornerRadius} ${barCornerRadius} 0 0 1 ${barCornerRadius} ${barCornerRadius}
|
|
741
|
+
v ${barHeight - barCornerRadius}
|
|
742
|
+
h ${-_barWidth}
|
|
743
|
+
z
|
|
744
|
+
`,
|
|
745
|
+
fill: startColor,
|
|
746
|
+
rx: props.roundCorners ? 3 : 0,
|
|
747
|
+
ref: (e)=>ref.refElement = e,
|
|
748
|
+
transform: `translate(${xScaleBandwidthTranslate}, 0)`,
|
|
749
|
+
cursor: props.href ? 'pointer' : 'default',
|
|
750
|
+
...rectFocusProps
|
|
751
|
+
}));
|
|
752
|
+
}
|
|
753
|
+
if (barHeight < 0) {
|
|
754
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, {
|
|
755
|
+
key: index + indexNumber
|
|
756
|
+
}, " ");
|
|
757
|
+
}
|
|
758
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, {
|
|
759
|
+
key: index + indexNumber
|
|
760
|
+
}, /*#__PURE__*/ React.createElement("rect", {
|
|
761
|
+
className: classes.opacityChangeOnHover,
|
|
762
|
+
x: xPoint,
|
|
763
|
+
y: yPoint,
|
|
764
|
+
width: _barWidth,
|
|
765
|
+
height: barHeight,
|
|
766
|
+
fill: startColor,
|
|
767
|
+
opacity: shouldHighlight ? 1 : 0.1,
|
|
768
|
+
cursor: props.href ? 'pointer' : 'default',
|
|
769
|
+
rx: props.roundCorners ? 3 : 0,
|
|
770
|
+
ref: (e)=>ref.refElement = e,
|
|
771
|
+
...rectFocusProps,
|
|
772
|
+
transform: `translate(${xScaleBandwidthTranslate}, 0)`
|
|
773
|
+
}));
|
|
774
|
+
});
|
|
775
|
+
const groupRef = {};
|
|
776
|
+
const stackFocusProps = shouldFocusWholeStack && {
|
|
777
|
+
'data-is-focusable': !props.hideTooltip,
|
|
778
|
+
'aria-label': _getAriaLabel(singleChartData),
|
|
779
|
+
onMouseOver: (event)=>_onStackHover(singleChartData, event),
|
|
780
|
+
onMouseMove: (event)=>_onStackHover(singleChartData, event),
|
|
781
|
+
onMouseLeave: _handleMouseOut,
|
|
782
|
+
onFocus: ()=>_onStackFocus(singleChartData, groupRef),
|
|
783
|
+
onBlur: _handleMouseOut,
|
|
784
|
+
onClick: (event)=>_onClick(singleChartData, event),
|
|
785
|
+
role: 'img'
|
|
786
|
+
};
|
|
787
|
+
let showLabel = false;
|
|
788
|
+
let barLabel = 0;
|
|
789
|
+
if (!props.hideLabels) {
|
|
790
|
+
if (_noLegendHighlighted()) {
|
|
791
|
+
showLabel = true;
|
|
792
|
+
barLabel = barTotalValue;
|
|
793
|
+
} else {
|
|
794
|
+
barsToDisplay.forEach((point)=>{
|
|
795
|
+
if (_isLegendHighlighted(point.legend)) {
|
|
796
|
+
showLabel = true;
|
|
797
|
+
barLabel += point.data;
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
return /*#__PURE__*/ React.createElement("g", {
|
|
803
|
+
key: indexNumber + `${shouldFocusWholeStack}`
|
|
804
|
+
}, /*#__PURE__*/ React.createElement("g", {
|
|
805
|
+
id: `${indexNumber}-singleBar`,
|
|
806
|
+
ref: (e)=>groupRef.refElement = e,
|
|
807
|
+
...stackFocusProps,
|
|
808
|
+
tabIndex: !props.hideTooltip ? 0 : undefined
|
|
809
|
+
}, singleBar), !props.hideLabels && _barWidth >= 16 && showLabel && /*#__PURE__*/ React.createElement("text", {
|
|
810
|
+
x: xPoint + _barWidth / 2,
|
|
811
|
+
y: yPoint - 6,
|
|
812
|
+
textAnchor: "middle",
|
|
813
|
+
className: classes.barLabel,
|
|
814
|
+
"aria-label": `Total: ${barLabel}`,
|
|
815
|
+
role: "img",
|
|
816
|
+
transform: `translate(${xScaleBandwidthTranslate}, 0)`
|
|
817
|
+
}, formatValueWithSIPrefix(barLabel)));
|
|
818
|
+
});
|
|
819
|
+
if (!props.showXAxisLablesTooltip) {
|
|
820
|
+
try {
|
|
821
|
+
document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
|
|
822
|
+
// eslint-disable-next-line no-empty
|
|
823
|
+
} catch (e) {}
|
|
824
|
+
}
|
|
825
|
+
if (!props.wrapXAxisLables && props.showXAxisLablesTooltip) {
|
|
826
|
+
const xAxisElement = d3Select(xElement).call(xBarScale);
|
|
827
|
+
try {
|
|
828
|
+
document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
|
|
829
|
+
// eslint-disable-next-line no-empty
|
|
830
|
+
} catch (e) {}
|
|
831
|
+
const tooltipProps = {
|
|
832
|
+
tooltipCls: classes.tooltip,
|
|
833
|
+
id: _tooltipId,
|
|
834
|
+
xAxis: xAxisElement
|
|
835
|
+
};
|
|
836
|
+
xAxisElement && tooltipOfXAxislabels(tooltipProps);
|
|
837
|
+
}
|
|
838
|
+
return bars.filter((bar)=>!!bar);
|
|
839
|
+
}
|
|
840
|
+
if (!_isChartEmpty()) {
|
|
841
|
+
_adjustProps();
|
|
842
|
+
const _isHavingLines = props.data.some((item)=>item.lineData && item.lineData.length > 0);
|
|
843
|
+
const shouldFocusWholeStack = _toFocusWholeStack(_isHavingLines);
|
|
844
|
+
_dataset = _createDataSetLayer();
|
|
845
|
+
const legendBars = _getLegendData(_points, _createLegendsForLine(props.data));
|
|
846
|
+
const calloutProps = {
|
|
847
|
+
color: color,
|
|
848
|
+
legend: calloutLegend,
|
|
849
|
+
XValue: xCalloutValue,
|
|
850
|
+
YValue: yCalloutValue ? yCalloutValue : dataForHoverCard,
|
|
851
|
+
YValueHover: YValueHover,
|
|
852
|
+
hoverXValue: hoverXValue,
|
|
853
|
+
...props.calloutProps,
|
|
854
|
+
...getAccessibleDataObject(callOutAccessibilityData),
|
|
855
|
+
clickPosition: clickPosition,
|
|
856
|
+
isPopoverOpen: isPopoverOpen,
|
|
857
|
+
isCalloutForStack: props.isCalloutForStack || _isHavingLines && _noLegendHighlighted(),
|
|
858
|
+
isCartesian: true,
|
|
859
|
+
customCallout: {
|
|
860
|
+
customizedCallout: _getCustomizedCallout() !== null ? _getCustomizedCallout() : undefined,
|
|
861
|
+
customCalloutProps: props.calloutPropsPerDataPoint ? props.calloutPropsPerDataPoint(dataPointCalloutProps) : undefined
|
|
862
|
+
}
|
|
863
|
+
};
|
|
864
|
+
const tickParams = {
|
|
865
|
+
tickValues: props.tickValues,
|
|
866
|
+
tickFormat: props.tickFormat
|
|
867
|
+
};
|
|
868
|
+
return /*#__PURE__*/ React.createElement(CartesianChart, {
|
|
869
|
+
...props,
|
|
870
|
+
chartTitle: _getChartTitle(),
|
|
871
|
+
points: _dataset,
|
|
872
|
+
chartType: ChartTypes.VerticalStackedBarChart,
|
|
873
|
+
xAxisType: _xAxisType,
|
|
874
|
+
calloutProps: calloutProps,
|
|
875
|
+
tickParams: tickParams,
|
|
876
|
+
legendBars: legendBars,
|
|
877
|
+
datasetForXAxisDomain: _xAxisLabels,
|
|
878
|
+
isCalloutForStack: shouldFocusWholeStack,
|
|
879
|
+
barwidth: _barWidth,
|
|
880
|
+
getmargins: _getMargins,
|
|
881
|
+
getGraphData: _getGraphData,
|
|
882
|
+
getAxisData: _getAxisData,
|
|
883
|
+
onChartMouseLeave: _handleChartMouseLeave,
|
|
884
|
+
getDomainMargins: _getDomainMargins,
|
|
885
|
+
..._xAxisType === XAxisTypes.StringAxis && {
|
|
886
|
+
xAxisInnerPadding: _xAxisInnerPadding,
|
|
887
|
+
xAxisOuterPadding: _xAxisOuterPadding
|
|
888
|
+
},
|
|
889
|
+
componentRef: cartesianChartRef,
|
|
890
|
+
/* eslint-disable react/jsx-no-bind */ children: (props)=>{
|
|
891
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("g", null, _bars), /*#__PURE__*/ React.createElement("g", null, _isHavingLines && _createLines(props.xScale, props.yScale, props.containerHeight, props.containerWidth, props.yScaleSecondary)));
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
896
|
+
id: _emptyChartId,
|
|
897
|
+
role: 'alert',
|
|
898
|
+
style: {
|
|
899
|
+
opacity: '0'
|
|
900
|
+
},
|
|
901
|
+
"aria-label": 'Graph has no data to display'
|
|
902
|
+
});
|
|
903
|
+
};
|
|
904
|
+
VerticalStackedBarChart.displayName = 'VerticalStackedBarChart';
|