@fluentui/react-charts 9.3.2 → 9.3.4
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 +47 -2
- package/dist/index.d.ts +151 -1
- package/lib/components/AreaChart/AreaChart.js +208 -60
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +14 -12
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.js +3 -3
- package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +2 -2
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +5 -6
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.js +2 -1
- package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +3 -2
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +2 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +3 -2
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js +2 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +16 -7
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +63 -18
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +471 -207
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.js +8 -7
- package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +16 -32
- 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 -4
- package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.js +3 -2
- package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +2 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js +23 -45
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js +3 -2
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js +2 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +21 -46
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +3 -2
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js +2 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +332 -114
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +3 -2
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +2 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/Legends/Legends.js +1 -1
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +145 -97
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +3 -2
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +7 -11
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/types/DataPoint.js +1 -3
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/utilities.js +77 -26
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +207 -59
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +13 -12
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +3 -3
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +2 -2
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +5 -6
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.js +2 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +7 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +7 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +16 -7
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +65 -18
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +470 -206
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js +8 -7
- package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +16 -32
- 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 -4
- package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +7 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js +23 -45
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js +7 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +21 -46
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +7 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +329 -112
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +7 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js +1 -1
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +144 -96
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +7 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +6 -10
- package/lib-commonjs/components/ScatterChart/ScatterChart.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/utilities.js +80 -26
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +13 -13
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useGroupedVerticalBarChartStyles_unstable } from './useGroupedVerticalBarChartStyles.styles';
|
|
4
|
-
import { select as d3Select } from 'd3-selection';
|
|
4
|
+
import { select as d3Select, pointer as d3Pointer } from 'd3-selection';
|
|
5
5
|
import { max as d3Max, min as d3Min } from 'd3-array';
|
|
6
6
|
import { scaleBand as d3ScaleBand } from 'd3-scale';
|
|
7
7
|
import { useId } from '@fluentui/react-utilities';
|
|
8
8
|
import { ChartTypes, getAccessibleDataObject, tooltipOfAxislabels, XAxisTypes, getTypeOfAxis, formatScientificLimitWidth, getScalePadding, getBarWidth, isScalePaddingDefined, createNumericYAxis, domainRangeOfXStringAxis, createStringYAxis, getNextColor, areArraysEqual, calculateLongestLabelWidth, useRtl, calcRequiredWidth, calcTotalWidth, calcBandwidth, calcTotalBandUnits, sortAxisCategories } from '../../utilities/index';
|
|
9
|
-
import { CartesianChart, Legends } from '../../index';
|
|
9
|
+
import { CartesianChart, Legends, getColorFromToken } from '../../index';
|
|
10
10
|
import { toImage } from '../../utilities/image-export-utils';
|
|
11
|
+
import { tokens } from '@fluentui/react-theme';
|
|
11
12
|
const MIN_DOMAIN_MARGIN = 8;
|
|
12
13
|
const X1_INNER_PADDING = 0.1;
|
|
13
14
|
const VERTICAL_BAR_GAP = 1;
|
|
@@ -38,26 +39,27 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
38
39
|
let _groupWidth = 0;
|
|
39
40
|
let _xAxisInnerPadding = 0;
|
|
40
41
|
let _xAxisOuterPadding = 0;
|
|
41
|
-
let
|
|
42
|
+
let _barLegends = [];
|
|
43
|
+
let _lineLegends = [];
|
|
42
44
|
let _legendColorMap = {};
|
|
43
45
|
const cartesianChartRef = React.useRef(null);
|
|
44
46
|
const Y_ORIGIN = 0;
|
|
45
47
|
const _legendsRef = React.useRef(null);
|
|
48
|
+
const _rectRef = React.useRef(null);
|
|
49
|
+
const _uniqDotId = useId('gvbc_dot_');
|
|
46
50
|
const [color, setColor] = React.useState('');
|
|
47
51
|
const [dataForHoverCard, setDataForHoverCard] = React.useState(0);
|
|
48
52
|
const [selectedLegends, setSelectedLegends] = React.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
|
|
49
53
|
const [xCalloutValue, setXCalloutValue] = React.useState('');
|
|
50
54
|
const [yCalloutValue, setYCalloutValue] = React.useState('');
|
|
51
|
-
const [
|
|
55
|
+
const [yValueHover, setYValueHover] = React.useState([]);
|
|
52
56
|
const [hoverXValue, setHoverXValue] = React.useState('');
|
|
53
57
|
const [calloutLegend, setCalloutLegend] = React.useState('');
|
|
54
58
|
const [activeLegend, setActiveLegend] = React.useState('');
|
|
55
59
|
const [callOutAccessibilityData, setCallOutAccessibilityData] = React.useState(undefined);
|
|
56
|
-
const [
|
|
57
|
-
x: 0,
|
|
58
|
-
y: 0
|
|
59
|
-
});
|
|
60
|
+
const [popoverTarget, setPopoverTarget] = React.useState(null);
|
|
60
61
|
const [isPopoverOpen, setPopoverOpen] = React.useState(false);
|
|
62
|
+
const [activeLinePoint, setActiveLinePoint] = React.useState('');
|
|
61
63
|
const classes = useGroupedVerticalBarChartStyles_unstable(props);
|
|
62
64
|
React.useEffect(()=>{
|
|
63
65
|
var _props_legendProps;
|
|
@@ -83,14 +85,30 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
83
85
|
_barWidth = getBarWidth(props.barWidth, props.maxBarWidth);
|
|
84
86
|
// x0_inner_padding = space_between_groups / (space_between_groups + group_width)
|
|
85
87
|
// space_between_groups = 2 * bar_width
|
|
86
|
-
// group_width =
|
|
87
|
-
_xAxisInnerPadding = getScalePadding(props.xAxisInnerPadding, undefined, 2 / (2 + calcTotalBandUnits(
|
|
88
|
+
// group_width = _barLegends.length * bar_width + (_barLegends.length - 1) * space_between_bars
|
|
89
|
+
_xAxisInnerPadding = getScalePadding(props.xAxisInnerPadding, undefined, 2 / (2 + calcTotalBandUnits(_barLegends.length, X1_INNER_PADDING)));
|
|
88
90
|
_xAxisOuterPadding = getScalePadding(props.xAxisOuterPadding);
|
|
89
91
|
};
|
|
90
|
-
const _createDataset = (
|
|
92
|
+
const _createDataset = (barData, lineData)=>{
|
|
91
93
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
94
|
const datasetForBars = [];
|
|
93
|
-
|
|
95
|
+
const linePointsByX = {};
|
|
96
|
+
const visitedX = new Set();
|
|
97
|
+
lineData.forEach((series)=>{
|
|
98
|
+
series.data.forEach((point)=>{
|
|
99
|
+
if (!linePointsByX[point.x]) {
|
|
100
|
+
linePointsByX[point.x] = [];
|
|
101
|
+
}
|
|
102
|
+
linePointsByX[point.x].push({
|
|
103
|
+
...point,
|
|
104
|
+
legend: series.legend,
|
|
105
|
+
color: series.color,
|
|
106
|
+
data: point.y,
|
|
107
|
+
useSecondaryYScale: series.useSecondaryYScale
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
barData.forEach((point, index)=>{
|
|
94
112
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
113
|
const singleDatasetPointForBars = {};
|
|
96
114
|
const legendToBarPoint = {};
|
|
@@ -113,23 +131,38 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
113
131
|
});
|
|
114
132
|
singleDatasetPointForBars.xAxisPoint = point.name;
|
|
115
133
|
singleDatasetPointForBars.indexNum = index;
|
|
116
|
-
|
|
134
|
+
var _linePointsByX_point_name;
|
|
135
|
+
singleDatasetPointForBars.groupSeries = [
|
|
136
|
+
...Object.values(legendToBarPoint),
|
|
137
|
+
...(_linePointsByX_point_name = linePointsByX[point.name]) !== null && _linePointsByX_point_name !== void 0 ? _linePointsByX_point_name : []
|
|
138
|
+
];
|
|
117
139
|
singleDatasetPointForBars.stackCallOutAccessibilityData = point.stackCallOutAccessibilityData;
|
|
118
140
|
datasetForBars.push(singleDatasetPointForBars);
|
|
141
|
+
visitedX.add(point.name);
|
|
142
|
+
});
|
|
143
|
+
Object.keys(linePointsByX).forEach((xPoint)=>{
|
|
144
|
+
if (!visitedX.has(xPoint)) {
|
|
145
|
+
datasetForBars.push({
|
|
146
|
+
xAxisPoint: xPoint,
|
|
147
|
+
groupSeries: linePointsByX[xPoint]
|
|
148
|
+
});
|
|
149
|
+
}
|
|
119
150
|
});
|
|
120
151
|
return datasetForBars;
|
|
121
152
|
};
|
|
122
|
-
const _createDataSetOfGVBC = (
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
points.forEach((point)=>{
|
|
153
|
+
const _createDataSetOfGVBC = (barData, lineData)=>{
|
|
154
|
+
const barLegends = new Set();
|
|
155
|
+
barData.forEach((point)=>{
|
|
126
156
|
point.series.forEach((seriesPoint)=>{
|
|
127
|
-
|
|
157
|
+
barLegends.add(seriesPoint.legend);
|
|
128
158
|
});
|
|
129
159
|
});
|
|
130
|
-
const
|
|
160
|
+
const lineLegends = new Set(lineData.map((series)=>series.legend));
|
|
161
|
+
const xAxisLabels = _getOrderedXAxisLabels(barData, lineData);
|
|
162
|
+
const datasetForBars = _createDataset(barData, lineData);
|
|
131
163
|
return {
|
|
132
|
-
|
|
164
|
+
barLegends: Array.from(barLegends),
|
|
165
|
+
lineLegends: Array.from(lineLegends),
|
|
133
166
|
xAxisLabels,
|
|
134
167
|
datasetForBars
|
|
135
168
|
};
|
|
@@ -146,12 +179,13 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
146
179
|
}
|
|
147
180
|
};
|
|
148
181
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
149
|
-
const _getLegendData = (
|
|
182
|
+
const _getLegendData = ()=>{
|
|
150
183
|
const actions = [];
|
|
151
|
-
|
|
184
|
+
const addLegendButton = (legendTitle, isLineLegendInBarChart)=>{
|
|
152
185
|
const legend = {
|
|
153
186
|
title: legendTitle,
|
|
154
187
|
color: _legendColorMap[legendTitle][0],
|
|
188
|
+
isLineLegendInBarChart,
|
|
155
189
|
hoverAction: ()=>{
|
|
156
190
|
_handleChartMouseLeave();
|
|
157
191
|
_onLegendHover(legendTitle);
|
|
@@ -161,7 +195,9 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
161
195
|
}
|
|
162
196
|
};
|
|
163
197
|
actions.push(legend);
|
|
164
|
-
}
|
|
198
|
+
};
|
|
199
|
+
_lineLegends.forEach((legendTitle)=>addLegendButton(legendTitle, true));
|
|
200
|
+
_barLegends.forEach((legendTitle)=>addLegendButton(legendTitle));
|
|
165
201
|
return /*#__PURE__*/ React.createElement(Legends, {
|
|
166
202
|
legends: actions,
|
|
167
203
|
enabledWrapLines: props.enabledLegendsWrapLines,
|
|
@@ -171,44 +207,104 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
171
207
|
legendRef: _legendsRef
|
|
172
208
|
});
|
|
173
209
|
};
|
|
174
|
-
const
|
|
210
|
+
const _processDataV2 = (dataV2)=>{
|
|
211
|
+
const barPointsByX = {};
|
|
212
|
+
const lineData = [];
|
|
213
|
+
dataV2.forEach((series)=>{
|
|
214
|
+
if (series.type === 'bar') {
|
|
215
|
+
series.data.forEach((point)=>{
|
|
216
|
+
if (!barPointsByX[point.x]) {
|
|
217
|
+
barPointsByX[point.x] = {
|
|
218
|
+
name: point.x,
|
|
219
|
+
series: []
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
var _series_key, _point_color;
|
|
223
|
+
barPointsByX[point.x].series.push({
|
|
224
|
+
key: (_series_key = series.key) !== null && _series_key !== void 0 ? _series_key : series.legend,
|
|
225
|
+
data: point.y,
|
|
226
|
+
color: (_point_color = point.color) !== null && _point_color !== void 0 ? _point_color : series.color,
|
|
227
|
+
// gradient: series.gradient,
|
|
228
|
+
legend: series.legend,
|
|
229
|
+
xAxisCalloutData: point.xAxisCalloutData,
|
|
230
|
+
yAxisCalloutData: point.yAxisCalloutData,
|
|
231
|
+
onClick: point.onClick,
|
|
232
|
+
useSecondaryYScale: series.useSecondaryYScale
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
} else if (series.type === 'line') {
|
|
236
|
+
lineData.push(series);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
return {
|
|
240
|
+
barData: Object.values(barPointsByX),
|
|
241
|
+
lineData
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
const _prepareChartData = ()=>{
|
|
245
|
+
let barData = props.data;
|
|
246
|
+
let lineData;
|
|
247
|
+
if (Array.isArray(props.dataV2) && props.dataV2.length > 0) {
|
|
248
|
+
({ barData, lineData } = _processDataV2(props.dataV2));
|
|
249
|
+
}
|
|
175
250
|
_legendColorMap = {};
|
|
176
251
|
let colorIndex = 0;
|
|
177
|
-
var
|
|
178
|
-
return
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
_legendColorMap[seriesPoint.legend]
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
252
|
+
var _barData_map, _lineData_map;
|
|
253
|
+
return {
|
|
254
|
+
barData: (_barData_map = barData === null || barData === void 0 ? void 0 : barData.map((point)=>{
|
|
255
|
+
var _point_series;
|
|
256
|
+
var _point_series_map;
|
|
257
|
+
return {
|
|
258
|
+
...point,
|
|
259
|
+
series: (_point_series_map = (_point_series = point.series) === null || _point_series === void 0 ? void 0 : _point_series.map((seriesPoint)=>{
|
|
260
|
+
// TODO: Add support for gradient colors
|
|
261
|
+
let startColor = seriesPoint.color ? seriesPoint.color : getNextColor(colorIndex, 0);
|
|
262
|
+
let endColor = startColor;
|
|
263
|
+
if (!_legendColorMap[seriesPoint.legend]) {
|
|
264
|
+
_legendColorMap[seriesPoint.legend] = [
|
|
265
|
+
startColor,
|
|
266
|
+
endColor
|
|
267
|
+
];
|
|
268
|
+
}
|
|
269
|
+
colorIndex += 1;
|
|
270
|
+
var _seriesPoint_color;
|
|
271
|
+
return {
|
|
272
|
+
...seriesPoint,
|
|
273
|
+
color: (_seriesPoint_color = seriesPoint.color) !== null && _seriesPoint_color !== void 0 ? _seriesPoint_color : _legendColorMap[seriesPoint.legend][0]
|
|
274
|
+
};
|
|
275
|
+
})) !== null && _point_series_map !== void 0 ? _point_series_map : []
|
|
276
|
+
};
|
|
277
|
+
})) !== null && _barData_map !== void 0 ? _barData_map : [],
|
|
278
|
+
lineData: (_lineData_map = lineData === null || lineData === void 0 ? void 0 : lineData.map((series)=>{
|
|
279
|
+
let lineColor;
|
|
280
|
+
if (typeof series.color === 'undefined') {
|
|
281
|
+
lineColor = getNextColor(colorIndex, 0);
|
|
282
|
+
} else {
|
|
283
|
+
lineColor = getColorFromToken(series.color);
|
|
284
|
+
}
|
|
285
|
+
if (!_legendColorMap[series.legend]) {
|
|
286
|
+
_legendColorMap[series.legend] = [
|
|
287
|
+
lineColor,
|
|
288
|
+
lineColor
|
|
289
|
+
];
|
|
290
|
+
}
|
|
291
|
+
colorIndex += 1;
|
|
292
|
+
return {
|
|
293
|
+
...series,
|
|
294
|
+
color: _legendColorMap[series.legend][0]
|
|
295
|
+
};
|
|
296
|
+
})) !== null && _lineData_map !== void 0 ? _lineData_map : []
|
|
297
|
+
};
|
|
202
298
|
};
|
|
203
|
-
const _getOrderedXAxisLabels = (
|
|
299
|
+
const _getOrderedXAxisLabels = (barData, lineData)=>{
|
|
204
300
|
if (_xAxisType !== XAxisTypes.StringAxis) {
|
|
205
301
|
return [];
|
|
206
302
|
}
|
|
207
|
-
return sortAxisCategories(_mapCategoryToValues(
|
|
303
|
+
return sortAxisCategories(_mapCategoryToValues(barData, lineData), props.xAxisCategoryOrder);
|
|
208
304
|
};
|
|
209
|
-
const _mapCategoryToValues = (
|
|
305
|
+
const _mapCategoryToValues = (barData, lineData)=>{
|
|
210
306
|
const categoryToValues = {};
|
|
211
|
-
|
|
307
|
+
barData.forEach((point)=>{
|
|
212
308
|
if (!categoryToValues[point.name]) {
|
|
213
309
|
categoryToValues[point.name] = [];
|
|
214
310
|
}
|
|
@@ -216,15 +312,24 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
216
312
|
categoryToValues[point.name].push(seriesPoint.data);
|
|
217
313
|
});
|
|
218
314
|
});
|
|
315
|
+
lineData.forEach((series)=>{
|
|
316
|
+
series.data.forEach((point)=>{
|
|
317
|
+
if (!categoryToValues[point.x]) {
|
|
318
|
+
categoryToValues[point.x] = [];
|
|
319
|
+
}
|
|
320
|
+
categoryToValues[point.x].push(point.y);
|
|
321
|
+
});
|
|
322
|
+
});
|
|
219
323
|
return categoryToValues;
|
|
220
324
|
};
|
|
221
|
-
const
|
|
222
|
-
const _xAxisType = getTypeOfAxis(
|
|
223
|
-
const {
|
|
224
|
-
|
|
325
|
+
const { barData, lineData } = _prepareChartData();
|
|
326
|
+
const _xAxisType = getTypeOfAxis(barData[0].name, true);
|
|
327
|
+
const { barLegends, lineLegends, xAxisLabels, datasetForBars } = _createDataSetOfGVBC(barData, lineData);
|
|
328
|
+
_barLegends = barLegends;
|
|
329
|
+
_lineLegends = lineLegends;
|
|
225
330
|
_xAxisLabels = xAxisLabels;
|
|
226
331
|
_datasetForBars = datasetForBars;
|
|
227
|
-
const legendBars = _getLegendData(
|
|
332
|
+
const legendBars = _getLegendData();
|
|
228
333
|
_adjustProps();
|
|
229
334
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Add commentMore actions
|
|
230
335
|
function _getMinMaxOfYAxis(datasetForBars, yAxisType, useSecondaryYScale) {
|
|
@@ -262,16 +367,19 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
262
367
|
const yMax = _getMinMaxOfYAxis(_datasetForBars).endValue;
|
|
263
368
|
_yMax = Math.max(yMax, props.yMaxValue || 0);
|
|
264
369
|
const calloutProps = {
|
|
265
|
-
|
|
370
|
+
positioning: {
|
|
371
|
+
target: popoverTarget
|
|
372
|
+
},
|
|
266
373
|
isPopoverOpen,
|
|
267
374
|
color,
|
|
268
375
|
legend: calloutLegend,
|
|
269
376
|
XValue: xCalloutValue,
|
|
270
377
|
YValue: yCalloutValue ? yCalloutValue : dataForHoverCard,
|
|
271
|
-
YValueHover,
|
|
378
|
+
YValueHover: yValueHover,
|
|
272
379
|
hoverXValue,
|
|
273
380
|
culture: props.culture,
|
|
274
381
|
isCartesian: true,
|
|
382
|
+
isCalloutForStack: props.isCalloutForStack,
|
|
275
383
|
...props.calloutProps,
|
|
276
384
|
...getAccessibleDataObject(callOutAccessibilityData, 'text', false)
|
|
277
385
|
};
|
|
@@ -283,8 +391,8 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
283
391
|
const xScale0 = _createX0Scale(containerWidth);
|
|
284
392
|
// Setting the bar width here is safe because there are no dependencies earlier in the code
|
|
285
393
|
// that rely on the width of bars in vertical bar charts with string x-axis.
|
|
286
|
-
_barWidth = getBarWidth(props.barWidth, props.maxBarWidth, calcBandwidth(xScale0.bandwidth(),
|
|
287
|
-
_groupWidth = calcRequiredWidth(_barWidth,
|
|
394
|
+
_barWidth = getBarWidth(props.barWidth, props.maxBarWidth, calcBandwidth(xScale0.bandwidth(), _barLegends.length, X1_INNER_PADDING));
|
|
395
|
+
_groupWidth = calcRequiredWidth(_barWidth, _barLegends.length, X1_INNER_PADDING);
|
|
288
396
|
const xScale1 = _createX1Scale();
|
|
289
397
|
const allGroupsBars = [];
|
|
290
398
|
_datasetForBars.forEach((singleSet)=>{
|
|
@@ -295,35 +403,12 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
295
403
|
const _getMargins = (margins)=>{
|
|
296
404
|
_margins = margins;
|
|
297
405
|
};
|
|
298
|
-
function updatePosition(newX, newY) {
|
|
299
|
-
const threshold = 1; // Set a threshold for movement
|
|
300
|
-
const { x, y } = clickPosition;
|
|
301
|
-
// Calculate the distance moved
|
|
302
|
-
const distance = Math.sqrt(Math.pow(newX - x, 2) + Math.pow(newY - y, 2));
|
|
303
|
-
// Update the position only if the distance moved is greater than the threshold
|
|
304
|
-
if (distance > threshold) {
|
|
305
|
-
setClickPosition({
|
|
306
|
-
x: newX,
|
|
307
|
-
y: newY
|
|
308
|
-
});
|
|
309
|
-
setPopoverOpen(true);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
406
|
const onBarHover = (pointData, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
313
407
|
groupData, mouseEvent)=>{
|
|
314
408
|
mouseEvent.persist();
|
|
315
409
|
if (_calloutAnchorPoint !== pointData) {
|
|
316
410
|
_calloutAnchorPoint = pointData;
|
|
317
|
-
|
|
318
|
-
setPopoverOpen(_noLegendHighlighted() || _legendHighlighted(pointData.legend));
|
|
319
|
-
setCalloutLegend(pointData.legend);
|
|
320
|
-
setDataForHoverCard(pointData.data);
|
|
321
|
-
setColor(pointData.color);
|
|
322
|
-
setXCalloutValue(pointData.xAxisCalloutData);
|
|
323
|
-
setYCalloutValue(pointData.yAxisCalloutData);
|
|
324
|
-
setCallOutAccessibilityData(props.isCalloutForStack ? groupData.stackCallOutAccessibilityData : pointData.callOutAccessibilityData);
|
|
325
|
-
setYValueHover(groupData.groupSeries);
|
|
326
|
-
setHoverXValue(pointData.xAxisCalloutData);
|
|
411
|
+
_showCallout(mouseEvent.currentTarget, pointData, groupData);
|
|
327
412
|
}
|
|
328
413
|
};
|
|
329
414
|
const _onBarLeave = ()=>{
|
|
@@ -332,23 +417,9 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
332
417
|
_calloutAnchorPoint = null;
|
|
333
418
|
setPopoverOpen(false);
|
|
334
419
|
};
|
|
335
|
-
const onBarFocus = (
|
|
420
|
+
const onBarFocus = (focusEvent, pointData, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
336
421
|
groupData)=>{
|
|
337
|
-
|
|
338
|
-
let y = 0;
|
|
339
|
-
const targetRect = event.target.getBoundingClientRect();
|
|
340
|
-
x = targetRect.left + targetRect.width / 2;
|
|
341
|
-
y = targetRect.top + targetRect.height / 2;
|
|
342
|
-
updatePosition(x, y);
|
|
343
|
-
setPopoverOpen(_noLegendHighlighted() || _legendHighlighted(pointData.legend));
|
|
344
|
-
setCalloutLegend(pointData.legend);
|
|
345
|
-
setDataForHoverCard(pointData.data);
|
|
346
|
-
setColor(pointData.color);
|
|
347
|
-
setXCalloutValue(pointData.xAxisCalloutData);
|
|
348
|
-
setYCalloutValue(pointData.yAxisCalloutData);
|
|
349
|
-
setCallOutAccessibilityData(props.isCalloutForStack ? groupData.stackCallOutAccessibilityData : pointData.callOutAccessibilityData);
|
|
350
|
-
setYValueHover(groupData.groupSeries);
|
|
351
|
-
setHoverXValue(pointData.xAxisCalloutData);
|
|
422
|
+
_showCallout(focusEvent.currentTarget, pointData, groupData);
|
|
352
423
|
};
|
|
353
424
|
const _buildGraph = (// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
354
425
|
singleSet, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -359,7 +430,7 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
359
430
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
360
431
|
const barLabelsForGroup = [];
|
|
361
432
|
// Get the actual legends present at this x-axis point
|
|
362
|
-
const presentLegends =
|
|
433
|
+
const presentLegends = _barLegends.filter((key)=>key in singleSet);
|
|
363
434
|
const effectiveGroupWidth = calcRequiredWidth(_barWidth, presentLegends.length, X1_INNER_PADDING);
|
|
364
435
|
// For stacked bars, center the single bar group in the available space
|
|
365
436
|
// Instead of using the global legend position, use the local position within present legends
|
|
@@ -370,7 +441,7 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
370
441
|
0,
|
|
371
442
|
effectiveGroupWidth
|
|
372
443
|
]).paddingInner(X1_INNER_PADDING);
|
|
373
|
-
|
|
444
|
+
_barLegends.forEach((legendTitle, legendIndex)=>{
|
|
374
445
|
const barPoints = singleSet[legendTitle];
|
|
375
446
|
if (barPoints) {
|
|
376
447
|
const yBarScale = barPoints[0].useSecondaryYScale && yScaleSecondary ? yScaleSecondary : yScalePrimary;
|
|
@@ -469,7 +540,7 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
469
540
|
};
|
|
470
541
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
471
542
|
const _createX1Scale = ()=>{
|
|
472
|
-
return d3ScaleBand().domain(
|
|
543
|
+
return d3ScaleBand().domain(_barLegends)// When there is only one group, xScale0 adds padding around it,
|
|
473
544
|
// causing the bandwidth to become smaller than the actual group width.
|
|
474
545
|
// So to render bars in the group correctly, use groupWidth instead of the generated scale bandwidth.
|
|
475
546
|
.range(_useRtl ? [
|
|
@@ -530,7 +601,7 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
530
601
|
// Update the bar width so that when CartesianChart rerenders,
|
|
531
602
|
// the following calculations don't use the previous bar width.
|
|
532
603
|
_barWidth = getBarWidth(props.barWidth, props.maxBarWidth);
|
|
533
|
-
const groupWidth = calcRequiredWidth(_barWidth,
|
|
604
|
+
const groupWidth = calcRequiredWidth(_barWidth, _barLegends.length, X1_INNER_PADDING);
|
|
534
605
|
/** Total width required to render the groups. Directly proportional to group width */ const reqWidth = calcRequiredWidth(groupWidth, _xAxisLabels.length, _xAxisInnerPadding);
|
|
535
606
|
if (totalWidth >= reqWidth) {
|
|
536
607
|
// Center align the chart by setting equal left and right margins for domain
|
|
@@ -539,9 +610,9 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
539
610
|
} else if (props.mode === 'plotly' && xAxisLabels.length > 1) {
|
|
540
611
|
// Calculate the remaining width after rendering groups at their maximum allowable width
|
|
541
612
|
const groupBandwidth = calcBandwidth(totalWidth, _xAxisLabels.length, _xAxisInnerPadding);
|
|
542
|
-
const barBandwidth = calcBandwidth(groupBandwidth,
|
|
613
|
+
const barBandwidth = calcBandwidth(groupBandwidth, _barLegends.length, X1_INNER_PADDING);
|
|
543
614
|
const barWidth = getBarWidth(props.barWidth, props.maxBarWidth, barBandwidth);
|
|
544
|
-
const groupWidth = calcRequiredWidth(barWidth,
|
|
615
|
+
const groupWidth = calcRequiredWidth(barWidth, _barLegends.length, X1_INNER_PADDING);
|
|
545
616
|
let reqWidth = calcRequiredWidth(groupWidth, _xAxisLabels.length, _xAxisInnerPadding);
|
|
546
617
|
const margin1 = (totalWidth - reqWidth) / 2;
|
|
547
618
|
let margin2 = Number.POSITIVE_INFINITY;
|
|
@@ -560,13 +631,152 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
560
631
|
right: _margins.right + _domainMargin
|
|
561
632
|
};
|
|
562
633
|
};
|
|
563
|
-
const _isChartEmpty = ()=>{
|
|
564
|
-
return !(
|
|
634
|
+
const _isChartEmpty = (_barData, _lineData)=>{
|
|
635
|
+
return !(_barData && _barData.length > 0 && _barData.filter((item)=>item.series.length).length > 0 || _lineData && _lineData.length > 0 && _lineData.some((series)=>series.data.length > 0));
|
|
565
636
|
};
|
|
566
637
|
const _getChartTitle = ()=>{
|
|
567
|
-
return (props.chartTitle ? `${props.chartTitle}. ` : '') + `Vertical bar chart with ${
|
|
638
|
+
return (props.chartTitle ? `${props.chartTitle}. ` : '') + `Vertical bar chart with ${_barLegends.length} grouped bar series` + (_lineLegends.length > 0 ? ` and ${_lineLegends.length} line series. ` : '. ');
|
|
639
|
+
};
|
|
640
|
+
const _createLines = (_lineData, xScale, yScalePrimary, yScaleSecondary)=>{
|
|
641
|
+
const lineBorders = [];
|
|
642
|
+
const lines = [];
|
|
643
|
+
const dots = [];
|
|
644
|
+
const scaleLineX = (x)=>xScale(x) + xScale.bandwidth() / 2;
|
|
645
|
+
_lineData.forEach((series, seriesIdx)=>{
|
|
646
|
+
var _series_lineOptions;
|
|
647
|
+
const lineBorderGroup = [];
|
|
648
|
+
const lineGroup = [];
|
|
649
|
+
const dotGroup = [];
|
|
650
|
+
const lineBorderWidth = ((_series_lineOptions = series.lineOptions) === null || _series_lineOptions === void 0 ? void 0 : _series_lineOptions.lineBorderWidth) ? Number.parseFloat(series.lineOptions.lineBorderWidth.toString()) : 0;
|
|
651
|
+
const yScale = series.useSecondaryYScale && yScaleSecondary ? yScaleSecondary : yScalePrimary;
|
|
652
|
+
const shouldHighlight = _legendHighlighted(series.legend) || _noLegendHighlighted();
|
|
653
|
+
series.data.forEach((point, pointIdx)=>{
|
|
654
|
+
const x2 = scaleLineX(point.x);
|
|
655
|
+
const y2 = yScale(point.y);
|
|
656
|
+
if (pointIdx > 0) {
|
|
657
|
+
var _series_lineOptions, _series_lineOptions1, _series_lineOptions2;
|
|
658
|
+
const x1 = scaleLineX(series.data[pointIdx - 1].x);
|
|
659
|
+
const y1 = yScale(series.data[pointIdx - 1].y);
|
|
660
|
+
if (lineBorderWidth > 0) {
|
|
661
|
+
var _series_lineOptions3;
|
|
662
|
+
var _series_lineOptions_lineBorderColor;
|
|
663
|
+
lineBorderGroup.push(/*#__PURE__*/ React.createElement("line", {
|
|
664
|
+
key: `lineBorder-${seriesIdx}-${pointIdx}`,
|
|
665
|
+
x1: x1,
|
|
666
|
+
y1: y1,
|
|
667
|
+
x2: x2,
|
|
668
|
+
y2: y2,
|
|
669
|
+
fill: "transparent",
|
|
670
|
+
stroke: (_series_lineOptions_lineBorderColor = (_series_lineOptions3 = series.lineOptions) === null || _series_lineOptions3 === void 0 ? void 0 : _series_lineOptions3.lineBorderColor) !== null && _series_lineOptions_lineBorderColor !== void 0 ? _series_lineOptions_lineBorderColor : tokens.colorNeutralBackground1,
|
|
671
|
+
strokeWidth: 3 + lineBorderWidth * 2,
|
|
672
|
+
strokeLinecap: "round",
|
|
673
|
+
opacity: shouldHighlight ? 1 : 0.1
|
|
674
|
+
}));
|
|
675
|
+
}
|
|
676
|
+
var _series_lineOptions_strokeWidth, _series_lineOptions_strokeLinecap;
|
|
677
|
+
lineGroup.push(/*#__PURE__*/ React.createElement("line", {
|
|
678
|
+
key: `line-${seriesIdx}-${pointIdx}`,
|
|
679
|
+
x1: x1,
|
|
680
|
+
y1: y1,
|
|
681
|
+
x2: x2,
|
|
682
|
+
y2: y2,
|
|
683
|
+
stroke: series.color,
|
|
684
|
+
strokeWidth: (_series_lineOptions_strokeWidth = (_series_lineOptions = series.lineOptions) === null || _series_lineOptions === void 0 ? void 0 : _series_lineOptions.strokeWidth) !== null && _series_lineOptions_strokeWidth !== void 0 ? _series_lineOptions_strokeWidth : 3,
|
|
685
|
+
strokeLinecap: (_series_lineOptions_strokeLinecap = (_series_lineOptions1 = series.lineOptions) === null || _series_lineOptions1 === void 0 ? void 0 : _series_lineOptions1.strokeLinecap) !== null && _series_lineOptions_strokeLinecap !== void 0 ? _series_lineOptions_strokeLinecap : 'round',
|
|
686
|
+
strokeDasharray: (_series_lineOptions2 = series.lineOptions) === null || _series_lineOptions2 === void 0 ? void 0 : _series_lineOptions2.strokeDasharray,
|
|
687
|
+
opacity: shouldHighlight ? 1 : 0.1,
|
|
688
|
+
onMouseOver: (e)=>_onLineHover(e, series, seriesIdx, pointIdx, scaleLineX),
|
|
689
|
+
onMouseLeave: _onBarLeave
|
|
690
|
+
}));
|
|
691
|
+
}
|
|
692
|
+
const dotId = _getDotId(seriesIdx, pointIdx);
|
|
693
|
+
const isLinePointActive = activeLinePoint === point.x || activeLinePoint === dotId;
|
|
694
|
+
dotGroup.push(/*#__PURE__*/ React.createElement("circle", {
|
|
695
|
+
key: dotId,
|
|
696
|
+
id: dotId,
|
|
697
|
+
cx: x2,
|
|
698
|
+
cy: y2,
|
|
699
|
+
r: shouldHighlight && isLinePointActive ? 8 : 0.3,
|
|
700
|
+
fill: tokens.colorNeutralBackground1,
|
|
701
|
+
stroke: series.color,
|
|
702
|
+
strokeWidth: 3,
|
|
703
|
+
opacity: shouldHighlight ? 1 : 0.1,
|
|
704
|
+
onMouseOver: (e)=>_onLineHover(e, series, seriesIdx, pointIdx, scaleLineX),
|
|
705
|
+
onMouseLeave: _onBarLeave,
|
|
706
|
+
"data-is-focusable": shouldHighlight,
|
|
707
|
+
onFocus: (e)=>_onLineFocus(e, series, seriesIdx, pointIdx),
|
|
708
|
+
onBlur: _onBarLeave,
|
|
709
|
+
role: "img",
|
|
710
|
+
"aria-label": getAriaLabel({
|
|
711
|
+
xAxisCalloutData: point.xAxisCalloutData,
|
|
712
|
+
legend: series.legend,
|
|
713
|
+
yAxisCalloutData: point.yAxisCalloutData,
|
|
714
|
+
data: point.y,
|
|
715
|
+
callOutAccessibilityData: point.callOutAccessibilityData
|
|
716
|
+
}, point.x)
|
|
717
|
+
}));
|
|
718
|
+
});
|
|
719
|
+
lineBorders.push(/*#__PURE__*/ React.createElement("g", {
|
|
720
|
+
key: `lineBorderGroup-${seriesIdx}`
|
|
721
|
+
}, lineBorderGroup));
|
|
722
|
+
lines.push(/*#__PURE__*/ React.createElement("g", {
|
|
723
|
+
key: `lineGroup-${seriesIdx}`
|
|
724
|
+
}, lineGroup));
|
|
725
|
+
dots.push(/*#__PURE__*/ React.createElement("g", {
|
|
726
|
+
key: `dotGroup-${seriesIdx}`
|
|
727
|
+
}, dotGroup));
|
|
728
|
+
});
|
|
729
|
+
return dots.length > 0 ? /*#__PURE__*/ React.createElement("g", null, lineBorders.length > 0 ? /*#__PURE__*/ React.createElement("g", null, lineBorders) : null, lines.length > 0 ? /*#__PURE__*/ React.createElement("g", null, lines) : null, /*#__PURE__*/ React.createElement("g", null, dots)) : null;
|
|
568
730
|
};
|
|
569
|
-
|
|
731
|
+
const _onLineHover = (event, series, seriesIdx, pointIdx, scaleLineX)=>{
|
|
732
|
+
const pointerX = d3Pointer(event, _rectRef.current)[0];
|
|
733
|
+
let closestPointIdx = pointIdx;
|
|
734
|
+
if (pointIdx > 0) {
|
|
735
|
+
const currPointPos = scaleLineX(series.data[pointIdx].x);
|
|
736
|
+
const prevPointPos = scaleLineX(series.data[pointIdx - 1].x);
|
|
737
|
+
if (Math.abs(prevPointPos - pointerX) < Math.abs(currPointPos - pointerX)) {
|
|
738
|
+
closestPointIdx = pointIdx - 1;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
event.persist();
|
|
742
|
+
_showCalloutForLines(event.currentTarget, series, seriesIdx, closestPointIdx);
|
|
743
|
+
};
|
|
744
|
+
const _onLineFocus = (event, series, seriesIdx, pointIdx)=>{
|
|
745
|
+
_showCalloutForLines(event.currentTarget, series, seriesIdx, pointIdx);
|
|
746
|
+
};
|
|
747
|
+
const _showCalloutForLines = (target, series, seriesIdx, pointIdx)=>{
|
|
748
|
+
const point = series.data[pointIdx];
|
|
749
|
+
const pointData = {
|
|
750
|
+
...point,
|
|
751
|
+
legend: series.legend,
|
|
752
|
+
color: series.color,
|
|
753
|
+
key: series.legend,
|
|
754
|
+
data: point.y,
|
|
755
|
+
yAxisCalloutData: point.yAxisCalloutData
|
|
756
|
+
};
|
|
757
|
+
const groupData = _datasetForBars.find((singleSet)=>singleSet.xAxisPoint === point.x);
|
|
758
|
+
_showCallout(target, pointData, groupData, _getDotId(seriesIdx, pointIdx));
|
|
759
|
+
};
|
|
760
|
+
const _showCallout = (target, pointData, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
761
|
+
groupData, _activeLinePoint = '')=>{
|
|
762
|
+
setPopoverTarget(target);
|
|
763
|
+
setPopoverOpen(_noLegendHighlighted() || _legendHighlighted(pointData.legend));
|
|
764
|
+
setCalloutLegend(pointData.legend);
|
|
765
|
+
setDataForHoverCard(pointData.data);
|
|
766
|
+
setColor(pointData.color);
|
|
767
|
+
var _pointData_xAxisCalloutData;
|
|
768
|
+
setXCalloutValue((_pointData_xAxisCalloutData = pointData.xAxisCalloutData) !== null && _pointData_xAxisCalloutData !== void 0 ? _pointData_xAxisCalloutData : groupData.xAxisPoint);
|
|
769
|
+
setYCalloutValue(pointData.yAxisCalloutData);
|
|
770
|
+
setCallOutAccessibilityData(props.isCalloutForStack ? groupData.stackCallOutAccessibilityData : pointData.callOutAccessibilityData);
|
|
771
|
+
setYValueHover(groupData.groupSeries.filter((item)=>_noLegendHighlighted() || _legendHighlighted(item.legend)));
|
|
772
|
+
var _pointData_xAxisCalloutData1;
|
|
773
|
+
setHoverXValue((_pointData_xAxisCalloutData1 = pointData.xAxisCalloutData) !== null && _pointData_xAxisCalloutData1 !== void 0 ? _pointData_xAxisCalloutData1 : groupData.xAxisPoint);
|
|
774
|
+
setActiveLinePoint(props.isCalloutForStack ? groupData.xAxisPoint : _activeLinePoint);
|
|
775
|
+
};
|
|
776
|
+
const _getDotId = (seriesIdx, pointIdx)=>{
|
|
777
|
+
return _uniqDotId + `-${seriesIdx}-${pointIdx}`;
|
|
778
|
+
};
|
|
779
|
+
return !_isChartEmpty(barData, lineData) ? /*#__PURE__*/ React.createElement(CartesianChart, {
|
|
570
780
|
...props,
|
|
571
781
|
chartTitle: _getChartTitle(),
|
|
572
782
|
points: _datasetForBars,
|
|
@@ -593,8 +803,16 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((_props, f
|
|
|
593
803
|
},
|
|
594
804
|
barwidth: _barWidth,
|
|
595
805
|
componentRef: cartesianChartRef,
|
|
596
|
-
/* eslint-disable react/jsx-no-bind */ children: ()=>{
|
|
597
|
-
return /*#__PURE__*/ React.createElement(
|
|
806
|
+
/* eslint-disable react/jsx-no-bind */ children: (childProps)=>{
|
|
807
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("rect", {
|
|
808
|
+
ref: _rectRef,
|
|
809
|
+
width: "100%",
|
|
810
|
+
height: "100%",
|
|
811
|
+
fill: "transparent",
|
|
812
|
+
style: {
|
|
813
|
+
pointerEvents: 'none'
|
|
814
|
+
}
|
|
815
|
+
}), /*#__PURE__*/ React.createElement("g", null, _groupedVerticalBarGraph), _createLines(lineData, childProps.xScale, childProps.yScalePrimary, childProps.yScaleSecondary));
|
|
598
816
|
}
|
|
599
817
|
}) : /*#__PURE__*/ React.createElement("div", {
|
|
600
818
|
id: _emptyChartId,
|