@fluentui/react-charting 5.23.32 → 5.23.34
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 +55 -1
- package/CHANGELOG.md +24 -2
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/lib/components/AreaChart/AreaChart.base.d.ts +4 -1
- package/lib/components/AreaChart/AreaChart.base.js +56 -35
- package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +9 -8
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.base.d.ts +3 -1
- package/lib/components/GaugeChart/GaugeChart.base.js +31 -20
- package/lib/components/GaugeChart/GaugeChart.base.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +11 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +55 -39
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.d.ts +3 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js +56 -51
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/AreaChart/AreaChart.base.d.ts +4 -1
- package/lib-amd/components/AreaChart/AreaChart.base.js +55 -34
- package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +9 -8
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-amd/components/GaugeChart/GaugeChart.base.d.ts +3 -1
- package/lib-amd/components/GaugeChart/GaugeChart.base.js +30 -19
- package/lib-amd/components/GaugeChart/GaugeChart.base.js.map +1 -1
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +11 -1
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +54 -38
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.d.ts +3 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +55 -50
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.base.d.ts +4 -1
- package/lib-commonjs/components/AreaChart/AreaChart.base.js +55 -34
- package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +9 -8
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.base.d.ts +3 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.base.js +30 -19
- package/lib-commonjs/components/GaugeChart/GaugeChart.base.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +11 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +54 -38
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.d.ts +3 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +55 -50
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/package.json +3 -3
|
@@ -8,7 +8,7 @@ import { classNamesFunction, getId, getRTL, initializeComponentRef } from '@flue
|
|
|
8
8
|
import { DirectionalHint } from '@fluentui/react/lib/Callout';
|
|
9
9
|
import { CartesianChart, ChartHoverCard, Legends, } from '../../index';
|
|
10
10
|
import { FocusZoneDirection } from '@fluentui/react-focus';
|
|
11
|
-
import { ChartTypes, getAccessibleDataObject, XAxisTypes, getTypeOfAxis, tooltipOfXAxislabels, formatValueWithSIPrefix, getBarWidth, getScalePadding, isScalePaddingDefined, calculateAppropriateBarWidth, findVerticalNumericMinMaxOfY, createNumericYAxis, domainRageOfVerticalNumeric, domainRangeOfDateForAreaLineVerticalBarChart, domainRangeOfXStringAxis, createStringYAxis, formatDate, getNextGradient, } from '../../utilities/index';
|
|
11
|
+
import { ChartTypes, getAccessibleDataObject, XAxisTypes, getTypeOfAxis, tooltipOfXAxislabels, formatValueWithSIPrefix, getBarWidth, getScalePadding, isScalePaddingDefined, calculateAppropriateBarWidth, findVerticalNumericMinMaxOfY, createNumericYAxis, domainRageOfVerticalNumeric, domainRangeOfDateForAreaLineVerticalBarChart, domainRangeOfXStringAxis, createStringYAxis, formatDate, getNextGradient, areArraysEqual, } from '../../utilities/index';
|
|
12
12
|
var CircleVisbility;
|
|
13
13
|
(function (CircleVisbility) {
|
|
14
14
|
CircleVisbility["show"] = "visibility";
|
|
@@ -19,7 +19,7 @@ var MIN_DOMAIN_MARGIN = 8;
|
|
|
19
19
|
var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
20
20
|
__extends(VerticalBarChartBase, _super);
|
|
21
21
|
function VerticalBarChartBase(props) {
|
|
22
|
-
var _a
|
|
22
|
+
var _a;
|
|
23
23
|
var _this = _super.call(this, props) || this;
|
|
24
24
|
_this._isRtl = getRTL();
|
|
25
25
|
_this._getDomainNRangeValues = function (points, margins, width, chartType, isRTL, xAxisType, barWidth, tickValues, shiftX) {
|
|
@@ -92,12 +92,12 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
92
92
|
dots));
|
|
93
93
|
};
|
|
94
94
|
_this._getCircleVisibilityAndRadius = function (xAxisPoint, legend) {
|
|
95
|
-
var
|
|
96
|
-
if (
|
|
97
|
-
if (xAxisPoint === activeXdataPoint &&
|
|
95
|
+
var activeXdataPoint = _this.state.activeXdataPoint;
|
|
96
|
+
if (!_this._noLegendHighlighted()) {
|
|
97
|
+
if (xAxisPoint === activeXdataPoint && _this._legendHighlighted(legend)) {
|
|
98
98
|
return { visibility: CircleVisbility.show, radius: 8 };
|
|
99
99
|
}
|
|
100
|
-
else if (
|
|
100
|
+
else if (_this._legendHighlighted(legend)) {
|
|
101
101
|
// Don't hide the circle to keep it focusable. For more information,
|
|
102
102
|
// see https://fuzzbomb.github.io/accessibility-demos/visually-hidden-focus-test.html
|
|
103
103
|
return { visibility: CircleVisbility.show, radius: 0.3 };
|
|
@@ -170,7 +170,9 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
170
170
|
: _this._createColors()(selectedPoint[0].y)
|
|
171
171
|
: _this._createColors()(1);
|
|
172
172
|
// there might be no y value of the line for the hovered bar. so we need to check this condition
|
|
173
|
-
if (_this._isHavingLine &&
|
|
173
|
+
if (_this._isHavingLine &&
|
|
174
|
+
((_a = selectedPoint[0].lineData) === null || _a === void 0 ? void 0 : _a.y) !== undefined &&
|
|
175
|
+
(_this._legendHighlighted(lineLegendText) || _this._noLegendHighlighted())) {
|
|
174
176
|
// callout data for the line
|
|
175
177
|
YValueHover.push({
|
|
176
178
|
legend: lineLegendText,
|
|
@@ -180,18 +182,20 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
180
182
|
yAxisCalloutData: (_d = selectedPoint[0].lineData) === null || _d === void 0 ? void 0 : _d.yAxisCalloutData,
|
|
181
183
|
});
|
|
182
184
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
?
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
185
|
+
if (_this._legendHighlighted(selectedPoint[0].legend) || _this._noLegendHighlighted()) {
|
|
186
|
+
// callout data for the bar
|
|
187
|
+
YValueHover.push({
|
|
188
|
+
legend: selectedPoint[0].legend,
|
|
189
|
+
y: selectedPoint[0].y,
|
|
190
|
+
color: enableGradient
|
|
191
|
+
? useSingleColor
|
|
192
|
+
? getNextGradient(0, 0)[0]
|
|
193
|
+
: ((_e = selectedPoint[0].gradient) === null || _e === void 0 ? void 0 : _e[0]) || getNextGradient(pointIndex, 0)[0]
|
|
194
|
+
: calloutColor,
|
|
195
|
+
data: selectedPoint[0].yAxisCalloutData,
|
|
196
|
+
yAxisCalloutData: selectedPoint[0].yAxisCalloutData,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
195
199
|
var hoverXValue = point.x instanceof Date ? formatDate(point.x, _this.props.useUTC) : point.x.toString();
|
|
196
200
|
return {
|
|
197
201
|
YValueHover: YValueHover,
|
|
@@ -217,7 +221,7 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
217
221
|
_this.setState({
|
|
218
222
|
refSelected: obj.refElement,
|
|
219
223
|
/** Show the callout if highlighted bar is focused and Hide it if unhighlighted bar is focused */
|
|
220
|
-
isCalloutVisible: _this.
|
|
224
|
+
isCalloutVisible: _this._noLegendHighlighted() || _this._legendHighlighted(point.legend),
|
|
221
225
|
calloutLegend: point.legend,
|
|
222
226
|
dataForHoverCard: point.y,
|
|
223
227
|
color: point.color || color,
|
|
@@ -322,9 +326,6 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
322
326
|
var legend = {
|
|
323
327
|
title: legendTitle,
|
|
324
328
|
color: color,
|
|
325
|
-
action: function () {
|
|
326
|
-
_this._onLegendClick(legendTitle);
|
|
327
|
-
},
|
|
328
329
|
hoverAction: function () {
|
|
329
330
|
_this._handleChartMouseLeave();
|
|
330
331
|
_this._onLegendHover(legendTitle);
|
|
@@ -339,9 +340,6 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
339
340
|
var lineLegend = {
|
|
340
341
|
title: lineLegendText,
|
|
341
342
|
color: lineLegendColor,
|
|
342
|
-
action: function () {
|
|
343
|
-
_this._onLegendClick(lineLegendText);
|
|
344
|
-
},
|
|
345
343
|
hoverAction: function () {
|
|
346
344
|
_this._handleChartMouseLeave();
|
|
347
345
|
_this._onLegendHover(lineLegendText);
|
|
@@ -353,7 +351,7 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
353
351
|
};
|
|
354
352
|
actions.unshift(lineLegend);
|
|
355
353
|
}
|
|
356
|
-
var legends = (React.createElement(Legends, __assign({ legends: actions, enabledWrapLines: _this.props.enabledLegendsWrapLines, overflowProps: _this.props.legendsOverflowProps, focusZonePropsInHoverCard: _this.props.focusZonePropsForLegendsInHoverCard, overflowText: _this.props.legendsOverflowText }, _this.props.legendProps)));
|
|
354
|
+
var legends = (React.createElement(Legends, __assign({ legends: actions, enabledWrapLines: _this.props.enabledLegendsWrapLines, overflowProps: _this.props.legendsOverflowProps, focusZonePropsInHoverCard: _this.props.focusZonePropsForLegendsInHoverCard, overflowText: _this.props.legendsOverflowText }, _this.props.legendProps, { onChange: _this._onLegendSelectionChange.bind(_this) })));
|
|
357
355
|
return legends;
|
|
358
356
|
};
|
|
359
357
|
_this._getAxisData = function (yAxisData) {
|
|
@@ -370,14 +368,13 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
370
368
|
* 2. hovering: if there is no selected legend and the user hovers over it
|
|
371
369
|
*/
|
|
372
370
|
_this._legendHighlighted = function (legendTitle) {
|
|
373
|
-
return
|
|
374
|
-
(_this.state.selectedLegend === '' && _this.state.activeLegend === legendTitle));
|
|
371
|
+
return _this._getHighlightedLegend().includes(legendTitle);
|
|
375
372
|
};
|
|
376
373
|
/**
|
|
377
374
|
* This function checks if none of the legends is selected or hovered.
|
|
378
375
|
*/
|
|
379
376
|
_this._noLegendHighlighted = function () {
|
|
380
|
-
return _this.
|
|
377
|
+
return _this._getHighlightedLegend().length === 0;
|
|
381
378
|
};
|
|
382
379
|
_this._getAriaLabel = function (point) {
|
|
383
380
|
var _a, _b, _c;
|
|
@@ -441,8 +438,8 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
441
438
|
dataForHoverCard: 0,
|
|
442
439
|
isCalloutVisible: false,
|
|
443
440
|
refSelected: null,
|
|
444
|
-
|
|
445
|
-
activeLegend:
|
|
441
|
+
selectedLegends: ((_a = props.legendProps) === null || _a === void 0 ? void 0 : _a.selectedLegends) || [],
|
|
442
|
+
activeLegend: undefined,
|
|
446
443
|
xCalloutValue: '',
|
|
447
444
|
yCalloutValue: '',
|
|
448
445
|
activeXdataPoint: null,
|
|
@@ -464,10 +461,10 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
464
461
|
return _this;
|
|
465
462
|
}
|
|
466
463
|
VerticalBarChartBase.prototype.componentDidUpdate = function (prevProps) {
|
|
467
|
-
var _a, _b, _c
|
|
468
|
-
if (((_a = prevProps.legendProps) === null || _a === void 0 ? void 0 : _a.
|
|
464
|
+
var _a, _b, _c;
|
|
465
|
+
if (!areArraysEqual((_a = prevProps.legendProps) === null || _a === void 0 ? void 0 : _a.selectedLegends, (_b = this.props.legendProps) === null || _b === void 0 ? void 0 : _b.selectedLegends)) {
|
|
469
466
|
this.setState({
|
|
470
|
-
|
|
467
|
+
selectedLegends: ((_c = this.props.legendProps) === null || _c === void 0 ? void 0 : _c.selectedLegends) || [],
|
|
471
468
|
});
|
|
472
469
|
}
|
|
473
470
|
};
|
|
@@ -490,7 +487,8 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
490
487
|
tickValues: this.props.tickValues,
|
|
491
488
|
tickFormat: this.props.tickFormat,
|
|
492
489
|
};
|
|
493
|
-
return !this._isChartEmpty() ? (React.createElement(CartesianChart, __assign({}, this.props, { chartTitle: this._getChartTitle(), points: this._points, supportNegativeData: this.props.supportNegativeData, chartType: ChartTypes.VerticalBarChart, xAxisType: this._xAxisType, createYAxis: createNumericYAxis, calloutProps: calloutProps, tickParams: tickParams }, (this._isHavingLine &&
|
|
490
|
+
return !this._isChartEmpty() ? (React.createElement(CartesianChart, __assign({}, this.props, { chartTitle: this._getChartTitle(), points: this._points, supportNegativeData: this.props.supportNegativeData, chartType: ChartTypes.VerticalBarChart, xAxisType: this._xAxisType, createYAxis: createNumericYAxis, calloutProps: calloutProps, tickParams: tickParams }, (this._isHavingLine &&
|
|
491
|
+
(this._noLegendHighlighted() || this._getHighlightedLegend().length > 1) && { isCalloutForStack: true }), { legendBars: legendBars, datasetForXAxisDomain: this._xAxisLabels, barwidth: this._barWidth, focusZoneDirection: FocusZoneDirection.horizontal, customizedCallout: this._getCustomizedCallout(), createStringYAxis: createStringYAxis, getmargins: this._getMargins, getMinMaxOfYAxis: findVerticalNumericMinMaxOfY, getGraphData: this._getGraphData, getDomainNRangeValues: this._getDomainNRangeValues, getAxisData: this._getAxisData, onChartMouseLeave: this._handleChartMouseLeave, getDomainMargins: this._getDomainMargins }, (this._xAxisType === XAxisTypes.StringAxis && {
|
|
494
492
|
xAxisInnerPadding: this._xAxisInnerPadding,
|
|
495
493
|
xAxisOuterPadding: this._xAxisOuterPadding,
|
|
496
494
|
}), { ref: this._cartesianChartRef,
|
|
@@ -543,7 +541,7 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
543
541
|
this.setState({
|
|
544
542
|
refSelected: mouseEvent,
|
|
545
543
|
/** Show the callout if highlighted bar is hovered and Hide it if unhighlighted bar is hovered */
|
|
546
|
-
isCalloutVisible: this.
|
|
544
|
+
isCalloutVisible: this._noLegendHighlighted() || this._legendHighlighted(point.legend),
|
|
547
545
|
dataForHoverCard: point.y,
|
|
548
546
|
calloutLegend: point.legend,
|
|
549
547
|
color: point.color || color,
|
|
@@ -553,7 +551,7 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
553
551
|
yCalloutValue: point.yAxisCalloutData,
|
|
554
552
|
dataPointCalloutProps: point,
|
|
555
553
|
// Hovering over a bar should highlight corresponding line points only when no legend is selected
|
|
556
|
-
activeXdataPoint: this._noLegendHighlighted() ? point.x : null,
|
|
554
|
+
activeXdataPoint: this._noLegendHighlighted() || this._legendHighlighted(point.legend) ? point.x : null,
|
|
557
555
|
YValueHover: YValueHover,
|
|
558
556
|
hoverXValue: hoverXValue,
|
|
559
557
|
callOutAccessibilityData: point.callOutAccessibilityData,
|
|
@@ -805,18 +803,6 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
805
803
|
}
|
|
806
804
|
return bars;
|
|
807
805
|
};
|
|
808
|
-
VerticalBarChartBase.prototype._onLegendClick = function (legendTitle) {
|
|
809
|
-
if (this.state.selectedLegend === legendTitle) {
|
|
810
|
-
this.setState({
|
|
811
|
-
selectedLegend: '',
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
else {
|
|
815
|
-
this.setState({
|
|
816
|
-
selectedLegend: legendTitle,
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
};
|
|
820
806
|
VerticalBarChartBase.prototype._onLegendHover = function (legendTitle) {
|
|
821
807
|
this.setState({
|
|
822
808
|
activeLegend: legendTitle,
|
|
@@ -824,9 +810,28 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
824
810
|
};
|
|
825
811
|
VerticalBarChartBase.prototype._onLegendLeave = function () {
|
|
826
812
|
this.setState({
|
|
827
|
-
activeLegend:
|
|
813
|
+
activeLegend: undefined,
|
|
828
814
|
});
|
|
829
815
|
};
|
|
816
|
+
VerticalBarChartBase.prototype._onLegendSelectionChange = function (selectedLegends, event, currentLegend) {
|
|
817
|
+
var _a, _b;
|
|
818
|
+
if ((_a = this.props.legendProps) === null || _a === void 0 ? void 0 : _a.canSelectMultipleLegends) {
|
|
819
|
+
this.setState({ selectedLegends: selectedLegends });
|
|
820
|
+
}
|
|
821
|
+
else {
|
|
822
|
+
this.setState({ selectedLegends: selectedLegends.slice(-1) });
|
|
823
|
+
}
|
|
824
|
+
if ((_b = this.props.legendProps) === null || _b === void 0 ? void 0 : _b.onChange) {
|
|
825
|
+
this.props.legendProps.onChange(selectedLegends, event, currentLegend);
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
VerticalBarChartBase.prototype._getHighlightedLegend = function () {
|
|
829
|
+
return this.state.selectedLegends.length > 0
|
|
830
|
+
? this.state.selectedLegends
|
|
831
|
+
: this.state.activeLegend
|
|
832
|
+
? [this.state.activeLegend]
|
|
833
|
+
: [];
|
|
834
|
+
};
|
|
830
835
|
VerticalBarChartBase.prototype._renderBarLabel = function (xPoint, yPoint, barValue, legend, isNegativeBar) {
|
|
831
836
|
if (this.props.hideLabels ||
|
|
832
837
|
this._barWidth < 16 ||
|