@fluentui/react-charting 5.16.19 → 5.16.21
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 +31 -1
- package/CHANGELOG.md +20 -2
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/lib/components/LineChart/LineChart.base.d.ts +6 -2
- package/lib/components/LineChart/LineChart.base.js +62 -46
- package/lib/components/LineChart/LineChart.base.js.map +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.base.d.ts +6 -2
- package/lib-amd/components/LineChart/LineChart.base.js +62 -46
- package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-amd/version.js +1 -1
- package/lib-amd/version.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.base.d.ts +6 -2
- package/lib-commonjs/components/LineChart/LineChart.base.js +62 -46
- package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-commonjs/version.js +1 -1
- package/lib-commonjs/version.js.map +1 -1
- package/package.json +3 -3
|
@@ -323,7 +323,6 @@ var LineChartBase = /** @class */ (function (_super) {
|
|
|
323
323
|
// if no points need to be called out then don't show vertical line and callout card
|
|
324
324
|
if (found) {
|
|
325
325
|
var _this_2 = _this_1;
|
|
326
|
-
d3_selection_1.select('#' + circleId).attr('aria-labelledby', "toolTip" + _this_1._uniqueCallOutID);
|
|
327
326
|
d3_selection_1.select("#" + _this_1._verticalLine)
|
|
328
327
|
.attr('transform', function () { return "translate(" + _this_2._xAxisScale(x) + ", 0)"; })
|
|
329
328
|
.attr('visibility', 'visibility');
|
|
@@ -384,15 +383,17 @@ var LineChartBase = /** @class */ (function (_super) {
|
|
|
384
383
|
});
|
|
385
384
|
}
|
|
386
385
|
};
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
_this_1._onDataPointClick = function (func) {
|
|
386
|
+
/**
|
|
387
|
+
* Screen readers announce an element as clickable if the onClick attribute is set.
|
|
388
|
+
* This function sets the attribute only when a click event handler is provided.
|
|
389
|
+
*/
|
|
390
|
+
_this_1._getClickHandler = function (func) {
|
|
393
391
|
if (func) {
|
|
394
|
-
|
|
392
|
+
return {
|
|
393
|
+
onClick: func,
|
|
394
|
+
};
|
|
395
395
|
}
|
|
396
|
+
return {};
|
|
396
397
|
};
|
|
397
398
|
_this_1._handleMouseOut = function () {
|
|
398
399
|
d3_selection_1.select("#" + _this_1._verticalLine).attr('visibility', 'hidden');
|
|
@@ -515,6 +516,16 @@ var LineChartBase = /** @class */ (function (_super) {
|
|
|
515
516
|
_this_1._getColorFillBarOpacity = function (colorFillBar) {
|
|
516
517
|
return colorFillBar.applyPattern ? 1 : 0.4;
|
|
517
518
|
};
|
|
519
|
+
_this_1._getAriaLabel = function (lineIndex, pointIndex) {
|
|
520
|
+
var _a;
|
|
521
|
+
var line = _this_1._points[lineIndex];
|
|
522
|
+
var point = line.data[pointIndex];
|
|
523
|
+
var formattedDate = point.x instanceof Date ? point.x.toLocaleString() : point.x;
|
|
524
|
+
var xValue = point.xAxisCalloutData || formattedDate;
|
|
525
|
+
var legend = line.legend;
|
|
526
|
+
var yValue = point.yAxisCalloutData || point.y;
|
|
527
|
+
return ((_a = point.callOutAccessibilityData) === null || _a === void 0 ? void 0 : _a.ariaLabel) || xValue + ". " + legend + ", " + yValue + ".";
|
|
528
|
+
};
|
|
518
529
|
_this_1.state = {
|
|
519
530
|
hoverXValue: '',
|
|
520
531
|
activeLegend: '',
|
|
@@ -660,60 +671,62 @@ var LineChartBase = /** @class */ (function (_super) {
|
|
|
660
671
|
else {
|
|
661
672
|
this._points = this._injectIndexPropertyInLineChartData(this.props.data.lineChartData);
|
|
662
673
|
}
|
|
663
|
-
|
|
674
|
+
var _loop_1 = function (i) {
|
|
664
675
|
var linesForLine = [];
|
|
665
676
|
var bordersForLine = [];
|
|
666
677
|
var pointsForLine = [];
|
|
667
|
-
var legendVal =
|
|
668
|
-
var lineColor =
|
|
669
|
-
var activePoint =
|
|
670
|
-
var theme =
|
|
671
|
-
var verticaLineHeight = containerHeight -
|
|
672
|
-
if (
|
|
673
|
-
var _0 =
|
|
674
|
-
var
|
|
675
|
-
pointsForLine.push(React.createElement("circle", { id:
|
|
678
|
+
var legendVal = this_1._points[i].legend;
|
|
679
|
+
var lineColor = this_1._points[i].color;
|
|
680
|
+
var activePoint = this_1.state.activePoint;
|
|
681
|
+
var theme = this_1.props.theme;
|
|
682
|
+
var verticaLineHeight = containerHeight - this_1.margins.bottom + 6;
|
|
683
|
+
if (this_1._points[i].data.length === 1) {
|
|
684
|
+
var _0 = this_1._points[i].data[0], x1_1 = _0.x, y1 = _0.y, xAxisCalloutData_1 = _0.xAxisCalloutData, xAxisCalloutAccessibilityData_1 = _0.xAxisCalloutAccessibilityData;
|
|
685
|
+
var circleId_1 = this_1._circleId + "_" + i;
|
|
686
|
+
pointsForLine.push(React.createElement("circle", tslib_1.__assign({ id: circleId_1, key: circleId_1, r: activePoint === circleId_1 ? 5.5 : 3.5, cx: this_1._xAxisScale(x1_1), cy: this_1._yAxisScale(y1), fill: activePoint === circleId_1 ? theme.palette.white : lineColor, onMouseOver: this_1._handleHover.bind(this_1, x1_1, y1, verticaLineHeight, xAxisCalloutData_1, circleId_1, xAxisCalloutAccessibilityData_1), onMouseMove: this_1._handleHover.bind(this_1, x1_1, y1, verticaLineHeight, xAxisCalloutData_1, circleId_1, xAxisCalloutAccessibilityData_1), onMouseOut: this_1._handleMouseOut, strokeWidth: activePoint === circleId_1 ? DEFAULT_LINE_STROKE_SIZE : 0, stroke: activePoint === circleId_1 ? lineColor : '', role: "img", "aria-label": this_1._getAriaLabel(i, 0), "data-is-focusable": true, ref: function (e) {
|
|
687
|
+
_this_1._refCallback(e, circleId_1);
|
|
688
|
+
}, onFocus: function () { return _this_1._handleFocus(circleId_1, x1_1, xAxisCalloutData_1, circleId_1, xAxisCalloutAccessibilityData_1); }, onBlur: this_1._handleMouseOut }, this_1._getClickHandler(this_1._points[i].data[0].onDataPointClick))));
|
|
676
689
|
}
|
|
677
690
|
var gapIndex = 0;
|
|
678
|
-
var gaps = (_b = (_a =
|
|
691
|
+
var gaps = (_b = (_a = this_1._points[i].gaps) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.startIndex - b.startIndex; })) !== null && _b !== void 0 ? _b : [];
|
|
679
692
|
// Use path rendering technique for larger datasets to optimize performance.
|
|
680
|
-
if (
|
|
693
|
+
if (this_1.props.optimizeLargeData && this_1._points[i].data.length > 1) {
|
|
681
694
|
var line = d3_shape_1.line()
|
|
682
695
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
683
696
|
.x(function (d) { return _this_1._xAxisScale(d[0]); })
|
|
684
697
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
685
698
|
.y(function (d) { return _this_1._yAxisScale(d[1]); })
|
|
686
699
|
.curve(d3_shape_1.curveLinear);
|
|
687
|
-
var lineId =
|
|
688
|
-
var borderId =
|
|
689
|
-
var strokeWidth = ((_c =
|
|
690
|
-
var isLegendSelected =
|
|
700
|
+
var lineId = this_1._lineId + "_" + i;
|
|
701
|
+
var borderId = this_1._borderId + "_" + i;
|
|
702
|
+
var strokeWidth = ((_c = this_1._points[i].lineOptions) === null || _c === void 0 ? void 0 : _c.strokeWidth) || this_1.props.strokeWidth || DEFAULT_LINE_STROKE_SIZE;
|
|
703
|
+
var isLegendSelected = this_1._legendHighlighted(legendVal) || this_1._noLegendHighlighted() || this_1.state.isSelectedLegend;
|
|
691
704
|
var lineData = [];
|
|
692
|
-
for (var k = 0; k <
|
|
705
|
+
for (var k = 0; k < this_1._points[i].data.length; k++) {
|
|
693
706
|
lineData.push([
|
|
694
|
-
|
|
695
|
-
?
|
|
696
|
-
:
|
|
697
|
-
|
|
707
|
+
this_1._points[i].data[k].x instanceof Date
|
|
708
|
+
? this_1._points[i].data[k].x.getTime()
|
|
709
|
+
: this_1._points[i].data[k].x,
|
|
710
|
+
this_1._points[i].data[k].y,
|
|
698
711
|
]);
|
|
699
712
|
}
|
|
700
713
|
if (isLegendSelected) {
|
|
701
|
-
var lineBorderWidth = ((_d =
|
|
702
|
-
? Number.parseFloat(
|
|
714
|
+
var lineBorderWidth = ((_d = this_1._points[i].lineOptions) === null || _d === void 0 ? void 0 : _d.lineBorderWidth)
|
|
715
|
+
? Number.parseFloat(this_1._points[i].lineOptions.lineBorderWidth.toString())
|
|
703
716
|
: 0;
|
|
704
717
|
if (lineBorderWidth > 0) {
|
|
705
|
-
bordersForLine.push(React.createElement("path", { id: borderId, key: borderId, d: line(lineData), fill: "transparent", strokeLinecap: (_f = (_e =
|
|
718
|
+
bordersForLine.push(React.createElement("path", { id: borderId, key: borderId, d: line(lineData), fill: "transparent", strokeLinecap: (_f = (_e = this_1._points[i].lineOptions) === null || _e === void 0 ? void 0 : _e.strokeLinecap) !== null && _f !== void 0 ? _f : 'round', strokeWidth: Number.parseFloat(strokeWidth.toString()) + lineBorderWidth, stroke: ((_g = this_1._points[i].lineOptions) === null || _g === void 0 ? void 0 : _g.lineBorderColor) || theme.palette.white, opacity: 1 }));
|
|
706
719
|
}
|
|
707
|
-
linesForLine.push(React.createElement("path", { id: lineId, key: lineId, d: line(lineData), fill: "transparent", "data-is-focusable": true, stroke: lineColor, strokeWidth: strokeWidth, strokeLinecap: (_j = (_h =
|
|
720
|
+
linesForLine.push(React.createElement("path", tslib_1.__assign({ id: lineId, key: lineId, d: line(lineData), fill: "transparent", "data-is-focusable": true, stroke: lineColor, strokeWidth: strokeWidth, strokeLinecap: (_j = (_h = this_1._points[i].lineOptions) === null || _h === void 0 ? void 0 : _h.strokeLinecap) !== null && _j !== void 0 ? _j : 'round', onMouseMove: this_1._onMouseOverLargeDataset.bind(this_1, i, verticaLineHeight), onMouseOver: this_1._onMouseOverLargeDataset.bind(this_1, i, verticaLineHeight), onMouseOut: this_1._handleMouseOut }, this_1._getClickHandler(this_1._points[i].onLineClick), { opacity: 1, role: "img", "aria-label": legendVal + ", series " + (i + 1) + " of " + this_1._points.length + " with " + this_1._points[i].data.length + " data points." })));
|
|
708
721
|
}
|
|
709
722
|
else {
|
|
710
|
-
linesForLine.push(React.createElement("path", { id: lineId, key: lineId, d: line(lineData), fill: "transparent", "data-is-focusable": true, stroke: lineColor, strokeWidth: strokeWidth, strokeLinecap: (_l = (_k =
|
|
723
|
+
linesForLine.push(React.createElement("path", { id: lineId, key: lineId, d: line(lineData), fill: "transparent", "data-is-focusable": true, stroke: lineColor, strokeWidth: strokeWidth, strokeLinecap: (_l = (_k = this_1._points[i].lineOptions) === null || _k === void 0 ? void 0 : _k.strokeLinecap) !== null && _l !== void 0 ? _l : 'round', opacity: 0.1, role: "img", "aria-label": legendVal + ", series " + (i + 1) + " of " + this_1._points.length + " with " + this_1._points[i].data.length + " data points." }));
|
|
711
724
|
}
|
|
712
|
-
var isPointHighlighted =
|
|
713
|
-
pointsForLine.push(React.createElement("circle", { id:
|
|
725
|
+
var isPointHighlighted = this_1.state.activeLine !== null && this_1.state.activeLine === i;
|
|
726
|
+
pointsForLine.push(React.createElement("circle", { id: this_1._staticHighlightCircle + "_" + i, key: this_1._staticHighlightCircle + "_" + i, r: 5.5, cx: 0, cy: 0, fill: theme.palette.white, strokeWidth: DEFAULT_LINE_STROKE_SIZE, stroke: lineColor, visibility: isPointHighlighted ? 'visibility' : 'hidden', onMouseMove: this_1._onMouseOverLargeDataset.bind(this_1, i, verticaLineHeight), onMouseOver: this_1._onMouseOverLargeDataset.bind(this_1, i, verticaLineHeight), onMouseOut: this_1._handleMouseOut }));
|
|
714
727
|
}
|
|
715
|
-
else {
|
|
716
|
-
var
|
|
728
|
+
else if (!this_1.props.optimizeLargeData) {
|
|
729
|
+
var _loop_2 = function (j) {
|
|
717
730
|
var gapResult = this_1._checkInGap(j, gaps, gapIndex);
|
|
718
731
|
var isInGap = gapResult.isInGap;
|
|
719
732
|
gapIndex = gapResult.gapIndex;
|
|
@@ -726,16 +739,16 @@ var LineChartBase = /** @class */ (function (_super) {
|
|
|
726
739
|
var strokeWidth = ((_m = this_1._points[i].lineOptions) === null || _m === void 0 ? void 0 : _m.strokeWidth) || this_1.props.strokeWidth || DEFAULT_LINE_STROKE_SIZE;
|
|
727
740
|
var isLegendSelected = this_1._legendHighlighted(legendVal) || this_1._noLegendHighlighted() || this_1.state.isSelectedLegend;
|
|
728
741
|
var currentPointHidden = this_1._points[i].hideNonActiveDots && activePoint !== circleId;
|
|
729
|
-
pointsForLine.push(React.createElement("path", { id: circleId, key: circleId, d: path, "data-is-focusable": true, onMouseOver: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseMove: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseOut: this_1._handleMouseOut, onFocus: function () { return _this_1._handleFocus(lineId, x1, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData); }, onBlur: this_1._handleMouseOut,
|
|
742
|
+
pointsForLine.push(React.createElement("path", tslib_1.__assign({ id: circleId, key: circleId, d: path, "data-is-focusable": true, onMouseOver: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseMove: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseOut: this_1._handleMouseOut, onFocus: function () { return _this_1._handleFocus(lineId, x1, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData); }, onBlur: this_1._handleMouseOut }, this_1._getClickHandler(this_1._points[i].data[j - 1].onDataPointClick), { opacity: isLegendSelected && !currentPointHidden ? 1 : 0.01, fill: this_1._getPointFill(lineColor, circleId, j, false), stroke: lineColor, strokeWidth: strokeWidth, role: "img", "aria-label": this_1._getAriaLabel(i, j - 1) })));
|
|
730
743
|
if (j + 1 === this_1._points[i].data.length) {
|
|
731
744
|
// If this is last point of the line segment.
|
|
732
745
|
var lastCircleId_1 = "" + circleId + j + "L";
|
|
733
746
|
var lastPointHidden = this_1._points[i].hideNonActiveDots && activePoint !== lastCircleId_1;
|
|
734
747
|
path = this_1._getPath(this_1._xAxisScale(x2), this_1._yAxisScale(y2), lastCircleId_1, j, true, this_1._points[i].index);
|
|
735
748
|
var _3 = this_1._points[i].data[j], lastCirlceXCallout_1 = _3.xAxisCalloutData, lastCirlceXCalloutAccessibilityData_1 = _3.xAxisCalloutAccessibilityData;
|
|
736
|
-
pointsForLine.push(React.createElement("path", { id: lastCircleId_1, key: lastCircleId_1, d: path, "data-is-focusable": true, onMouseOver: this_1._handleHover.bind(this_1, x2, y2, verticaLineHeight, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1), onMouseMove: this_1._handleHover.bind(this_1, x2, y2, verticaLineHeight, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1), onMouseOut: this_1._handleMouseOut, onFocus: function () {
|
|
749
|
+
pointsForLine.push(React.createElement("path", tslib_1.__assign({ id: lastCircleId_1, key: lastCircleId_1, d: path, "data-is-focusable": true, onMouseOver: this_1._handleHover.bind(this_1, x2, y2, verticaLineHeight, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1), onMouseMove: this_1._handleHover.bind(this_1, x2, y2, verticaLineHeight, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1), onMouseOut: this_1._handleMouseOut, onFocus: function () {
|
|
737
750
|
return _this_1._handleFocus(lineId, x2, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1);
|
|
738
|
-
}, onBlur: this_1._handleMouseOut,
|
|
751
|
+
}, onBlur: this_1._handleMouseOut }, this_1._getClickHandler(this_1._points[i].data[j].onDataPointClick), { opacity: isLegendSelected && !lastPointHidden ? 1 : 0.01, fill: this_1._getPointFill(lineColor, lastCircleId_1, j, true), stroke: lineColor, strokeWidth: strokeWidth, role: "img", "aria-label": this_1._getAriaLabel(i, j) })));
|
|
739
752
|
/* eslint-enable react/jsx-no-bind */
|
|
740
753
|
}
|
|
741
754
|
if (isLegendSelected) {
|
|
@@ -747,9 +760,9 @@ var LineChartBase = /** @class */ (function (_super) {
|
|
|
747
760
|
if (lineBorderWidth > 0) {
|
|
748
761
|
bordersForLine.push(React.createElement("line", { id: borderId, key: borderId, x1: this_1._xAxisScale(x1), y1: this_1._yAxisScale(y1), x2: this_1._xAxisScale(x2), y2: this_1._yAxisScale(y2), strokeLinecap: (_q = (_p = this_1._points[i].lineOptions) === null || _p === void 0 ? void 0 : _p.strokeLinecap) !== null && _q !== void 0 ? _q : 'round', strokeWidth: Number.parseFloat(strokeWidth.toString()) + lineBorderWidth, stroke: ((_r = this_1._points[i].lineOptions) === null || _r === void 0 ? void 0 : _r.lineBorderColor) || theme.palette.white, opacity: 1 }));
|
|
749
762
|
}
|
|
750
|
-
linesForLine.push(React.createElement("line", { id: lineId, key: lineId, x1: this_1._xAxisScale(x1), y1: this_1._yAxisScale(y1), x2: this_1._xAxisScale(x2), y2: this_1._yAxisScale(y2), strokeWidth: strokeWidth, ref: function (e) {
|
|
763
|
+
linesForLine.push(React.createElement("line", tslib_1.__assign({ id: lineId, key: lineId, x1: this_1._xAxisScale(x1), y1: this_1._yAxisScale(y1), x2: this_1._xAxisScale(x2), y2: this_1._yAxisScale(y2), strokeWidth: strokeWidth, ref: function (e) {
|
|
751
764
|
_this_1._refCallback(e, lineId);
|
|
752
|
-
}, onMouseOver: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseMove: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseOut: this_1._handleMouseOut, stroke: lineColor, strokeLinecap: (_t = (_s = this_1._points[i].lineOptions) === null || _s === void 0 ? void 0 : _s.strokeLinecap) !== null && _t !== void 0 ? _t : 'round', strokeDasharray: (_u = this_1._points[i].lineOptions) === null || _u === void 0 ? void 0 : _u.strokeDasharray, strokeDashoffset: (_v = this_1._points[i].lineOptions) === null || _v === void 0 ? void 0 : _v.strokeDashoffset, opacity: 1,
|
|
765
|
+
}, onMouseOver: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseMove: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseOut: this_1._handleMouseOut, stroke: lineColor, strokeLinecap: (_t = (_s = this_1._points[i].lineOptions) === null || _s === void 0 ? void 0 : _s.strokeLinecap) !== null && _t !== void 0 ? _t : 'round', strokeDasharray: (_u = this_1._points[i].lineOptions) === null || _u === void 0 ? void 0 : _u.strokeDasharray, strokeDashoffset: (_v = this_1._points[i].lineOptions) === null || _v === void 0 ? void 0 : _v.strokeDashoffset, opacity: 1 }, this_1._getClickHandler(this_1._points[i].onLineClick))));
|
|
753
766
|
}
|
|
754
767
|
}
|
|
755
768
|
else {
|
|
@@ -758,12 +771,15 @@ var LineChartBase = /** @class */ (function (_super) {
|
|
|
758
771
|
}
|
|
759
772
|
}
|
|
760
773
|
};
|
|
761
|
-
var
|
|
762
|
-
|
|
763
|
-
_loop_1(j);
|
|
774
|
+
for (var j = 1; j < this_1._points[i].data.length; j++) {
|
|
775
|
+
_loop_2(j);
|
|
764
776
|
}
|
|
765
777
|
}
|
|
766
778
|
lines.push.apply(lines, tslib_1.__spreadArray(tslib_1.__spreadArray(tslib_1.__spreadArray([], bordersForLine), linesForLine), pointsForLine));
|
|
779
|
+
};
|
|
780
|
+
var this_1 = this;
|
|
781
|
+
for (var i = this._points.length - 1; i >= 0; i--) {
|
|
782
|
+
_loop_1(i);
|
|
767
783
|
}
|
|
768
784
|
var classNames = getClassNames(this.props.styles, {
|
|
769
785
|
theme: this.props.theme,
|