@fluentui/react-charting 5.23.77 → 5.23.79
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.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +10 -23
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +3 -4
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +119 -117
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +89 -26
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib/components/LineChart/eventAnnotation/LabelLink.js +1 -1
- package/lib/components/LineChart/eventAnnotation/LabelLink.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +2 -0
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +29 -11
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib/utilities/utilities.d.ts +6 -3
- package/lib/utilities/utilities.js +16 -11
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +10 -23
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +3 -4
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +119 -117
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -1
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +88 -25
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-amd/components/LineChart/eventAnnotation/LabelLink.js +1 -1
- package/lib-amd/components/LineChart/eventAnnotation/LabelLink.js.map +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +2 -0
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +29 -11
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +6 -3
- package/lib-amd/utilities/utilities.js +18 -13
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +10 -23
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +3 -4
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +119 -117
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +88 -25
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js +1 -1
- package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +2 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +29 -11
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +6 -3
- package/lib-commonjs/utilities/utilities.js +18 -13
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +1 -1
|
@@ -10,12 +10,15 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
10
10
|
// => space_between_bars = (x1_inner_padding / (1 - x1_inner_padding)) * bar_width
|
|
11
11
|
/** Rate at which the space between the bars in a group changes wrt the bar width */
|
|
12
12
|
var BAR_GAP_RATE = X1_INNER_PADDING / (1 - X1_INNER_PADDING);
|
|
13
|
+
var VERTICAL_BAR_GAP = 1;
|
|
14
|
+
var MIN_BAR_HEIGHT = 1;
|
|
13
15
|
var GroupedVerticalBarChartBase = /** @class */ (function (_super) {
|
|
14
16
|
tslib_1.__extends(GroupedVerticalBarChartBase, _super);
|
|
15
17
|
function GroupedVerticalBarChartBase(props) {
|
|
16
18
|
var _a;
|
|
17
19
|
var _this = _super.call(this, props) || this;
|
|
18
20
|
_this._isRtl = (0, Utilities_1.getRTL)();
|
|
21
|
+
_this._legendColorMap = {};
|
|
19
22
|
_this.toImage = function (opts) {
|
|
20
23
|
var _a, _b;
|
|
21
24
|
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 +50,8 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
47
50
|
var xScale0 = _this._createX0Scale(containerWidth);
|
|
48
51
|
// Setting the bar width here is safe because there are no dependencies earlier in the code
|
|
49
52
|
// 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, xScale0.bandwidth() / (_this.
|
|
51
|
-
_this._groupWidth = (_this.
|
|
53
|
+
_this._barWidth = (0, index_1.getBarWidth)(_this.props.barwidth, _this.props.maxBarWidth, xScale0.bandwidth() / (_this._legends.length + (_this._legends.length - 1) * BAR_GAP_RATE));
|
|
54
|
+
_this._groupWidth = (_this._legends.length + (_this._legends.length - 1) * BAR_GAP_RATE) * _this._barWidth;
|
|
52
55
|
var xScale1 = _this._createX1Scale();
|
|
53
56
|
var allGroupsBars = [];
|
|
54
57
|
_this._datasetForBars.forEach(function (singleSet) {
|
|
@@ -58,14 +61,16 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
58
61
|
};
|
|
59
62
|
_this._getMargins = function (margins) { return (_this.margins = margins); };
|
|
60
63
|
_this._createDataSetOfGVBC = function (points) {
|
|
61
|
-
var
|
|
64
|
+
var legends = new Set();
|
|
62
65
|
var xAxisLabels = points.map(function (singlePoint) { return singlePoint.name; });
|
|
63
|
-
points
|
|
64
|
-
|
|
66
|
+
points.forEach(function (point) {
|
|
67
|
+
point.series.forEach(function (seriesPoint) {
|
|
68
|
+
legends.add(seriesPoint.legend);
|
|
69
|
+
});
|
|
65
70
|
});
|
|
66
71
|
var datasetForBars = _this._createDataset(points);
|
|
67
72
|
return {
|
|
68
|
-
|
|
73
|
+
legends: Array.from(legends),
|
|
69
74
|
xAxisLabels: xAxisLabels,
|
|
70
75
|
datasetForBars: datasetForBars,
|
|
71
76
|
};
|
|
@@ -75,10 +80,6 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
75
80
|
? _this.props.onRenderCalloutPerDataPoint(_this.state.dataPointCalloutProps)
|
|
76
81
|
: null;
|
|
77
82
|
};
|
|
78
|
-
_this._getOpacity = function (legendTitle) {
|
|
79
|
-
var opacity = _this._legendHighlighted(legendTitle) || _this._noLegendHighlighted() ? '' : '0.1';
|
|
80
|
-
return opacity;
|
|
81
|
-
};
|
|
82
83
|
_this._onBarHover = function (pointData,
|
|
83
84
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
85
|
groupData, mouseEvent) {
|
|
@@ -112,26 +113,22 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
112
113
|
};
|
|
113
114
|
_this._onBarFocus = function (pointData,
|
|
114
115
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
115
|
-
groupData,
|
|
116
|
-
_this.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
YValueHover: groupData.groupSeries,
|
|
132
|
-
hoverXValue: pointData.xAxisCalloutData,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
116
|
+
groupData, focusEvent) {
|
|
117
|
+
_this.setState({
|
|
118
|
+
refSelected: focusEvent.currentTarget,
|
|
119
|
+
/** Show the callout if highlighted bar is focused and Hide it if unhighlighted bar is focused */
|
|
120
|
+
isCalloutVisible: _this._noLegendHighlighted() || _this._legendHighlighted(pointData.legend),
|
|
121
|
+
calloutLegend: pointData.legend,
|
|
122
|
+
dataForHoverCard: pointData.data,
|
|
123
|
+
color: pointData.color,
|
|
124
|
+
xCalloutValue: pointData.xAxisCalloutData,
|
|
125
|
+
yCalloutValue: pointData.yAxisCalloutData,
|
|
126
|
+
dataPointCalloutProps: pointData,
|
|
127
|
+
callOutAccessibilityData: _this.props.isCalloutForStack
|
|
128
|
+
? groupData.stackCallOutAccessibilityData
|
|
129
|
+
: pointData.callOutAccessibilityData,
|
|
130
|
+
YValueHover: groupData.groupSeries,
|
|
131
|
+
hoverXValue: pointData.xAxisCalloutData,
|
|
135
132
|
});
|
|
136
133
|
};
|
|
137
134
|
_this._redirectToUrl = function (href) {
|
|
@@ -146,40 +143,41 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
146
143
|
xScale1, yScalePrimary, yScaleSecondary, containerHeight, xElement) {
|
|
147
144
|
var singleGroup = [];
|
|
148
145
|
var barLabelsForGroup = [];
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
var pointData = singleSet[datasetKey];
|
|
154
|
-
if (pointData) {
|
|
155
|
-
var yBarScale = pointData.useSecondaryYScale && yScaleSecondary ? yScaleSecondary : yScalePrimary;
|
|
146
|
+
_this._legends.forEach(function (legendTitle, legendIndex) {
|
|
147
|
+
var barPoints = singleSet[legendTitle];
|
|
148
|
+
if (barPoints) {
|
|
149
|
+
var yBarScale_1 = barPoints[0].useSecondaryYScale && yScaleSecondary ? yScaleSecondary : yScalePrimary;
|
|
156
150
|
// To align the centers of the generated bandwidth and the calculated one when they differ,
|
|
157
151
|
// use the following addend.
|
|
158
|
-
var
|
|
159
|
-
var
|
|
160
|
-
var
|
|
161
|
-
var
|
|
152
|
+
var xPoint_1 = xScale1(legendTitle) + (xScale1.bandwidth() - _this._barWidth) / 2;
|
|
153
|
+
var isLegendActive_1 = _this._legendHighlighted(legendTitle) || _this._noLegendHighlighted();
|
|
154
|
+
var barOpacity_1 = isLegendActive_1 ? '' : '0.1';
|
|
155
|
+
var gradientId_1 = (0, Utilities_1.getId)('GVBC_Gradient') + "_".concat(singleSet.indexNum, "_").concat(legendIndex);
|
|
156
|
+
var startColor_1 = barPoints[0].color;
|
|
157
|
+
var endColor = startColor_1;
|
|
162
158
|
if (_this.props.enableGradient) {
|
|
163
|
-
|
|
164
|
-
endColor =
|
|
165
|
-
|
|
159
|
+
startColor_1 = barPoints[0].gradient[0];
|
|
160
|
+
endColor = barPoints[0].gradient[1];
|
|
161
|
+
singleGroup.push(React.createElement("linearGradient", { key: gradientId_1, id: gradientId_1, x1: "0%", y1: "100%", x2: "0%", y2: "0%" },
|
|
162
|
+
React.createElement("stop", { offset: "0", stopColor: startColor_1 }),
|
|
163
|
+
React.createElement("stop", { offset: "100%", stopColor: endColor })));
|
|
166
164
|
}
|
|
167
|
-
var
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
barLabelsForGroup.push(React.createElement("text", { key: "".concat(singleSet.indexNum, "-").concat(
|
|
165
|
+
var prevYPoint_1 = yBarScale_1(0);
|
|
166
|
+
var barTotalValue_1 = 0;
|
|
167
|
+
barPoints.forEach(function (pointData, pointIndex) {
|
|
168
|
+
if (!pointData.data) {
|
|
169
|
+
// Not rendering data with 0.
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
var barGapTop = (VERTICAL_BAR_GAP / 2) * (pointIndex < barPoints.length - 1 ? 1 : 0);
|
|
173
|
+
var barGapBottom = (VERTICAL_BAR_GAP / 2) * (pointIndex > 0 ? 1 : 0);
|
|
174
|
+
var height = Math.max(yBarScale_1(0) - yBarScale_1(pointData.data) - barGapTop - barGapBottom, MIN_BAR_HEIGHT);
|
|
175
|
+
singleGroup.push(React.createElement("rect", { key: "".concat(singleSet.indexNum, "-").concat(legendIndex, "-").concat(pointIndex), className: _this._classNames.opacityChangeOnHover, height: height, width: _this._barWidth, x: xPoint_1, y: prevYPoint_1 - (height + barGapBottom), "data-is-focusable": !_this.props.hideTooltip && isLegendActive_1, opacity: barOpacity_1, fill: _this.props.enableGradient ? "url(#".concat(gradientId_1, ")") : startColor_1, rx: _this.props.roundCorners ? 3 : 0, onMouseOver: _this._onBarHover.bind(_this, pointData, singleSet), onMouseMove: _this._onBarHover.bind(_this, pointData, singleSet), onMouseOut: _this._onBarLeave, onFocus: _this._onBarFocus.bind(_this, pointData, singleSet), onBlur: _this._onBarLeave, onClick: _this.props.href ? _this._redirectToUrl.bind(_this, _this.props.href) : pointData.onClick, "aria-label": _this._getAriaLabel(pointData, singleSet.xAxisPoint), role: "img" }));
|
|
176
|
+
prevYPoint_1 = prevYPoint_1 - (height + barGapTop + barGapBottom);
|
|
177
|
+
barTotalValue_1 += pointData.data;
|
|
178
|
+
});
|
|
179
|
+
if (barTotalValue_1 && !_this.props.hideLabels && _this._barWidth >= 16 && isLegendActive_1) {
|
|
180
|
+
barLabelsForGroup.push(React.createElement("text", { key: "".concat(singleSet.indexNum, "-").concat(legendIndex), x: xPoint_1 + _this._barWidth / 2, y: prevYPoint_1 - 6, textAnchor: "middle", className: _this._classNames.barLabel, "aria-hidden": true }, (0, index_1.formatValueWithSIPrefix)(barTotalValue_1)));
|
|
183
181
|
}
|
|
184
182
|
}
|
|
185
183
|
});
|
|
@@ -205,28 +203,25 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
205
203
|
_this._createDataset = function (points) {
|
|
206
204
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
207
205
|
var datasetForBars = [];
|
|
208
|
-
var dataset = [];
|
|
209
206
|
points.forEach(function (point, index) {
|
|
210
|
-
var singleDatasetPoint = {};
|
|
211
207
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
212
208
|
var singleDatasetPointForBars = {};
|
|
213
|
-
var
|
|
214
|
-
point.series.forEach(function (seriesPoint
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
seriesPoint.
|
|
218
|
-
|
|
209
|
+
var legendToBarPoint = {};
|
|
210
|
+
point.series.forEach(function (seriesPoint) {
|
|
211
|
+
if (!singleDatasetPointForBars[seriesPoint.legend]) {
|
|
212
|
+
singleDatasetPointForBars[seriesPoint.legend] = [tslib_1.__assign({}, seriesPoint)];
|
|
213
|
+
legendToBarPoint[seriesPoint.legend] = tslib_1.__assign({}, seriesPoint);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
singleDatasetPointForBars[seriesPoint.legend].push(tslib_1.__assign({}, seriesPoint));
|
|
217
|
+
legendToBarPoint[seriesPoint.legend].data += seriesPoint.data;
|
|
219
218
|
}
|
|
220
|
-
singleDatasetPoint[seriesPoint.key] = seriesPoint.data;
|
|
221
|
-
singleDatasetPointForBars[seriesPoint.key] = tslib_1.__assign({}, seriesPoint);
|
|
222
|
-
singleDataSeries.push(seriesPoint);
|
|
223
219
|
});
|
|
224
220
|
singleDatasetPointForBars.xAxisPoint = point.name;
|
|
225
221
|
singleDatasetPointForBars.indexNum = index;
|
|
226
|
-
singleDatasetPointForBars.groupSeries =
|
|
222
|
+
singleDatasetPointForBars.groupSeries = Object.values(legendToBarPoint);
|
|
227
223
|
singleDatasetPointForBars.stackCallOutAccessibilityData = point.stackCallOutAccessibilityData;
|
|
228
224
|
datasetForBars.push(singleDatasetPointForBars);
|
|
229
|
-
dataset.push(singleDatasetPoint);
|
|
230
225
|
});
|
|
231
226
|
return datasetForBars;
|
|
232
227
|
};
|
|
@@ -245,7 +240,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
245
240
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
246
241
|
_this._createX1Scale = function () {
|
|
247
242
|
return ((0, d3_scale_1.scaleBand)()
|
|
248
|
-
.domain(_this.
|
|
243
|
+
.domain(_this._legends)
|
|
249
244
|
// When there is only one group, xScale0 adds padding around it,
|
|
250
245
|
// causing the bandwidth to become smaller than the actual group width.
|
|
251
246
|
// So to render bars in the group correctly, use groupWidth instead of the generated scale bandwidth.
|
|
@@ -257,35 +252,21 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
257
252
|
isCalloutVisible: false,
|
|
258
253
|
});
|
|
259
254
|
};
|
|
260
|
-
_this._getLegendData = function (
|
|
261
|
-
var data = points;
|
|
262
|
-
var defaultPalette = [palette.blueLight, palette.blue, palette.blueMid, palette.red, palette.black];
|
|
255
|
+
_this._getLegendData = function () {
|
|
263
256
|
var actions = [];
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
title: point.legend,
|
|
278
|
-
color: color,
|
|
279
|
-
hoverAction: function () {
|
|
280
|
-
_this._handleChartMouseLeave();
|
|
281
|
-
_this._onLegendHover(point.legend);
|
|
282
|
-
},
|
|
283
|
-
onMouseOutAction: function () {
|
|
284
|
-
_this._onLegendLeave();
|
|
285
|
-
},
|
|
286
|
-
};
|
|
287
|
-
actions.push(legend);
|
|
288
|
-
});
|
|
257
|
+
_this._legends.forEach(function (legendTitle) {
|
|
258
|
+
var legend = {
|
|
259
|
+
title: legendTitle,
|
|
260
|
+
color: _this._legendColorMap[legendTitle][0],
|
|
261
|
+
hoverAction: function () {
|
|
262
|
+
_this._handleChartMouseLeave();
|
|
263
|
+
_this._onLegendHover(legendTitle);
|
|
264
|
+
},
|
|
265
|
+
onMouseOutAction: function () {
|
|
266
|
+
_this._onLegendLeave();
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
actions.push(legend);
|
|
289
270
|
});
|
|
290
271
|
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 })));
|
|
291
272
|
};
|
|
@@ -333,7 +314,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
333
314
|
// Update the bar width so that when CartesianChart rerenders,
|
|
334
315
|
// the following calculations don't use the previous bar width.
|
|
335
316
|
_this._barWidth = (0, index_1.getBarWidth)(_this.props.barwidth, _this.props.maxBarWidth);
|
|
336
|
-
var groupWidth = (_this.
|
|
317
|
+
var groupWidth = (_this._legends.length + (_this._legends.length - 1) * BAR_GAP_RATE) * _this._barWidth;
|
|
337
318
|
/** Total width required to render the groups. Directly proportional to group width */
|
|
338
319
|
var reqWidth = (_this._xAxisLabels.length + (_this._xAxisLabels.length - 1) * groupGapRate) * groupWidth;
|
|
339
320
|
if (totalWidth >= reqWidth) {
|
|
@@ -344,9 +325,9 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
344
325
|
else if (_this.props.mode === 'plotly' && _this._xAxisLabels.length > 1) {
|
|
345
326
|
// Calculate the remaining width after rendering groups at their maximum allowable width
|
|
346
327
|
var groupBandwidth = totalWidth / (_this._xAxisLabels.length + (_this._xAxisLabels.length - 1) * groupGapRate);
|
|
347
|
-
var barBandwidth = groupBandwidth / (_this.
|
|
328
|
+
var barBandwidth = groupBandwidth / (_this._legends.length + (_this._legends.length - 1) * BAR_GAP_RATE);
|
|
348
329
|
var barWidth = (0, index_1.getBarWidth)(_this.props.barwidth, _this.props.maxBarWidth, barBandwidth);
|
|
349
|
-
var groupWidth = (_this.
|
|
330
|
+
var groupWidth = (_this._legends.length + (_this._legends.length - 1) * BAR_GAP_RATE) * barWidth;
|
|
350
331
|
var reqWidth = (_this._xAxisLabels.length + (_this._xAxisLabels.length - 1) * groupGapRate) * groupWidth;
|
|
351
332
|
var margin1 = (totalWidth - reqWidth) / 2;
|
|
352
333
|
var margin2 = Number.POSITIVE_INFINITY;
|
|
@@ -364,7 +345,32 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
364
345
|
_this._getChartTitle = function () {
|
|
365
346
|
var chartTitle = _this.props.chartTitle;
|
|
366
347
|
return ((chartTitle ? "".concat(chartTitle, ". ") : '') +
|
|
367
|
-
"Vertical bar chart with ".concat(_this._xAxisLabels.length, " groups of ").concat(_this.
|
|
348
|
+
"Vertical bar chart with ".concat(_this._xAxisLabels.length, " groups of ").concat(_this._legends.length, " bars each. "));
|
|
349
|
+
};
|
|
350
|
+
_this._addDefaultColors = function (data) {
|
|
351
|
+
var _a;
|
|
352
|
+
_this._legendColorMap = {};
|
|
353
|
+
var colorIndex = 0;
|
|
354
|
+
return ((_a = data === null || data === void 0 ? void 0 : data.map(function (point) {
|
|
355
|
+
var _a, _b;
|
|
356
|
+
return tslib_1.__assign(tslib_1.__assign({}, point), { series: (_b = (_a = point.series) === null || _a === void 0 ? void 0 : _a.map(function (seriesPoint) {
|
|
357
|
+
var _a, _b, _c, _d;
|
|
358
|
+
if (!_this._legendColorMap[seriesPoint.legend]) {
|
|
359
|
+
var startColor = seriesPoint.color
|
|
360
|
+
? seriesPoint.color
|
|
361
|
+
: (0, index_1.getNextColor)(colorIndex, 0, (_a = _this.props.theme) === null || _a === void 0 ? void 0 : _a.isInverted);
|
|
362
|
+
var endColor = startColor;
|
|
363
|
+
if (_this.props.enableGradient) {
|
|
364
|
+
var nextGradient = (0, index_1.getNextGradient)(colorIndex, 0, (_b = _this.props.theme) === null || _b === void 0 ? void 0 : _b.isInverted);
|
|
365
|
+
startColor = ((_c = seriesPoint.gradient) === null || _c === void 0 ? void 0 : _c[0]) || nextGradient[0];
|
|
366
|
+
endColor = ((_d = seriesPoint.gradient) === null || _d === void 0 ? void 0 : _d[1]) || nextGradient[1];
|
|
367
|
+
}
|
|
368
|
+
_this._legendColorMap[seriesPoint.legend] = [startColor, endColor];
|
|
369
|
+
colorIndex += 1;
|
|
370
|
+
}
|
|
371
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, seriesPoint), { color: _this._legendColorMap[seriesPoint.legend][0] }), (_this.props.enableGradient ? { gradient: _this._legendColorMap[seriesPoint.legend] } : {}));
|
|
372
|
+
})) !== null && _b !== void 0 ? _b : [] });
|
|
373
|
+
})) !== null && _a !== void 0 ? _a : []);
|
|
368
374
|
};
|
|
369
375
|
(0, Utilities_1.initializeComponentRef)(_this);
|
|
370
376
|
_this._createSet = (0, Utilities_1.memoizeFunction)(function (data) { return _this._createDataSetOfGVBC(data); });
|
|
@@ -388,7 +394,6 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
388
394
|
showXAxisGridLines: 'Dont use this property. Handling with default value.',
|
|
389
395
|
legendColor: 'Dont use this property. colour will pick from given data.',
|
|
390
396
|
});
|
|
391
|
-
_this._refArray = [];
|
|
392
397
|
_this._calloutId = (0, Utilities_1.getId)('callout');
|
|
393
398
|
_this._tooltipId = (0, Utilities_1.getId)('GVBCTooltipId_');
|
|
394
399
|
_this._emptyChartId = (0, Utilities_1.getId)('_GVBC_empty');
|
|
@@ -407,13 +412,13 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
407
412
|
};
|
|
408
413
|
GroupedVerticalBarChartBase.prototype.render = function () {
|
|
409
414
|
var _this = this;
|
|
410
|
-
var points = this.props.data;
|
|
411
|
-
var _a = this._createSet(points),
|
|
412
|
-
this.
|
|
415
|
+
var points = this._addDefaultColors(this.props.data);
|
|
416
|
+
var _a = this._createSet(points), legends = _a.legends, xAxisLabels = _a.xAxisLabels, datasetForBars = _a.datasetForBars;
|
|
417
|
+
this._legends = legends;
|
|
413
418
|
this._xAxisLabels = xAxisLabels;
|
|
414
419
|
this._datasetForBars = datasetForBars;
|
|
415
420
|
this._xAxisType = (0, index_1.getTypeOfAxis)(points[0].name, true);
|
|
416
|
-
var
|
|
421
|
+
var legendBars = this._getLegendData();
|
|
417
422
|
this._adjustProps();
|
|
418
423
|
// The maxOfYVal prop is only required for the primary y-axis, so yMax should be calculated
|
|
419
424
|
// using only the data points associated with the primary y-axis.
|
|
@@ -429,7 +434,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
429
434
|
tickValues: this.props.tickValues,
|
|
430
435
|
tickFormat: this.props.tickFormat,
|
|
431
436
|
};
|
|
432
|
-
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:
|
|
437
|
+
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: {
|
|
433
438
|
direction: react_focus_1.FocusZoneDirection.horizontal,
|
|
434
439
|
}, customizedCallout: this._getCustomizedCallout(), getmargins: this._getMargins, getGraphData: this._getGraphData, getAxisData: this._getAxisData, onChartMouseLeave: this._handleChartMouseLeave, getDomainMargins: this._getDomainMargins }, (this._xAxisType === index_1.XAxisTypes.StringAxis && {
|
|
435
440
|
xAxisInnerPadding: this._xAxisInnerPadding,
|
|
@@ -448,9 +453,6 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
448
453
|
enumerable: false,
|
|
449
454
|
configurable: true
|
|
450
455
|
});
|
|
451
|
-
GroupedVerticalBarChartBase.prototype._refCallback = function (element, legendTitle, refIndexNumber) {
|
|
452
|
-
this._refArray[refIndexNumber] = { index: legendTitle, refElement: element };
|
|
453
|
-
};
|
|
454
456
|
GroupedVerticalBarChartBase.prototype._onLegendHover = function (legendTitle) {
|
|
455
457
|
this.setState({
|
|
456
458
|
activeLegend: legendTitle,
|
|
@@ -489,8 +491,8 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
|
|
|
489
491
|
this._barWidth = (0, index_1.getBarWidth)(this.props.barwidth, this.props.maxBarWidth);
|
|
490
492
|
// x0_inner_padding = space_between_groups / (space_between_groups + group_width)
|
|
491
493
|
// space_between_groups = 2 * bar_width
|
|
492
|
-
// group_width = this.
|
|
493
|
-
this._xAxisInnerPadding = (0, index_1.getScalePadding)(this.props.xAxisInnerPadding, undefined, 2 / (2 + this.
|
|
494
|
+
// group_width = this._legends.length * bar_width + (this._legends.length - 1) * space_between_bars
|
|
495
|
+
this._xAxisInnerPadding = (0, index_1.getScalePadding)(this.props.xAxisInnerPadding, undefined, 2 / (2 + this._legends.length + (this._legends.length - 1) * BAR_GAP_RATE));
|
|
494
496
|
this._xAxisOuterPadding = (0, index_1.getScalePadding)(this.props.xAxisOuterPadding);
|
|
495
497
|
};
|
|
496
498
|
GroupedVerticalBarChartBase.defaultProps = {
|