@fluentui/react-charting 5.24.31 → 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 +28 -1
- package/CHANGELOG.md +13 -2
- package/dist/react-charting.d.ts +131 -2
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +44 -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 +81 -43
- 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 +9 -16
- 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 +121 -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 +80 -42
- 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 +8 -15
- 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 +121 -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 +80 -42
- 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 +8 -15
- 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 +121 -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
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { __assign, __extends } from "tslib";
|
|
1
|
+
import { __assign, __extends, __spreadArray } from "tslib";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { max as d3Max, min as d3Min } from 'd3-array';
|
|
4
|
-
import { select as d3Select } from 'd3-selection';
|
|
4
|
+
import { select as d3Select, pointer as d3Pointer } from 'd3-selection';
|
|
5
5
|
import { scaleLinear as d3ScaleLinear, scaleBand as d3ScaleBand } from 'd3-scale';
|
|
6
6
|
import { classNamesFunction, getId, getRTL, initializeComponentRef, memoizeFunction, warnDeprecations, } from '@fluentui/react/lib/Utilities';
|
|
7
7
|
import { DirectionalHint } from '@fluentui/react/lib/Callout';
|
|
8
8
|
import { FocusZoneDirection } from '@fluentui/react-focus';
|
|
9
|
-
import { ChartTypes, getAccessibleDataObject, tooltipOfAxislabels, XAxisTypes, getTypeOfAxis, formatScientificLimitWidth, getScalePadding, getBarWidth, isScalePaddingDefined, createNumericYAxis, domainRangeOfXStringAxis, createStringYAxis, getNextGradient, getNextColor, areArraysEqual, calculateLongestLabelWidth, sortAxisCategories, calcTotalWidth, calcBandwidth, calcTotalBandUnits, calcRequiredWidth, } from '../../utilities/index';
|
|
9
|
+
import { ChartTypes, getAccessibleDataObject, tooltipOfAxislabels, XAxisTypes, getTypeOfAxis, formatScientificLimitWidth, getScalePadding, getBarWidth, isScalePaddingDefined, createNumericYAxis, domainRangeOfXStringAxis, createStringYAxis, getNextGradient, getNextColor, areArraysEqual, calculateLongestLabelWidth, sortAxisCategories, calcTotalWidth, calcBandwidth, calcTotalBandUnits, calcRequiredWidth, getColorFromToken, } from '../../utilities/index';
|
|
10
10
|
import { CartesianChart, Legends, } from '../../index';
|
|
11
11
|
import { toImage } from '../../utilities/image-export-utils';
|
|
12
12
|
import { rgb } from 'd3-color';
|
|
@@ -24,6 +24,7 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
24
24
|
_this._isRtl = getRTL();
|
|
25
25
|
_this._legendColorMap = {};
|
|
26
26
|
_this.Y_ORIGIN = 0;
|
|
27
|
+
_this._uniqDotId = getId('gvbc_dot_');
|
|
27
28
|
_this.toImage = function (opts) {
|
|
28
29
|
var _a, _b;
|
|
29
30
|
return 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);
|
|
@@ -55,8 +56,8 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
55
56
|
var xScale0 = _this._createX0Scale(containerWidth);
|
|
56
57
|
// Setting the bar width here is safe because there are no dependencies earlier in the code
|
|
57
58
|
// that rely on the width of bars in vertical bar charts with string x-axis.
|
|
58
|
-
_this._barWidth = getBarWidth(_this.props.barwidth, _this.props.maxBarWidth, calcBandwidth(xScale0.bandwidth(), _this.
|
|
59
|
-
_this._groupWidth = calcRequiredWidth(_this._barWidth, _this.
|
|
59
|
+
_this._barWidth = getBarWidth(_this.props.barwidth, _this.props.maxBarWidth, calcBandwidth(xScale0.bandwidth(), _this._barLegends.length, X1_INNER_PADDING));
|
|
60
|
+
_this._groupWidth = calcRequiredWidth(_this._barWidth, _this._barLegends.length, X1_INNER_PADDING);
|
|
60
61
|
var xScale1 = _this._createX1Scale();
|
|
61
62
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
62
63
|
var allGroupsBars = [];
|
|
@@ -66,17 +67,19 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
66
67
|
_this._groupedVerticalBarGraph = allGroupsBars;
|
|
67
68
|
};
|
|
68
69
|
_this._getMargins = function (margins) { return (_this.margins = margins); };
|
|
69
|
-
_this._createDataSetOfGVBC = function (
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
-
points.forEach(function (point) {
|
|
70
|
+
_this._createDataSetOfGVBC = function (barData, lineData) {
|
|
71
|
+
var barLegends = new Set();
|
|
72
|
+
barData.forEach(function (point) {
|
|
73
73
|
point.series.forEach(function (seriesPoint) {
|
|
74
|
-
|
|
74
|
+
barLegends.add(seriesPoint.legend);
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
|
-
var
|
|
77
|
+
var lineLegends = new Set(lineData.map(function (series) { return series.legend; }));
|
|
78
|
+
var xAxisLabels = _this._getOrderedXAxisLabels(barData, lineData);
|
|
79
|
+
var datasetForBars = _this._createDataset(barData, lineData);
|
|
78
80
|
return {
|
|
79
|
-
|
|
81
|
+
barLegends: Array.from(barLegends),
|
|
82
|
+
lineLegends: Array.from(lineLegends),
|
|
80
83
|
xAxisLabels: xAxisLabels,
|
|
81
84
|
datasetForBars: datasetForBars,
|
|
82
85
|
};
|
|
@@ -92,22 +95,7 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
92
95
|
mouseEvent.persist();
|
|
93
96
|
if (_this._calloutAnchorPoint !== pointData) {
|
|
94
97
|
_this._calloutAnchorPoint = pointData;
|
|
95
|
-
_this.
|
|
96
|
-
refSelected: mouseEvent,
|
|
97
|
-
/** Show the callout if highlighted bar is hovered and Hide it if unhighlighted bar is hovered */
|
|
98
|
-
isCalloutVisible: _this._noLegendHighlighted() || _this._legendHighlighted(pointData.legend),
|
|
99
|
-
calloutLegend: pointData.legend,
|
|
100
|
-
dataForHoverCard: pointData.data,
|
|
101
|
-
color: pointData.color,
|
|
102
|
-
xCalloutValue: pointData.xAxisCalloutData,
|
|
103
|
-
yCalloutValue: pointData.yAxisCalloutData,
|
|
104
|
-
dataPointCalloutProps: pointData,
|
|
105
|
-
callOutAccessibilityData: _this.props.isCalloutForStack
|
|
106
|
-
? groupData.stackCallOutAccessibilityData
|
|
107
|
-
: pointData.callOutAccessibilityData,
|
|
108
|
-
YValueHover: groupData.groupSeries,
|
|
109
|
-
hoverXValue: pointData.xAxisCalloutData,
|
|
110
|
-
});
|
|
98
|
+
_this._showCallout(mouseEvent, pointData, groupData);
|
|
111
99
|
}
|
|
112
100
|
};
|
|
113
101
|
_this._onBarLeave = function () {
|
|
@@ -120,22 +108,7 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
120
108
|
_this._onBarFocus = function (pointData,
|
|
121
109
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
122
110
|
groupData, focusEvent) {
|
|
123
|
-
_this.
|
|
124
|
-
refSelected: focusEvent.currentTarget,
|
|
125
|
-
/** Show the callout if highlighted bar is focused and Hide it if unhighlighted bar is focused */
|
|
126
|
-
isCalloutVisible: _this._noLegendHighlighted() || _this._legendHighlighted(pointData.legend),
|
|
127
|
-
calloutLegend: pointData.legend,
|
|
128
|
-
dataForHoverCard: pointData.data,
|
|
129
|
-
color: pointData.color,
|
|
130
|
-
xCalloutValue: pointData.xAxisCalloutData,
|
|
131
|
-
yCalloutValue: pointData.yAxisCalloutData,
|
|
132
|
-
dataPointCalloutProps: pointData,
|
|
133
|
-
callOutAccessibilityData: _this.props.isCalloutForStack
|
|
134
|
-
? groupData.stackCallOutAccessibilityData
|
|
135
|
-
: pointData.callOutAccessibilityData,
|
|
136
|
-
YValueHover: groupData.groupSeries,
|
|
137
|
-
hoverXValue: pointData.xAxisCalloutData,
|
|
138
|
-
});
|
|
111
|
+
_this._showCallout(focusEvent.currentTarget, pointData, groupData);
|
|
139
112
|
};
|
|
140
113
|
_this._redirectToUrl = function (href) {
|
|
141
114
|
href ? (window.location.href = href) : '';
|
|
@@ -152,7 +125,7 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
152
125
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
153
126
|
var barLabelsForGroup = [];
|
|
154
127
|
// Get the actual legends present at this x-axis point
|
|
155
|
-
var presentLegends =
|
|
128
|
+
var presentLegends = _this._barLegends.filter(function (key) { return key in singleSet; });
|
|
156
129
|
var effectiveGroupWidth = calcRequiredWidth(_this._barWidth, presentLegends.length, X1_INNER_PADDING);
|
|
157
130
|
// For stacked bars, center the single bar group in the available space
|
|
158
131
|
// Instead of using the global legend position, use the local position within present legends
|
|
@@ -160,7 +133,7 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
160
133
|
.domain(presentLegends)
|
|
161
134
|
.range(_this._isRtl ? [effectiveGroupWidth, 0] : [0, effectiveGroupWidth])
|
|
162
135
|
.paddingInner(X1_INNER_PADDING);
|
|
163
|
-
_this.
|
|
136
|
+
_this._barLegends.forEach(function (legendTitle, legendIndex) {
|
|
164
137
|
var _a;
|
|
165
138
|
var barPoints = singleSet[legendTitle];
|
|
166
139
|
if (barPoints) {
|
|
@@ -228,10 +201,21 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
228
201
|
singleGroup,
|
|
229
202
|
barLabelsForGroup));
|
|
230
203
|
};
|
|
231
|
-
_this._createDataset = function (
|
|
204
|
+
_this._createDataset = function (barData, lineData) {
|
|
232
205
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
233
206
|
var datasetForBars = [];
|
|
234
|
-
|
|
207
|
+
var linePointsByX = {};
|
|
208
|
+
var visitedX = new Set();
|
|
209
|
+
lineData.forEach(function (series) {
|
|
210
|
+
series.data.forEach(function (point) {
|
|
211
|
+
if (!linePointsByX[point.x]) {
|
|
212
|
+
linePointsByX[point.x] = [];
|
|
213
|
+
}
|
|
214
|
+
linePointsByX[point.x].push(__assign(__assign({}, point), { legend: series.legend, color: series.color, data: point.y, useSecondaryYScale: series.useSecondaryYScale }));
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
barData.forEach(function (point, index) {
|
|
218
|
+
var _a;
|
|
235
219
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
236
220
|
var singleDatasetPointForBars = {};
|
|
237
221
|
var legendToBarPoint = {};
|
|
@@ -247,9 +231,18 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
247
231
|
});
|
|
248
232
|
singleDatasetPointForBars.xAxisPoint = point.name;
|
|
249
233
|
singleDatasetPointForBars.indexNum = index;
|
|
250
|
-
singleDatasetPointForBars.groupSeries = Object.values(legendToBarPoint);
|
|
234
|
+
singleDatasetPointForBars.groupSeries = __spreadArray(__spreadArray([], Object.values(legendToBarPoint), true), ((_a = linePointsByX[point.name]) !== null && _a !== void 0 ? _a : []), true);
|
|
251
235
|
singleDatasetPointForBars.stackCallOutAccessibilityData = point.stackCallOutAccessibilityData;
|
|
252
236
|
datasetForBars.push(singleDatasetPointForBars);
|
|
237
|
+
visitedX.add(point.name);
|
|
238
|
+
});
|
|
239
|
+
Object.keys(linePointsByX).forEach(function (xPoint) {
|
|
240
|
+
if (!visitedX.has(xPoint)) {
|
|
241
|
+
datasetForBars.push({
|
|
242
|
+
xAxisPoint: xPoint,
|
|
243
|
+
groupSeries: linePointsByX[xPoint],
|
|
244
|
+
});
|
|
245
|
+
}
|
|
253
246
|
});
|
|
254
247
|
return datasetForBars;
|
|
255
248
|
};
|
|
@@ -268,7 +261,7 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
268
261
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
269
262
|
_this._createX1Scale = function () {
|
|
270
263
|
return (d3ScaleBand()
|
|
271
|
-
.domain(_this.
|
|
264
|
+
.domain(_this._barLegends)
|
|
272
265
|
// When there is only one group, xScale0 adds padding around it,
|
|
273
266
|
// causing the bandwidth to become smaller than the actual group width.
|
|
274
267
|
// So to render bars in the group correctly, use groupWidth instead of the generated scale bandwidth.
|
|
@@ -283,10 +276,11 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
283
276
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
284
277
|
_this._getLegendData = function () {
|
|
285
278
|
var actions = [];
|
|
286
|
-
|
|
279
|
+
var addLegendButton = function (legendTitle, isLineLegendInBarChart) {
|
|
287
280
|
var legend = {
|
|
288
281
|
title: legendTitle,
|
|
289
282
|
color: _this._legendColorMap[legendTitle][0],
|
|
283
|
+
isLineLegendInBarChart: isLineLegendInBarChart,
|
|
290
284
|
hoverAction: function () {
|
|
291
285
|
_this._handleChartMouseLeave();
|
|
292
286
|
_this._onLegendHover(legendTitle);
|
|
@@ -296,7 +290,9 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
296
290
|
},
|
|
297
291
|
};
|
|
298
292
|
actions.push(legend);
|
|
299
|
-
}
|
|
293
|
+
};
|
|
294
|
+
_this._lineLegends.forEach(function (legendTitle) { return addLegendButton(legendTitle, true); });
|
|
295
|
+
_this._barLegends.forEach(function (legendTitle) { return addLegendButton(legendTitle); });
|
|
300
296
|
return (React.createElement(Legends, __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 })));
|
|
301
297
|
};
|
|
302
298
|
_this._getAxisData = function (yAxisData) {
|
|
@@ -341,7 +337,7 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
341
337
|
// Update the bar width so that when CartesianChart rerenders,
|
|
342
338
|
// the following calculations don't use the previous bar width.
|
|
343
339
|
_this._barWidth = getBarWidth(_this.props.barwidth, _this.props.maxBarWidth);
|
|
344
|
-
var groupWidth = calcRequiredWidth(_this._barWidth, _this.
|
|
340
|
+
var groupWidth = calcRequiredWidth(_this._barWidth, _this._barLegends.length, X1_INNER_PADDING);
|
|
345
341
|
/** Total width required to render the groups. Directly proportional to group width */
|
|
346
342
|
var reqWidth = calcRequiredWidth(groupWidth, _this._xAxisLabels.length, _this._xAxisInnerPadding);
|
|
347
343
|
if (totalWidth >= reqWidth) {
|
|
@@ -352,9 +348,9 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
352
348
|
else if (_this.props.mode === 'plotly' && _this._xAxisLabels.length > 1) {
|
|
353
349
|
// Calculate the remaining width after rendering groups at their maximum allowable width
|
|
354
350
|
var groupBandwidth = calcBandwidth(totalWidth, _this._xAxisLabels.length, _this._xAxisInnerPadding);
|
|
355
|
-
var barBandwidth = calcBandwidth(groupBandwidth, _this.
|
|
351
|
+
var barBandwidth = calcBandwidth(groupBandwidth, _this._barLegends.length, X1_INNER_PADDING);
|
|
356
352
|
var barWidth = getBarWidth(_this.props.barwidth, _this.props.maxBarWidth, barBandwidth);
|
|
357
|
-
var groupWidth = calcRequiredWidth(barWidth, _this.
|
|
353
|
+
var groupWidth = calcRequiredWidth(barWidth, _this._barLegends.length, X1_INNER_PADDING);
|
|
358
354
|
var reqWidth = calcRequiredWidth(groupWidth, _this._xAxisLabels.length, _this._xAxisInnerPadding);
|
|
359
355
|
var margin1 = (totalWidth - reqWidth) / 2;
|
|
360
356
|
// Calculate the remaining width after accounting for the space required to render x-axis labels
|
|
@@ -369,7 +365,8 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
369
365
|
_this._getChartTitle = function () {
|
|
370
366
|
var chartTitle = _this.props.chartTitle;
|
|
371
367
|
return ((chartTitle ? "".concat(chartTitle, ". ") : '') +
|
|
372
|
-
"Vertical bar chart with ".concat(_this.
|
|
368
|
+
"Vertical bar chart with ".concat(_this._barLegends.length, " grouped bar series") +
|
|
369
|
+
(_this._lineLegends.length > 0 ? " and ".concat(_this._lineLegends.length, " line series. ") : '. '));
|
|
373
370
|
};
|
|
374
371
|
// Lighten/Darken a color by a given percentage using d3-scale
|
|
375
372
|
_this._adjustColor = function (color, percentage, lightenColor, isDarkTheme) {
|
|
@@ -377,48 +374,71 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
377
374
|
var colorInterpolator = d3ScaleLinear().domain([0, 1]).range([color, targetColor]);
|
|
378
375
|
return rgb(colorInterpolator(percentage)).formatRgb();
|
|
379
376
|
};
|
|
380
|
-
_this.
|
|
377
|
+
_this._prepareChartData = function () {
|
|
381
378
|
var _a;
|
|
379
|
+
var _b, _c;
|
|
380
|
+
var barData = _this.props.data;
|
|
381
|
+
var lineData;
|
|
382
|
+
if (Array.isArray(_this.props.dataV2) && _this.props.dataV2.length > 0) {
|
|
383
|
+
(_a = _this._processDataV2(_this.props.dataV2), barData = _a.barData, lineData = _a.lineData);
|
|
384
|
+
}
|
|
382
385
|
_this._legendColorMap = {};
|
|
383
386
|
var colorIndex = 0;
|
|
384
|
-
return
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
if (
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
387
|
+
return {
|
|
388
|
+
barData: (_b = barData === null || barData === void 0 ? void 0 : barData.map(function (point) {
|
|
389
|
+
var _a, _b;
|
|
390
|
+
return __assign(__assign({}, point), { series: (_b = (_a = point.series) === null || _a === void 0 ? void 0 : _a.map(function (seriesPoint) {
|
|
391
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
392
|
+
var startColor = seriesPoint.color
|
|
393
|
+
? seriesPoint.color
|
|
394
|
+
: getNextColor(colorIndex, 0, (_a = _this.props.theme) === null || _a === void 0 ? void 0 : _a.isInverted);
|
|
395
|
+
var endColor = startColor;
|
|
396
|
+
if (_this.props.enableGradient) {
|
|
397
|
+
if (seriesPoint.color) {
|
|
398
|
+
// Generate gradient colors based on seriesPoint.color
|
|
399
|
+
startColor = _this._adjustColor(seriesPoint.color || endColor, 0.2, false, (_b = _this.props.theme) === null || _b === void 0 ? void 0 : _b.isInverted);
|
|
400
|
+
endColor = _this._adjustColor(seriesPoint.color || startColor, 0.2, true, (_c = _this.props.theme) === null || _c === void 0 ? void 0 : _c.isInverted);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
var nextGradient = getNextGradient(colorIndex, 0, (_d = _this.props.theme) === null || _d === void 0 ? void 0 : _d.isInverted);
|
|
404
|
+
startColor = ((_e = seriesPoint.gradient) === null || _e === void 0 ? void 0 : _e[0]) || nextGradient[0];
|
|
405
|
+
endColor = ((_f = seriesPoint.gradient) === null || _f === void 0 ? void 0 : _f[1]) || nextGradient[1];
|
|
406
|
+
}
|
|
397
407
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
endColor = ((_f = seriesPoint.gradient) === null || _f === void 0 ? void 0 : _f[1]) || nextGradient[1];
|
|
408
|
+
var pointGradient = [startColor, endColor];
|
|
409
|
+
if (!_this._legendColorMap[seriesPoint.legend]) {
|
|
410
|
+
_this._legendColorMap[seriesPoint.legend] = [startColor, endColor];
|
|
402
411
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
+
colorIndex += 1;
|
|
413
|
+
return __assign(__assign(__assign({}, seriesPoint), { color: (_g = seriesPoint.color) !== null && _g !== void 0 ? _g : _this._legendColorMap[seriesPoint.legend][0] }), (_this.props.enableGradient ? { gradient: pointGradient } : {}));
|
|
414
|
+
})) !== null && _b !== void 0 ? _b : [] });
|
|
415
|
+
})) !== null && _b !== void 0 ? _b : [],
|
|
416
|
+
lineData: (_c = lineData === null || lineData === void 0 ? void 0 : lineData.map(function (series) {
|
|
417
|
+
var _a, _b;
|
|
418
|
+
var color;
|
|
419
|
+
if (typeof series.color === 'undefined') {
|
|
420
|
+
color = getNextColor(colorIndex, 0, (_a = _this.props.theme) === null || _a === void 0 ? void 0 : _a.isInverted);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
color = getColorFromToken(series.color, (_b = _this.props.theme) === null || _b === void 0 ? void 0 : _b.isInverted);
|
|
424
|
+
}
|
|
425
|
+
if (!_this._legendColorMap[series.legend]) {
|
|
426
|
+
_this._legendColorMap[series.legend] = [color, color];
|
|
427
|
+
}
|
|
428
|
+
colorIndex += 1;
|
|
429
|
+
return __assign(__assign({}, series), { color: _this._legendColorMap[series.legend][0] });
|
|
430
|
+
})) !== null && _c !== void 0 ? _c : [],
|
|
431
|
+
};
|
|
412
432
|
};
|
|
413
|
-
_this._getOrderedXAxisLabels = function (
|
|
433
|
+
_this._getOrderedXAxisLabels = function (barData, lineData) {
|
|
414
434
|
if (_this._xAxisType !== XAxisTypes.StringAxis) {
|
|
415
435
|
return [];
|
|
416
436
|
}
|
|
417
|
-
return sortAxisCategories(_this._mapCategoryToValues(
|
|
437
|
+
return sortAxisCategories(_this._mapCategoryToValues(barData, lineData), _this.props.xAxisCategoryOrder);
|
|
418
438
|
};
|
|
419
|
-
_this._mapCategoryToValues = function (
|
|
439
|
+
_this._mapCategoryToValues = function (barData, lineData) {
|
|
420
440
|
var categoryToValues = {};
|
|
421
|
-
|
|
441
|
+
barData.forEach(function (point) {
|
|
422
442
|
if (!categoryToValues[point.name]) {
|
|
423
443
|
categoryToValues[point.name] = [];
|
|
424
444
|
}
|
|
@@ -426,10 +446,143 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
426
446
|
categoryToValues[point.name].push(seriesPoint.data);
|
|
427
447
|
});
|
|
428
448
|
});
|
|
449
|
+
lineData.forEach(function (series) {
|
|
450
|
+
series.data.forEach(function (point) {
|
|
451
|
+
if (!categoryToValues[point.x]) {
|
|
452
|
+
categoryToValues[point.x] = [];
|
|
453
|
+
}
|
|
454
|
+
categoryToValues[point.x].push(point.y);
|
|
455
|
+
});
|
|
456
|
+
});
|
|
429
457
|
return categoryToValues;
|
|
430
458
|
};
|
|
459
|
+
_this._createLines = function (lineData, xScale, yScalePrimary, yScaleSecondary) {
|
|
460
|
+
var lineBorders = [];
|
|
461
|
+
var lines = [];
|
|
462
|
+
var dots = [];
|
|
463
|
+
var scaleLineX = function (x) { return xScale(x) + xScale.bandwidth() / 2; };
|
|
464
|
+
lineData.forEach(function (series, seriesIdx) {
|
|
465
|
+
var _a;
|
|
466
|
+
var lineBorderGroup = [];
|
|
467
|
+
var lineGroup = [];
|
|
468
|
+
var dotGroup = [];
|
|
469
|
+
var lineBorderWidth = ((_a = series.lineOptions) === null || _a === void 0 ? void 0 : _a.lineBorderWidth)
|
|
470
|
+
? Number.parseFloat(series.lineOptions.lineBorderWidth.toString())
|
|
471
|
+
: 0;
|
|
472
|
+
var yScale = series.useSecondaryYScale && yScaleSecondary ? yScaleSecondary : yScalePrimary;
|
|
473
|
+
var shouldHighlight = _this._legendHighlighted(series.legend) || _this._noLegendHighlighted();
|
|
474
|
+
series.data.forEach(function (point, pointIdx) {
|
|
475
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
476
|
+
var x2 = scaleLineX(point.x);
|
|
477
|
+
var y2 = yScale(point.y);
|
|
478
|
+
if (pointIdx > 0) {
|
|
479
|
+
var x1 = scaleLineX(series.data[pointIdx - 1].x);
|
|
480
|
+
var y1 = yScale(series.data[pointIdx - 1].y);
|
|
481
|
+
if (lineBorderWidth > 0) {
|
|
482
|
+
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 }));
|
|
483
|
+
}
|
|
484
|
+
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 }));
|
|
485
|
+
}
|
|
486
|
+
var dotId = _this._getDotId(seriesIdx, pointIdx);
|
|
487
|
+
var activeLinePoint = _this.state.activeLinePoint;
|
|
488
|
+
var isLinePointActive = activeLinePoint === point.x || activeLinePoint === dotId;
|
|
489
|
+
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({
|
|
490
|
+
xAxisCalloutData: point.xAxisCalloutData,
|
|
491
|
+
legend: series.legend,
|
|
492
|
+
yAxisCalloutData: point.yAxisCalloutData,
|
|
493
|
+
data: point.y,
|
|
494
|
+
callOutAccessibilityData: point.callOutAccessibilityData,
|
|
495
|
+
}, point.x) }));
|
|
496
|
+
});
|
|
497
|
+
lineBorders.push(React.createElement("g", { key: "lineBorderGroup-".concat(seriesIdx) }, lineBorderGroup));
|
|
498
|
+
lines.push(React.createElement("g", { key: "lineGroup-".concat(seriesIdx) }, lineGroup));
|
|
499
|
+
dots.push(React.createElement("g", { key: "dotGroup-".concat(seriesIdx) }, dotGroup));
|
|
500
|
+
});
|
|
501
|
+
return dots.length > 0 ? (React.createElement("g", null,
|
|
502
|
+
lineBorders.length > 0 ? React.createElement("g", null, lineBorders) : null,
|
|
503
|
+
lines.length > 0 ? React.createElement("g", null, lines) : null,
|
|
504
|
+
React.createElement("g", null, dots))) : null;
|
|
505
|
+
};
|
|
506
|
+
_this._onLineHover = function (event, series, seriesIdx, pointIdx, scaleLineX) {
|
|
507
|
+
var pointerX = d3Pointer(event, _this._rectRef.current)[0];
|
|
508
|
+
var closestPointIdx = pointIdx;
|
|
509
|
+
if (pointIdx > 0) {
|
|
510
|
+
var currPointPos = scaleLineX(series.data[pointIdx].x);
|
|
511
|
+
var prevPointPos = scaleLineX(series.data[pointIdx - 1].x);
|
|
512
|
+
if (Math.abs(prevPointPos - pointerX) < Math.abs(currPointPos - pointerX)) {
|
|
513
|
+
closestPointIdx = pointIdx - 1;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
event.persist();
|
|
517
|
+
_this._showCalloutForLines(event, series, seriesIdx, closestPointIdx);
|
|
518
|
+
};
|
|
519
|
+
_this._onLineFocus = function (event, series, seriesIdx, pointIdx) {
|
|
520
|
+
_this._showCalloutForLines(event.currentTarget, series, seriesIdx, pointIdx);
|
|
521
|
+
};
|
|
522
|
+
_this._showCalloutForLines = function (target, series, seriesIdx, pointIdx) {
|
|
523
|
+
var point = series.data[pointIdx];
|
|
524
|
+
var pointData = __assign(__assign({}, point), { legend: series.legend, color: series.color, key: series.legend, data: point.y, yAxisCalloutData: point.yAxisCalloutData });
|
|
525
|
+
var groupData = _this._datasetForBars.find(function (singleSet) { return singleSet.xAxisPoint === point.x; });
|
|
526
|
+
_this._showCallout(target, pointData, groupData, _this._getDotId(seriesIdx, pointIdx));
|
|
527
|
+
};
|
|
528
|
+
_this._showCallout = function (target, pointData,
|
|
529
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
530
|
+
groupData, activeLinePoint) {
|
|
531
|
+
var _a, _b;
|
|
532
|
+
if (activeLinePoint === void 0) { activeLinePoint = ''; }
|
|
533
|
+
_this.setState({
|
|
534
|
+
refSelected: target,
|
|
535
|
+
isCalloutVisible: _this._noLegendHighlighted() || _this._legendHighlighted(pointData.legend),
|
|
536
|
+
calloutLegend: pointData.legend,
|
|
537
|
+
dataForHoverCard: pointData.data,
|
|
538
|
+
color: pointData.color,
|
|
539
|
+
xCalloutValue: (_a = pointData.xAxisCalloutData) !== null && _a !== void 0 ? _a : groupData.xAxisPoint,
|
|
540
|
+
yCalloutValue: pointData.yAxisCalloutData,
|
|
541
|
+
dataPointCalloutProps: pointData,
|
|
542
|
+
callOutAccessibilityData: _this.props.isCalloutForStack
|
|
543
|
+
? groupData.stackCallOutAccessibilityData
|
|
544
|
+
: pointData.callOutAccessibilityData,
|
|
545
|
+
YValueHover: groupData.groupSeries.filter(function (item) { return _this._noLegendHighlighted() || _this._legendHighlighted(item.legend); }),
|
|
546
|
+
hoverXValue: (_b = pointData.xAxisCalloutData) !== null && _b !== void 0 ? _b : groupData.xAxisPoint,
|
|
547
|
+
activeLinePoint: _this.props.isCalloutForStack ? groupData.xAxisPoint : activeLinePoint,
|
|
548
|
+
});
|
|
549
|
+
};
|
|
550
|
+
_this._getDotId = function (seriesIdx, pointIdx) {
|
|
551
|
+
return _this._uniqDotId + "-".concat(seriesIdx, "-").concat(pointIdx);
|
|
552
|
+
};
|
|
553
|
+
_this._processDataV2 = function (dataV2) {
|
|
554
|
+
var barPointsByX = {};
|
|
555
|
+
var lineData = [];
|
|
556
|
+
dataV2.forEach(function (series) {
|
|
557
|
+
if (series.type === 'bar') {
|
|
558
|
+
series.data.forEach(function (point) {
|
|
559
|
+
var _a, _b;
|
|
560
|
+
if (!barPointsByX[point.x]) {
|
|
561
|
+
barPointsByX[point.x] = { name: point.x, series: [] };
|
|
562
|
+
}
|
|
563
|
+
barPointsByX[point.x].series.push({
|
|
564
|
+
key: (_a = series.key) !== null && _a !== void 0 ? _a : series.legend,
|
|
565
|
+
data: point.y,
|
|
566
|
+
color: (_b = point.color) !== null && _b !== void 0 ? _b : series.color,
|
|
567
|
+
gradient: series.gradient,
|
|
568
|
+
legend: series.legend,
|
|
569
|
+
xAxisCalloutData: point.xAxisCalloutData,
|
|
570
|
+
yAxisCalloutData: point.yAxisCalloutData,
|
|
571
|
+
onClick: point.onClick,
|
|
572
|
+
useSecondaryYScale: series.useSecondaryYScale,
|
|
573
|
+
});
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
else if (series.type === 'line') {
|
|
577
|
+
lineData.push(series);
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
return { barData: Object.values(barPointsByX), lineData: lineData };
|
|
581
|
+
};
|
|
431
582
|
initializeComponentRef(_this);
|
|
432
|
-
_this._createSet = memoizeFunction(function (
|
|
583
|
+
_this._createSet = memoizeFunction(function (barData, lineData) {
|
|
584
|
+
return _this._createDataSetOfGVBC(barData, lineData);
|
|
585
|
+
});
|
|
433
586
|
_this.state = {
|
|
434
587
|
color: '',
|
|
435
588
|
dataForHoverCard: 0,
|
|
@@ -442,6 +595,7 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
442
595
|
hoverXValue: '',
|
|
443
596
|
calloutLegend: '',
|
|
444
597
|
activeLegend: '',
|
|
598
|
+
activeLinePoint: '',
|
|
445
599
|
};
|
|
446
600
|
warnDeprecations(COMPONENT_NAME, props, {
|
|
447
601
|
showYAxisGridLines: 'Dont use this property. Lines are drawn by default',
|
|
@@ -456,6 +610,7 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
456
610
|
_this._domainMargin = MIN_DOMAIN_MARGIN;
|
|
457
611
|
_this._cartesianChartRef = React.createRef();
|
|
458
612
|
_this._legendsRef = React.createRef();
|
|
613
|
+
_this._rectRef = React.createRef();
|
|
459
614
|
return _this;
|
|
460
615
|
}
|
|
461
616
|
GroupedVerticalBarChartBase.prototype.componentDidUpdate = function (prevProps) {
|
|
@@ -468,10 +623,11 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
468
623
|
};
|
|
469
624
|
GroupedVerticalBarChartBase.prototype.render = function () {
|
|
470
625
|
var _this = this;
|
|
471
|
-
var
|
|
472
|
-
this._xAxisType = getTypeOfAxis(
|
|
473
|
-
var
|
|
474
|
-
this.
|
|
626
|
+
var _a = this._prepareChartData(), barData = _a.barData, lineData = _a.lineData;
|
|
627
|
+
this._xAxisType = getTypeOfAxis(barData[0].name, true);
|
|
628
|
+
var _b = this._createSet(barData, lineData), barLegends = _b.barLegends, lineLegends = _b.lineLegends, xAxisLabels = _b.xAxisLabels, datasetForBars = _b.datasetForBars;
|
|
629
|
+
this._barLegends = barLegends;
|
|
630
|
+
this._lineLegends = lineLegends;
|
|
475
631
|
this._xAxisLabels = xAxisLabels;
|
|
476
632
|
this._datasetForBars = datasetForBars;
|
|
477
633
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
@@ -491,15 +647,18 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
491
647
|
tickValues: this.props.tickValues,
|
|
492
648
|
tickFormat: this.props.tickFormat,
|
|
493
649
|
};
|
|
494
|
-
return !this._isChartEmpty() ? (React.createElement(CartesianChart, __assign({}, this.props, { chartTitle: this._getChartTitle(), points: this._datasetForBars, chartType: ChartTypes.GroupedVerticalBarChart, calloutProps: calloutProps, legendBars: legendBars, xAxisType: this._xAxisType, createYAxis: createNumericYAxis, datasetForXAxisDomain: this._xAxisLabels, tickParams: tickParams, getDomainNRangeValues: this._getDomainNRangeValues, getMinMaxOfYAxis: this._getMinMaxOfYAxis, createStringYAxis: createStringYAxis, tickPadding: this.props.tickPadding || 5, maxOfYVal: this._yMax, svgFocusZoneProps: {
|
|
650
|
+
return !this._isChartEmpty(barData, lineData) ? (React.createElement(CartesianChart, __assign({}, this.props, { chartTitle: this._getChartTitle(), points: this._datasetForBars, chartType: ChartTypes.GroupedVerticalBarChart, calloutProps: calloutProps, legendBars: legendBars, xAxisType: this._xAxisType, createYAxis: createNumericYAxis, datasetForXAxisDomain: this._xAxisLabels, tickParams: tickParams, getDomainNRangeValues: this._getDomainNRangeValues, getMinMaxOfYAxis: this._getMinMaxOfYAxis, createStringYAxis: createStringYAxis, tickPadding: this.props.tickPadding || 5, maxOfYVal: this._yMax, svgFocusZoneProps: {
|
|
495
651
|
direction: FocusZoneDirection.horizontal,
|
|
496
652
|
}, customizedCallout: this._getCustomizedCallout(), getmargins: this._getMargins, getGraphData: this._getGraphData, getAxisData: this._getAxisData, onChartMouseLeave: this._handleChartMouseLeave, getDomainMargins: this._getDomainMargins }, (this._xAxisType === XAxisTypes.StringAxis && {
|
|
497
653
|
xAxisInnerPadding: this._xAxisInnerPadding,
|
|
498
654
|
xAxisOuterPadding: this._xAxisOuterPadding,
|
|
499
655
|
}), { barwidth: this._barWidth, ref: this._cartesianChartRef,
|
|
500
656
|
/* eslint-disable react/jsx-no-bind */
|
|
501
|
-
children: function () {
|
|
502
|
-
return React.createElement(
|
|
657
|
+
children: function (props) {
|
|
658
|
+
return (React.createElement(React.Fragment, null,
|
|
659
|
+
React.createElement("rect", { ref: _this._rectRef, width: "100%", height: "100%", fill: "transparent", style: { pointerEvents: 'none' } }),
|
|
660
|
+
React.createElement("g", null, _this._groupedVerticalBarGraph),
|
|
661
|
+
_this._createLines(lineData, props.xScale, props.yScalePrimary, props.yScaleSecondary)));
|
|
503
662
|
} }))) : (React.createElement("div", { id: this._emptyChartId, role: 'alert', style: { opacity: '0' }, "aria-label": 'Graph has no data to display' }));
|
|
504
663
|
};
|
|
505
664
|
Object.defineProperty(GroupedVerticalBarChartBase.prototype, "chartContainer", {
|
|
@@ -539,17 +698,18 @@ var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
539
698
|
? [this.state.activeLegend]
|
|
540
699
|
: [];
|
|
541
700
|
};
|
|
542
|
-
GroupedVerticalBarChartBase.prototype._isChartEmpty = function () {
|
|
543
|
-
return !(
|
|
544
|
-
|
|
545
|
-
|
|
701
|
+
GroupedVerticalBarChartBase.prototype._isChartEmpty = function (barData, lineData) {
|
|
702
|
+
return !((barData &&
|
|
703
|
+
barData.length > 0 &&
|
|
704
|
+
barData.filter(function (item) { return item.series.length; }).length > 0) ||
|
|
705
|
+
(lineData && lineData.length > 0 && lineData.some(function (series) { return series.data.length > 0; })));
|
|
546
706
|
};
|
|
547
707
|
GroupedVerticalBarChartBase.prototype._adjustProps = function () {
|
|
548
708
|
this._barWidth = getBarWidth(this.props.barwidth, this.props.maxBarWidth);
|
|
549
709
|
// x0_inner_padding = space_between_groups / (space_between_groups + group_width)
|
|
550
710
|
// space_between_groups = 2 * bar_width
|
|
551
711
|
// group_width = this._legends.length * bar_width + (this._legends.length - 1) * space_between_bars
|
|
552
|
-
this._xAxisInnerPadding = getScalePadding(this.props.xAxisInnerPadding, undefined, 2 / (2 + calcTotalBandUnits(this.
|
|
712
|
+
this._xAxisInnerPadding = getScalePadding(this.props.xAxisInnerPadding, undefined, 2 / (2 + calcTotalBandUnits(this._barLegends.length, X1_INNER_PADDING)));
|
|
553
713
|
this._xAxisOuterPadding = getScalePadding(this.props.xAxisOuterPadding);
|
|
554
714
|
};
|
|
555
715
|
GroupedVerticalBarChartBase.defaultProps = {
|