@fluentui/react-charting 5.24.30 → 5.24.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +43 -1
- package/CHANGELOG.md +22 -2
- package/dist/react-charting.d.ts +135 -2
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +45 -2
- package/lib/components/AreaChart/AreaChart.base.js +18 -22
- package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +1 -4
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +93 -50
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +13 -2
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +260 -100
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.d.ts +7 -2
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib/components/LineChart/LineChart.base.js +59 -42
- package/lib/components/LineChart/LineChart.base.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.base.js +5 -11
- package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js.map +1 -1
- package/lib/types/IDataPoint.d.ts +125 -1
- package/lib/types/IDataPoint.js.map +1 -1
- package/lib/utilities/utilities.d.ts +18 -4
- package/lib/utilities/utilities.js +14 -5
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/components/AreaChart/AreaChart.base.js +16 -20
- package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +1 -4
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +92 -49
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +13 -2
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +257 -97
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.d.ts +7 -2
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.base.js +58 -41
- package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.base.js +3 -9
- package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-amd/index.d.ts +1 -1
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/types/IDataPoint.d.ts +125 -1
- package/lib-amd/types/IDataPoint.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +18 -4
- package/lib-amd/utilities/utilities.js +16 -6
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.base.js +16 -20
- package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +1 -4
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +92 -49
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +13 -2
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +257 -97
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.d.ts +7 -2
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.base.js +58 -41
- package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +3 -9
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-commonjs/index.d.ts +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/IDataPoint.d.ts +125 -1
- package/lib-commonjs/types/IDataPoint.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +18 -4
- package/lib-commonjs/utilities/utilities.js +16 -6
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +2 -2
|
@@ -6,11 +6,13 @@ export interface IGroupedVerticalBarChartState extends IBasestate {
|
|
|
6
6
|
callOutAccessibilityData?: IAccessibilityProps;
|
|
7
7
|
calloutLegend: string;
|
|
8
8
|
selectedLegends: string[];
|
|
9
|
+
activeLinePoint: string;
|
|
9
10
|
}
|
|
10
11
|
export declare class GroupedVerticalBarChartBase extends React.Component<IGroupedVerticalBarChartProps, IGroupedVerticalBarChartState> implements IChart {
|
|
11
12
|
static defaultProps: Partial<IGroupedVerticalBarChartProps>;
|
|
12
13
|
private _createSet;
|
|
13
|
-
private
|
|
14
|
+
private _barLegends;
|
|
15
|
+
private _lineLegends;
|
|
14
16
|
private _xAxisLabels;
|
|
15
17
|
private _datasetForBars;
|
|
16
18
|
private margins;
|
|
@@ -32,6 +34,8 @@ export declare class GroupedVerticalBarChartBase extends React.Component<IGroupe
|
|
|
32
34
|
private _legendsRef;
|
|
33
35
|
private _legendColorMap;
|
|
34
36
|
private readonly Y_ORIGIN;
|
|
37
|
+
private _rectRef;
|
|
38
|
+
private _uniqDotId;
|
|
35
39
|
constructor(props: IGroupedVerticalBarChartProps);
|
|
36
40
|
componentDidUpdate(prevProps: IGroupedVerticalBarChartProps): void;
|
|
37
41
|
render(): React.ReactNode;
|
|
@@ -76,7 +80,14 @@ export declare class GroupedVerticalBarChartBase extends React.Component<IGroupe
|
|
|
76
80
|
private _adjustProps;
|
|
77
81
|
private _getChartTitle;
|
|
78
82
|
private _adjustColor;
|
|
79
|
-
private
|
|
83
|
+
private _prepareChartData;
|
|
80
84
|
private _getOrderedXAxisLabels;
|
|
81
85
|
private _mapCategoryToValues;
|
|
86
|
+
private _createLines;
|
|
87
|
+
private _onLineHover;
|
|
88
|
+
private _onLineFocus;
|
|
89
|
+
private _showCalloutForLines;
|
|
90
|
+
private _showCallout;
|
|
91
|
+
private _getDotId;
|
|
92
|
+
private _processDataV2;
|
|
82
93
|
}
|
|
@@ -16,6 +16,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
16
16
|
_this._isRtl = (0, Utilities_1.getRTL)();
|
|
17
17
|
_this._legendColorMap = {};
|
|
18
18
|
_this.Y_ORIGIN = 0;
|
|
19
|
+
_this._uniqDotId = (0, Utilities_1.getId)('gvbc_dot_');
|
|
19
20
|
_this.toImage = function (opts) {
|
|
20
21
|
var _a, _b;
|
|
21
22
|
return (0, image_export_utils_1.toImage)((_a = _this._cartesianChartRef.current) === null || _a === void 0 ? void 0 : _a.chartContainer, (_b = _this._legendsRef.current) === null || _b === void 0 ? void 0 : _b.toSVG, _this._isRtl, opts);
|
|
@@ -47,8 +48,8 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
47
48
|
var xScale0 = _this._createX0Scale(containerWidth);
|
|
48
49
|
// Setting the bar width here is safe because there are no dependencies earlier in the code
|
|
49
50
|
// that rely on the width of bars in vertical bar charts with string x-axis.
|
|
50
|
-
_this._barWidth = (0, index_1.getBarWidth)(_this.props.barwidth, _this.props.maxBarWidth, (0, index_1.calcBandwidth)(xScale0.bandwidth(), _this.
|
|
51
|
-
_this._groupWidth = (0, index_1.calcRequiredWidth)(_this._barWidth, _this.
|
|
51
|
+
_this._barWidth = (0, index_1.getBarWidth)(_this.props.barwidth, _this.props.maxBarWidth, (0, index_1.calcBandwidth)(xScale0.bandwidth(), _this._barLegends.length, X1_INNER_PADDING));
|
|
52
|
+
_this._groupWidth = (0, index_1.calcRequiredWidth)(_this._barWidth, _this._barLegends.length, X1_INNER_PADDING);
|
|
52
53
|
var xScale1 = _this._createX1Scale();
|
|
53
54
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
54
55
|
var allGroupsBars = [];
|
|
@@ -58,17 +59,19 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
58
59
|
_this._groupedVerticalBarGraph = allGroupsBars;
|
|
59
60
|
};
|
|
60
61
|
_this._getMargins = function (margins) { return (_this.margins = margins); };
|
|
61
|
-
_this._createDataSetOfGVBC = function (
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
points.forEach(function (point) {
|
|
62
|
+
_this._createDataSetOfGVBC = function (barData, lineData) {
|
|
63
|
+
var barLegends = new Set();
|
|
64
|
+
barData.forEach(function (point) {
|
|
65
65
|
point.series.forEach(function (seriesPoint) {
|
|
66
|
-
|
|
66
|
+
barLegends.add(seriesPoint.legend);
|
|
67
67
|
});
|
|
68
68
|
});
|
|
69
|
-
var
|
|
69
|
+
var lineLegends = new Set(lineData.map(function (series) { return series.legend; }));
|
|
70
|
+
var xAxisLabels = _this._getOrderedXAxisLabels(barData, lineData);
|
|
71
|
+
var datasetForBars = _this._createDataset(barData, lineData);
|
|
70
72
|
return {
|
|
71
|
-
|
|
73
|
+
barLegends: Array.from(barLegends),
|
|
74
|
+
lineLegends: Array.from(lineLegends),
|
|
72
75
|
xAxisLabels: xAxisLabels,
|
|
73
76
|
datasetForBars: datasetForBars,
|
|
74
77
|
};
|
|
@@ -84,22 +87,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
84
87
|
mouseEvent.persist();
|
|
85
88
|
if (_this._calloutAnchorPoint !== pointData) {
|
|
86
89
|
_this._calloutAnchorPoint = pointData;
|
|
87
|
-
_this.
|
|
88
|
-
refSelected: mouseEvent,
|
|
89
|
-
/** Show the callout if highlighted bar is hovered and Hide it if unhighlighted bar is hovered */
|
|
90
|
-
isCalloutVisible: _this._noLegendHighlighted() || _this._legendHighlighted(pointData.legend),
|
|
91
|
-
calloutLegend: pointData.legend,
|
|
92
|
-
dataForHoverCard: pointData.data,
|
|
93
|
-
color: pointData.color,
|
|
94
|
-
xCalloutValue: pointData.xAxisCalloutData,
|
|
95
|
-
yCalloutValue: pointData.yAxisCalloutData,
|
|
96
|
-
dataPointCalloutProps: pointData,
|
|
97
|
-
callOutAccessibilityData: _this.props.isCalloutForStack
|
|
98
|
-
? groupData.stackCallOutAccessibilityData
|
|
99
|
-
: pointData.callOutAccessibilityData,
|
|
100
|
-
YValueHover: groupData.groupSeries,
|
|
101
|
-
hoverXValue: pointData.xAxisCalloutData,
|
|
102
|
-
});
|
|
90
|
+
_this._showCallout(mouseEvent, pointData, groupData);
|
|
103
91
|
}
|
|
104
92
|
};
|
|
105
93
|
_this._onBarLeave = function () {
|
|
@@ -112,22 +100,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
112
100
|
_this._onBarFocus = function (pointData,
|
|
113
101
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
102
|
groupData, focusEvent) {
|
|
115
|
-
_this.
|
|
116
|
-
refSelected: focusEvent.currentTarget,
|
|
117
|
-
/** Show the callout if highlighted bar is focused and Hide it if unhighlighted bar is focused */
|
|
118
|
-
isCalloutVisible: _this._noLegendHighlighted() || _this._legendHighlighted(pointData.legend),
|
|
119
|
-
calloutLegend: pointData.legend,
|
|
120
|
-
dataForHoverCard: pointData.data,
|
|
121
|
-
color: pointData.color,
|
|
122
|
-
xCalloutValue: pointData.xAxisCalloutData,
|
|
123
|
-
yCalloutValue: pointData.yAxisCalloutData,
|
|
124
|
-
dataPointCalloutProps: pointData,
|
|
125
|
-
callOutAccessibilityData: _this.props.isCalloutForStack
|
|
126
|
-
? groupData.stackCallOutAccessibilityData
|
|
127
|
-
: pointData.callOutAccessibilityData,
|
|
128
|
-
YValueHover: groupData.groupSeries,
|
|
129
|
-
hoverXValue: pointData.xAxisCalloutData,
|
|
130
|
-
});
|
|
103
|
+
_this._showCallout(focusEvent.currentTarget, pointData, groupData);
|
|
131
104
|
};
|
|
132
105
|
_this._redirectToUrl = function (href) {
|
|
133
106
|
href ? (window.location.href = href) : '';
|
|
@@ -144,7 +117,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
144
117
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
145
118
|
var barLabelsForGroup = [];
|
|
146
119
|
// Get the actual legends present at this x-axis point
|
|
147
|
-
var presentLegends =
|
|
120
|
+
var presentLegends = _this._barLegends.filter(function (key) { return key in singleSet; });
|
|
148
121
|
var effectiveGroupWidth = (0, index_1.calcRequiredWidth)(_this._barWidth, presentLegends.length, X1_INNER_PADDING);
|
|
149
122
|
// For stacked bars, center the single bar group in the available space
|
|
150
123
|
// Instead of using the global legend position, use the local position within present legends
|
|
@@ -152,7 +125,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
152
125
|
.domain(presentLegends)
|
|
153
126
|
.range(_this._isRtl ? [effectiveGroupWidth, 0] : [0, effectiveGroupWidth])
|
|
154
127
|
.paddingInner(X1_INNER_PADDING);
|
|
155
|
-
_this.
|
|
128
|
+
_this._barLegends.forEach(function (legendTitle, legendIndex) {
|
|
156
129
|
var _a;
|
|
157
130
|
var barPoints = singleSet[legendTitle];
|
|
158
131
|
if (barPoints) {
|
|
@@ -220,10 +193,21 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
220
193
|
singleGroup,
|
|
221
194
|
barLabelsForGroup));
|
|
222
195
|
};
|
|
223
|
-
_this._createDataset = function (
|
|
196
|
+
_this._createDataset = function (barData, lineData) {
|
|
224
197
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
225
198
|
var datasetForBars = [];
|
|
226
|
-
|
|
199
|
+
var linePointsByX = {};
|
|
200
|
+
var visitedX = new Set();
|
|
201
|
+
lineData.forEach(function (series) {
|
|
202
|
+
series.data.forEach(function (point) {
|
|
203
|
+
if (!linePointsByX[point.x]) {
|
|
204
|
+
linePointsByX[point.x] = [];
|
|
205
|
+
}
|
|
206
|
+
linePointsByX[point.x].push(tslib_1.__assign(tslib_1.__assign({}, point), { legend: series.legend, color: series.color, data: point.y, useSecondaryYScale: series.useSecondaryYScale }));
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
barData.forEach(function (point, index) {
|
|
210
|
+
var _a;
|
|
227
211
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
228
212
|
var singleDatasetPointForBars = {};
|
|
229
213
|
var legendToBarPoint = {};
|
|
@@ -239,9 +223,18 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
239
223
|
});
|
|
240
224
|
singleDatasetPointForBars.xAxisPoint = point.name;
|
|
241
225
|
singleDatasetPointForBars.indexNum = index;
|
|
242
|
-
singleDatasetPointForBars.groupSeries = Object.values(legendToBarPoint);
|
|
226
|
+
singleDatasetPointForBars.groupSeries = tslib_1.__spreadArray(tslib_1.__spreadArray([], Object.values(legendToBarPoint), true), ((_a = linePointsByX[point.name]) !== null && _a !== void 0 ? _a : []), true);
|
|
243
227
|
singleDatasetPointForBars.stackCallOutAccessibilityData = point.stackCallOutAccessibilityData;
|
|
244
228
|
datasetForBars.push(singleDatasetPointForBars);
|
|
229
|
+
visitedX.add(point.name);
|
|
230
|
+
});
|
|
231
|
+
Object.keys(linePointsByX).forEach(function (xPoint) {
|
|
232
|
+
if (!visitedX.has(xPoint)) {
|
|
233
|
+
datasetForBars.push({
|
|
234
|
+
xAxisPoint: xPoint,
|
|
235
|
+
groupSeries: linePointsByX[xPoint],
|
|
236
|
+
});
|
|
237
|
+
}
|
|
245
238
|
});
|
|
246
239
|
return datasetForBars;
|
|
247
240
|
};
|
|
@@ -260,7 +253,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
260
253
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
261
254
|
_this._createX1Scale = function () {
|
|
262
255
|
return ((0, d3_scale_1.scaleBand)()
|
|
263
|
-
.domain(_this.
|
|
256
|
+
.domain(_this._barLegends)
|
|
264
257
|
// When there is only one group, xScale0 adds padding around it,
|
|
265
258
|
// causing the bandwidth to become smaller than the actual group width.
|
|
266
259
|
// So to render bars in the group correctly, use groupWidth instead of the generated scale bandwidth.
|
|
@@ -275,10 +268,11 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
275
268
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
276
269
|
_this._getLegendData = function () {
|
|
277
270
|
var actions = [];
|
|
278
|
-
|
|
271
|
+
var addLegendButton = function (legendTitle, isLineLegendInBarChart) {
|
|
279
272
|
var legend = {
|
|
280
273
|
title: legendTitle,
|
|
281
274
|
color: _this._legendColorMap[legendTitle][0],
|
|
275
|
+
isLineLegendInBarChart: isLineLegendInBarChart,
|
|
282
276
|
hoverAction: function () {
|
|
283
277
|
_this._handleChartMouseLeave();
|
|
284
278
|
_this._onLegendHover(legendTitle);
|
|
@@ -288,7 +282,9 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
288
282
|
},
|
|
289
283
|
};
|
|
290
284
|
actions.push(legend);
|
|
291
|
-
}
|
|
285
|
+
};
|
|
286
|
+
_this._lineLegends.forEach(function (legendTitle) { return addLegendButton(legendTitle, true); });
|
|
287
|
+
_this._barLegends.forEach(function (legendTitle) { return addLegendButton(legendTitle); });
|
|
292
288
|
return (React.createElement(index_2.Legends, tslib_1.__assign({ legends: actions, overflowProps: _this.props.legendsOverflowProps, enabledWrapLines: _this.props.enabledLegendsWrapLines, focusZonePropsInHoverCard: _this.props.focusZonePropsForLegendsInHoverCard }, _this.props.legendProps, { onChange: _this._onLegendSelectionChange.bind(_this), ref: _this._legendsRef })));
|
|
293
289
|
};
|
|
294
290
|
_this._getAxisData = function (yAxisData) {
|
|
@@ -333,7 +329,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
333
329
|
// Update the bar width so that when CartesianChart rerenders,
|
|
334
330
|
// the following calculations don't use the previous bar width.
|
|
335
331
|
_this._barWidth = (0, index_1.getBarWidth)(_this.props.barwidth, _this.props.maxBarWidth);
|
|
336
|
-
var groupWidth = (0, index_1.calcRequiredWidth)(_this._barWidth, _this.
|
|
332
|
+
var groupWidth = (0, index_1.calcRequiredWidth)(_this._barWidth, _this._barLegends.length, X1_INNER_PADDING);
|
|
337
333
|
/** Total width required to render the groups. Directly proportional to group width */
|
|
338
334
|
var reqWidth = (0, index_1.calcRequiredWidth)(groupWidth, _this._xAxisLabels.length, _this._xAxisInnerPadding);
|
|
339
335
|
if (totalWidth >= reqWidth) {
|
|
@@ -344,9 +340,9 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
344
340
|
else if (_this.props.mode === 'plotly' && _this._xAxisLabels.length > 1) {
|
|
345
341
|
// Calculate the remaining width after rendering groups at their maximum allowable width
|
|
346
342
|
var groupBandwidth = (0, index_1.calcBandwidth)(totalWidth, _this._xAxisLabels.length, _this._xAxisInnerPadding);
|
|
347
|
-
var barBandwidth = (0, index_1.calcBandwidth)(groupBandwidth, _this.
|
|
343
|
+
var barBandwidth = (0, index_1.calcBandwidth)(groupBandwidth, _this._barLegends.length, X1_INNER_PADDING);
|
|
348
344
|
var barWidth = (0, index_1.getBarWidth)(_this.props.barwidth, _this.props.maxBarWidth, barBandwidth);
|
|
349
|
-
var groupWidth = (0, index_1.calcRequiredWidth)(barWidth, _this.
|
|
345
|
+
var groupWidth = (0, index_1.calcRequiredWidth)(barWidth, _this._barLegends.length, X1_INNER_PADDING);
|
|
350
346
|
var reqWidth = (0, index_1.calcRequiredWidth)(groupWidth, _this._xAxisLabels.length, _this._xAxisInnerPadding);
|
|
351
347
|
var margin1 = (totalWidth - reqWidth) / 2;
|
|
352
348
|
// Calculate the remaining width after accounting for the space required to render x-axis labels
|
|
@@ -361,7 +357,8 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
361
357
|
_this._getChartTitle = function () {
|
|
362
358
|
var chartTitle = _this.props.chartTitle;
|
|
363
359
|
return ((chartTitle ? "".concat(chartTitle, ". ") : '') +
|
|
364
|
-
"Vertical bar chart with ".concat(_this.
|
|
360
|
+
"Vertical bar chart with ".concat(_this._barLegends.length, " grouped bar series") +
|
|
361
|
+
(_this._lineLegends.length > 0 ? " and ".concat(_this._lineLegends.length, " line series. ") : '. '));
|
|
365
362
|
};
|
|
366
363
|
// Lighten/Darken a color by a given percentage using d3-scale
|
|
367
364
|
_this._adjustColor = function (color, percentage, lightenColor, isDarkTheme) {
|
|
@@ -369,48 +366,71 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
369
366
|
var colorInterpolator = (0, d3_scale_1.scaleLinear)().domain([0, 1]).range([color, targetColor]);
|
|
370
367
|
return (0, d3_color_1.rgb)(colorInterpolator(percentage)).formatRgb();
|
|
371
368
|
};
|
|
372
|
-
_this.
|
|
369
|
+
_this._prepareChartData = function () {
|
|
373
370
|
var _a;
|
|
371
|
+
var _b, _c;
|
|
372
|
+
var barData = _this.props.data;
|
|
373
|
+
var lineData;
|
|
374
|
+
if (Array.isArray(_this.props.dataV2) && _this.props.dataV2.length > 0) {
|
|
375
|
+
(_a = _this._processDataV2(_this.props.dataV2), barData = _a.barData, lineData = _a.lineData);
|
|
376
|
+
}
|
|
374
377
|
_this._legendColorMap = {};
|
|
375
378
|
var colorIndex = 0;
|
|
376
|
-
return
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
if (
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
379
|
+
return {
|
|
380
|
+
barData: (_b = barData === null || barData === void 0 ? void 0 : barData.map(function (point) {
|
|
381
|
+
var _a, _b;
|
|
382
|
+
return tslib_1.__assign(tslib_1.__assign({}, point), { series: (_b = (_a = point.series) === null || _a === void 0 ? void 0 : _a.map(function (seriesPoint) {
|
|
383
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
384
|
+
var startColor = seriesPoint.color
|
|
385
|
+
? seriesPoint.color
|
|
386
|
+
: (0, index_1.getNextColor)(colorIndex, 0, (_a = _this.props.theme) === null || _a === void 0 ? void 0 : _a.isInverted);
|
|
387
|
+
var endColor = startColor;
|
|
388
|
+
if (_this.props.enableGradient) {
|
|
389
|
+
if (seriesPoint.color) {
|
|
390
|
+
// Generate gradient colors based on seriesPoint.color
|
|
391
|
+
startColor = _this._adjustColor(seriesPoint.color || endColor, 0.2, false, (_b = _this.props.theme) === null || _b === void 0 ? void 0 : _b.isInverted);
|
|
392
|
+
endColor = _this._adjustColor(seriesPoint.color || startColor, 0.2, true, (_c = _this.props.theme) === null || _c === void 0 ? void 0 : _c.isInverted);
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
var nextGradient = (0, index_1.getNextGradient)(colorIndex, 0, (_d = _this.props.theme) === null || _d === void 0 ? void 0 : _d.isInverted);
|
|
396
|
+
startColor = ((_e = seriesPoint.gradient) === null || _e === void 0 ? void 0 : _e[0]) || nextGradient[0];
|
|
397
|
+
endColor = ((_f = seriesPoint.gradient) === null || _f === void 0 ? void 0 : _f[1]) || nextGradient[1];
|
|
398
|
+
}
|
|
389
399
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
endColor = ((_f = seriesPoint.gradient) === null || _f === void 0 ? void 0 : _f[1]) || nextGradient[1];
|
|
400
|
+
var pointGradient = [startColor, endColor];
|
|
401
|
+
if (!_this._legendColorMap[seriesPoint.legend]) {
|
|
402
|
+
_this._legendColorMap[seriesPoint.legend] = [startColor, endColor];
|
|
394
403
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
+
colorIndex += 1;
|
|
405
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, seriesPoint), { color: (_g = seriesPoint.color) !== null && _g !== void 0 ? _g : _this._legendColorMap[seriesPoint.legend][0] }), (_this.props.enableGradient ? { gradient: pointGradient } : {}));
|
|
406
|
+
})) !== null && _b !== void 0 ? _b : [] });
|
|
407
|
+
})) !== null && _b !== void 0 ? _b : [],
|
|
408
|
+
lineData: (_c = lineData === null || lineData === void 0 ? void 0 : lineData.map(function (series) {
|
|
409
|
+
var _a, _b;
|
|
410
|
+
var color;
|
|
411
|
+
if (typeof series.color === 'undefined') {
|
|
412
|
+
color = (0, index_1.getNextColor)(colorIndex, 0, (_a = _this.props.theme) === null || _a === void 0 ? void 0 : _a.isInverted);
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
color = (0, index_1.getColorFromToken)(series.color, (_b = _this.props.theme) === null || _b === void 0 ? void 0 : _b.isInverted);
|
|
416
|
+
}
|
|
417
|
+
if (!_this._legendColorMap[series.legend]) {
|
|
418
|
+
_this._legendColorMap[series.legend] = [color, color];
|
|
419
|
+
}
|
|
420
|
+
colorIndex += 1;
|
|
421
|
+
return tslib_1.__assign(tslib_1.__assign({}, series), { color: _this._legendColorMap[series.legend][0] });
|
|
422
|
+
})) !== null && _c !== void 0 ? _c : [],
|
|
423
|
+
};
|
|
404
424
|
};
|
|
405
|
-
_this._getOrderedXAxisLabels = function (
|
|
425
|
+
_this._getOrderedXAxisLabels = function (barData, lineData) {
|
|
406
426
|
if (_this._xAxisType !== index_1.XAxisTypes.StringAxis) {
|
|
407
427
|
return [];
|
|
408
428
|
}
|
|
409
|
-
return (0, index_1.sortAxisCategories)(_this._mapCategoryToValues(
|
|
429
|
+
return (0, index_1.sortAxisCategories)(_this._mapCategoryToValues(barData, lineData), _this.props.xAxisCategoryOrder);
|
|
410
430
|
};
|
|
411
|
-
_this._mapCategoryToValues = function (
|
|
431
|
+
_this._mapCategoryToValues = function (barData, lineData) {
|
|
412
432
|
var categoryToValues = {};
|
|
413
|
-
|
|
433
|
+
barData.forEach(function (point) {
|
|
414
434
|
if (!categoryToValues[point.name]) {
|
|
415
435
|
categoryToValues[point.name] = [];
|
|
416
436
|
}
|
|
@@ -418,10 +438,143 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
418
438
|
categoryToValues[point.name].push(seriesPoint.data);
|
|
419
439
|
});
|
|
420
440
|
});
|
|
441
|
+
lineData.forEach(function (series) {
|
|
442
|
+
series.data.forEach(function (point) {
|
|
443
|
+
if (!categoryToValues[point.x]) {
|
|
444
|
+
categoryToValues[point.x] = [];
|
|
445
|
+
}
|
|
446
|
+
categoryToValues[point.x].push(point.y);
|
|
447
|
+
});
|
|
448
|
+
});
|
|
421
449
|
return categoryToValues;
|
|
422
450
|
};
|
|
451
|
+
_this._createLines = function (lineData, xScale, yScalePrimary, yScaleSecondary) {
|
|
452
|
+
var lineBorders = [];
|
|
453
|
+
var lines = [];
|
|
454
|
+
var dots = [];
|
|
455
|
+
var scaleLineX = function (x) { return xScale(x) + xScale.bandwidth() / 2; };
|
|
456
|
+
lineData.forEach(function (series, seriesIdx) {
|
|
457
|
+
var _a;
|
|
458
|
+
var lineBorderGroup = [];
|
|
459
|
+
var lineGroup = [];
|
|
460
|
+
var dotGroup = [];
|
|
461
|
+
var lineBorderWidth = ((_a = series.lineOptions) === null || _a === void 0 ? void 0 : _a.lineBorderWidth)
|
|
462
|
+
? Number.parseFloat(series.lineOptions.lineBorderWidth.toString())
|
|
463
|
+
: 0;
|
|
464
|
+
var yScale = series.useSecondaryYScale && yScaleSecondary ? yScaleSecondary : yScalePrimary;
|
|
465
|
+
var shouldHighlight = _this._legendHighlighted(series.legend) || _this._noLegendHighlighted();
|
|
466
|
+
series.data.forEach(function (point, pointIdx) {
|
|
467
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
468
|
+
var x2 = scaleLineX(point.x);
|
|
469
|
+
var y2 = yScale(point.y);
|
|
470
|
+
if (pointIdx > 0) {
|
|
471
|
+
var x1 = scaleLineX(series.data[pointIdx - 1].x);
|
|
472
|
+
var y1 = yScale(series.data[pointIdx - 1].y);
|
|
473
|
+
if (lineBorderWidth > 0) {
|
|
474
|
+
lineBorderGroup.push(React.createElement("line", { key: "lineBorder-".concat(seriesIdx, "-").concat(pointIdx), x1: x1, y1: y1, x2: x2, y2: y2, fill: "transparent", stroke: (_b = (_a = series.lineOptions) === null || _a === void 0 ? void 0 : _a.lineBorderColor) !== null && _b !== void 0 ? _b : _this.props.theme.semanticColors.bodyBackground, strokeWidth: 3 + lineBorderWidth * 2, strokeLinecap: "round", opacity: shouldHighlight ? 1 : 0.1 }));
|
|
475
|
+
}
|
|
476
|
+
lineGroup.push(React.createElement("line", { key: "line-".concat(seriesIdx, "-").concat(pointIdx), x1: x1, y1: y1, x2: x2, y2: y2, stroke: series.color, strokeWidth: (_d = (_c = series.lineOptions) === null || _c === void 0 ? void 0 : _c.strokeWidth) !== null && _d !== void 0 ? _d : 3, strokeLinecap: (_f = (_e = series.lineOptions) === null || _e === void 0 ? void 0 : _e.strokeLinecap) !== null && _f !== void 0 ? _f : 'round', strokeDasharray: (_g = series.lineOptions) === null || _g === void 0 ? void 0 : _g.strokeDasharray, opacity: shouldHighlight ? 1 : 0.1, onMouseOver: function (e) { return _this._onLineHover(e, series, seriesIdx, pointIdx, scaleLineX); }, onMouseLeave: _this._onBarLeave }));
|
|
477
|
+
}
|
|
478
|
+
var dotId = _this._getDotId(seriesIdx, pointIdx);
|
|
479
|
+
var activeLinePoint = _this.state.activeLinePoint;
|
|
480
|
+
var isLinePointActive = activeLinePoint === point.x || activeLinePoint === dotId;
|
|
481
|
+
dotGroup.push(React.createElement("circle", { key: dotId, id: dotId, cx: x2, cy: y2, r: shouldHighlight && isLinePointActive ? 8 : 0.3, fill: _this.props.theme.semanticColors.bodyBackground, stroke: series.color, strokeWidth: 3, opacity: shouldHighlight ? 1 : 0.1, onMouseOver: function (e) { return _this._onLineHover(e, series, seriesIdx, pointIdx, scaleLineX); }, onMouseLeave: _this._onBarLeave, "data-is-focusable": shouldHighlight, onFocus: function (e) { return _this._onLineFocus(e, series, seriesIdx, pointIdx); }, onBlur: _this._onBarLeave, role: "img", "aria-label": _this._getAriaLabel({
|
|
482
|
+
xAxisCalloutData: point.xAxisCalloutData,
|
|
483
|
+
legend: series.legend,
|
|
484
|
+
yAxisCalloutData: point.yAxisCalloutData,
|
|
485
|
+
data: point.y,
|
|
486
|
+
callOutAccessibilityData: point.callOutAccessibilityData,
|
|
487
|
+
}, point.x) }));
|
|
488
|
+
});
|
|
489
|
+
lineBorders.push(React.createElement("g", { key: "lineBorderGroup-".concat(seriesIdx) }, lineBorderGroup));
|
|
490
|
+
lines.push(React.createElement("g", { key: "lineGroup-".concat(seriesIdx) }, lineGroup));
|
|
491
|
+
dots.push(React.createElement("g", { key: "dotGroup-".concat(seriesIdx) }, dotGroup));
|
|
492
|
+
});
|
|
493
|
+
return dots.length > 0 ? (React.createElement("g", null,
|
|
494
|
+
lineBorders.length > 0 ? React.createElement("g", null, lineBorders) : null,
|
|
495
|
+
lines.length > 0 ? React.createElement("g", null, lines) : null,
|
|
496
|
+
React.createElement("g", null, dots))) : null;
|
|
497
|
+
};
|
|
498
|
+
_this._onLineHover = function (event, series, seriesIdx, pointIdx, scaleLineX) {
|
|
499
|
+
var pointerX = (0, d3_selection_1.pointer)(event, _this._rectRef.current)[0];
|
|
500
|
+
var closestPointIdx = pointIdx;
|
|
501
|
+
if (pointIdx > 0) {
|
|
502
|
+
var currPointPos = scaleLineX(series.data[pointIdx].x);
|
|
503
|
+
var prevPointPos = scaleLineX(series.data[pointIdx - 1].x);
|
|
504
|
+
if (Math.abs(prevPointPos - pointerX) < Math.abs(currPointPos - pointerX)) {
|
|
505
|
+
closestPointIdx = pointIdx - 1;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
event.persist();
|
|
509
|
+
_this._showCalloutForLines(event, series, seriesIdx, closestPointIdx);
|
|
510
|
+
};
|
|
511
|
+
_this._onLineFocus = function (event, series, seriesIdx, pointIdx) {
|
|
512
|
+
_this._showCalloutForLines(event.currentTarget, series, seriesIdx, pointIdx);
|
|
513
|
+
};
|
|
514
|
+
_this._showCalloutForLines = function (target, series, seriesIdx, pointIdx) {
|
|
515
|
+
var point = series.data[pointIdx];
|
|
516
|
+
var pointData = tslib_1.__assign(tslib_1.__assign({}, point), { legend: series.legend, color: series.color, key: series.legend, data: point.y, yAxisCalloutData: point.yAxisCalloutData });
|
|
517
|
+
var groupData = _this._datasetForBars.find(function (singleSet) { return singleSet.xAxisPoint === point.x; });
|
|
518
|
+
_this._showCallout(target, pointData, groupData, _this._getDotId(seriesIdx, pointIdx));
|
|
519
|
+
};
|
|
520
|
+
_this._showCallout = function (target, pointData,
|
|
521
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
522
|
+
groupData, activeLinePoint) {
|
|
523
|
+
var _a, _b;
|
|
524
|
+
if (activeLinePoint === void 0) { activeLinePoint = ''; }
|
|
525
|
+
_this.setState({
|
|
526
|
+
refSelected: target,
|
|
527
|
+
isCalloutVisible: _this._noLegendHighlighted() || _this._legendHighlighted(pointData.legend),
|
|
528
|
+
calloutLegend: pointData.legend,
|
|
529
|
+
dataForHoverCard: pointData.data,
|
|
530
|
+
color: pointData.color,
|
|
531
|
+
xCalloutValue: (_a = pointData.xAxisCalloutData) !== null && _a !== void 0 ? _a : groupData.xAxisPoint,
|
|
532
|
+
yCalloutValue: pointData.yAxisCalloutData,
|
|
533
|
+
dataPointCalloutProps: pointData,
|
|
534
|
+
callOutAccessibilityData: _this.props.isCalloutForStack
|
|
535
|
+
? groupData.stackCallOutAccessibilityData
|
|
536
|
+
: pointData.callOutAccessibilityData,
|
|
537
|
+
YValueHover: groupData.groupSeries.filter(function (item) { return _this._noLegendHighlighted() || _this._legendHighlighted(item.legend); }),
|
|
538
|
+
hoverXValue: (_b = pointData.xAxisCalloutData) !== null && _b !== void 0 ? _b : groupData.xAxisPoint,
|
|
539
|
+
activeLinePoint: _this.props.isCalloutForStack ? groupData.xAxisPoint : activeLinePoint,
|
|
540
|
+
});
|
|
541
|
+
};
|
|
542
|
+
_this._getDotId = function (seriesIdx, pointIdx) {
|
|
543
|
+
return _this._uniqDotId + "-".concat(seriesIdx, "-").concat(pointIdx);
|
|
544
|
+
};
|
|
545
|
+
_this._processDataV2 = function (dataV2) {
|
|
546
|
+
var barPointsByX = {};
|
|
547
|
+
var lineData = [];
|
|
548
|
+
dataV2.forEach(function (series) {
|
|
549
|
+
if (series.type === 'bar') {
|
|
550
|
+
series.data.forEach(function (point) {
|
|
551
|
+
var _a, _b;
|
|
552
|
+
if (!barPointsByX[point.x]) {
|
|
553
|
+
barPointsByX[point.x] = { name: point.x, series: [] };
|
|
554
|
+
}
|
|
555
|
+
barPointsByX[point.x].series.push({
|
|
556
|
+
key: (_a = series.key) !== null && _a !== void 0 ? _a : series.legend,
|
|
557
|
+
data: point.y,
|
|
558
|
+
color: (_b = point.color) !== null && _b !== void 0 ? _b : series.color,
|
|
559
|
+
gradient: series.gradient,
|
|
560
|
+
legend: series.legend,
|
|
561
|
+
xAxisCalloutData: point.xAxisCalloutData,
|
|
562
|
+
yAxisCalloutData: point.yAxisCalloutData,
|
|
563
|
+
onClick: point.onClick,
|
|
564
|
+
useSecondaryYScale: series.useSecondaryYScale,
|
|
565
|
+
});
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
else if (series.type === 'line') {
|
|
569
|
+
lineData.push(series);
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
return { barData: Object.values(barPointsByX), lineData: lineData };
|
|
573
|
+
};
|
|
423
574
|
(0, Utilities_1.initializeComponentRef)(_this);
|
|
424
|
-
_this._createSet = (0, Utilities_1.memoizeFunction)(function (
|
|
575
|
+
_this._createSet = (0, Utilities_1.memoizeFunction)(function (barData, lineData) {
|
|
576
|
+
return _this._createDataSetOfGVBC(barData, lineData);
|
|
577
|
+
});
|
|
425
578
|
_this.state = {
|
|
426
579
|
color: '',
|
|
427
580
|
dataForHoverCard: 0,
|
|
@@ -434,6 +587,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
434
587
|
hoverXValue: '',
|
|
435
588
|
calloutLegend: '',
|
|
436
589
|
activeLegend: '',
|
|
590
|
+
activeLinePoint: '',
|
|
437
591
|
};
|
|
438
592
|
(0, Utilities_1.warnDeprecations)(COMPONENT_NAME, props, {
|
|
439
593
|
showYAxisGridLines: 'Dont use this property. Lines are drawn by default',
|
|
@@ -448,6 +602,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
448
602
|
_this._domainMargin = MIN_DOMAIN_MARGIN;
|
|
449
603
|
_this._cartesianChartRef = React.createRef();
|
|
450
604
|
_this._legendsRef = React.createRef();
|
|
605
|
+
_this._rectRef = React.createRef();
|
|
451
606
|
return _this;
|
|
452
607
|
}
|
|
453
608
|
GroupedVerticalBarChartBase.prototype.componentDidUpdate = function (prevProps) {
|
|
@@ -460,10 +615,11 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
460
615
|
};
|
|
461
616
|
GroupedVerticalBarChartBase.prototype.render = function () {
|
|
462
617
|
var _this = this;
|
|
463
|
-
var
|
|
464
|
-
this._xAxisType = (0, index_1.getTypeOfAxis)(
|
|
465
|
-
var
|
|
466
|
-
this.
|
|
618
|
+
var _a = this._prepareChartData(), barData = _a.barData, lineData = _a.lineData;
|
|
619
|
+
this._xAxisType = (0, index_1.getTypeOfAxis)(barData[0].name, true);
|
|
620
|
+
var _b = this._createSet(barData, lineData), barLegends = _b.barLegends, lineLegends = _b.lineLegends, xAxisLabels = _b.xAxisLabels, datasetForBars = _b.datasetForBars;
|
|
621
|
+
this._barLegends = barLegends;
|
|
622
|
+
this._lineLegends = lineLegends;
|
|
467
623
|
this._xAxisLabels = xAxisLabels;
|
|
468
624
|
this._datasetForBars = datasetForBars;
|
|
469
625
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
@@ -483,15 +639,18 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
483
639
|
tickValues: this.props.tickValues,
|
|
484
640
|
tickFormat: this.props.tickFormat,
|
|
485
641
|
};
|
|
486
|
-
return !this._isChartEmpty() ? (React.createElement(index_2.CartesianChart, tslib_1.__assign({}, this.props, { chartTitle: this._getChartTitle(), points: this._datasetForBars, chartType: index_1.ChartTypes.GroupedVerticalBarChart, calloutProps: calloutProps, legendBars: legendBars, xAxisType: this._xAxisType, createYAxis: index_1.createNumericYAxis, datasetForXAxisDomain: this._xAxisLabels, tickParams: tickParams, getDomainNRangeValues: this._getDomainNRangeValues, getMinMaxOfYAxis: this._getMinMaxOfYAxis, createStringYAxis: index_1.createStringYAxis, tickPadding: this.props.tickPadding || 5, maxOfYVal: this._yMax, svgFocusZoneProps: {
|
|
642
|
+
return !this._isChartEmpty(barData, lineData) ? (React.createElement(index_2.CartesianChart, tslib_1.__assign({}, this.props, { chartTitle: this._getChartTitle(), points: this._datasetForBars, chartType: index_1.ChartTypes.GroupedVerticalBarChart, calloutProps: calloutProps, legendBars: legendBars, xAxisType: this._xAxisType, createYAxis: index_1.createNumericYAxis, datasetForXAxisDomain: this._xAxisLabels, tickParams: tickParams, getDomainNRangeValues: this._getDomainNRangeValues, getMinMaxOfYAxis: this._getMinMaxOfYAxis, createStringYAxis: index_1.createStringYAxis, tickPadding: this.props.tickPadding || 5, maxOfYVal: this._yMax, svgFocusZoneProps: {
|
|
487
643
|
direction: react_focus_1.FocusZoneDirection.horizontal,
|
|
488
644
|
}, customizedCallout: this._getCustomizedCallout(), getmargins: this._getMargins, getGraphData: this._getGraphData, getAxisData: this._getAxisData, onChartMouseLeave: this._handleChartMouseLeave, getDomainMargins: this._getDomainMargins }, (this._xAxisType === index_1.XAxisTypes.StringAxis && {
|
|
489
645
|
xAxisInnerPadding: this._xAxisInnerPadding,
|
|
490
646
|
xAxisOuterPadding: this._xAxisOuterPadding,
|
|
491
647
|
}), { barwidth: this._barWidth, ref: this._cartesianChartRef,
|
|
492
648
|
/* eslint-disable react/jsx-no-bind */
|
|
493
|
-
children: function () {
|
|
494
|
-
return React.createElement(
|
|
649
|
+
children: function (props) {
|
|
650
|
+
return (React.createElement(React.Fragment, null,
|
|
651
|
+
React.createElement("rect", { ref: _this._rectRef, width: "100%", height: "100%", fill: "transparent", style: { pointerEvents: 'none' } }),
|
|
652
|
+
React.createElement("g", null, _this._groupedVerticalBarGraph),
|
|
653
|
+
_this._createLines(lineData, props.xScale, props.yScalePrimary, props.yScaleSecondary)));
|
|
495
654
|
} }))) : (React.createElement("div", { id: this._emptyChartId, role: 'alert', style: { opacity: '0' }, "aria-label": 'Graph has no data to display' }));
|
|
496
655
|
};
|
|
497
656
|
Object.defineProperty(GroupedVerticalBarChartBase.prototype, "chartContainer", {
|
|
@@ -531,17 +690,18 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
531
690
|
? [this.state.activeLegend]
|
|
532
691
|
: [];
|
|
533
692
|
};
|
|
534
|
-
GroupedVerticalBarChartBase.prototype._isChartEmpty = function () {
|
|
535
|
-
return !(
|
|
536
|
-
|
|
537
|
-
|
|
693
|
+
GroupedVerticalBarChartBase.prototype._isChartEmpty = function (barData, lineData) {
|
|
694
|
+
return !((barData &&
|
|
695
|
+
barData.length > 0 &&
|
|
696
|
+
barData.filter(function (item) { return item.series.length; }).length > 0) ||
|
|
697
|
+
(lineData && lineData.length > 0 && lineData.some(function (series) { return series.data.length > 0; })));
|
|
538
698
|
};
|
|
539
699
|
GroupedVerticalBarChartBase.prototype._adjustProps = function () {
|
|
540
700
|
this._barWidth = (0, index_1.getBarWidth)(this.props.barwidth, this.props.maxBarWidth);
|
|
541
701
|
// x0_inner_padding = space_between_groups / (space_between_groups + group_width)
|
|
542
702
|
// space_between_groups = 2 * bar_width
|
|
543
703
|
// group_width = this._legends.length * bar_width + (this._legends.length - 1) * space_between_bars
|
|
544
|
-
this._xAxisInnerPadding = (0, index_1.getScalePadding)(this.props.xAxisInnerPadding, undefined, 2 / (2 + (0, index_1.calcTotalBandUnits)(this.
|
|
704
|
+
this._xAxisInnerPadding = (0, index_1.getScalePadding)(this.props.xAxisInnerPadding, undefined, 2 / (2 + (0, index_1.calcTotalBandUnits)(this._barLegends.length, X1_INNER_PADDING)));
|
|
545
705
|
this._xAxisOuterPadding = (0, index_1.getScalePadding)(this.props.xAxisOuterPadding);
|
|
546
706
|
};
|
|
547
707
|
GroupedVerticalBarChartBase.defaultProps = {
|