@fluentui/react-charting 5.12.8 → 5.12.9
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.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/lib/components/LineChart/LineChart.base.d.ts +4 -1
- package/lib/components/LineChart/LineChart.base.js +185 -44
- package/lib/components/LineChart/LineChart.base.js.map +1 -1
- package/lib/components/LineChart/LineChart.types.d.ts +1 -0
- package/lib/components/LineChart/LineChart.types.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 +4 -1
- package/lib-amd/components/LineChart/LineChart.base.js +183 -44
- package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.types.d.ts +1 -0
- package/lib-amd/components/LineChart/LineChart.types.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 +4 -1
- package/lib-commonjs/components/LineChart/LineChart.base.js +184 -43
- package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.d.ts +1 -0
- package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
- package/lib-commonjs/version.js +1 -1
- package/lib-commonjs/version.js.map +1 -1
- package/package.json +4 -4
- package/src/components/LineChart/LineChart.types.ts +7 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "tslib", "react", "d3-selection", "../Legends/index", "@fluentui/react/lib/Utilities", "../../index", "@fluentui/react/lib/Callout", "./eventAnnotation/EventAnnotation", "../../utilities/index"], function (require, exports, tslib_1, React, d3_selection_1, index_1, Utilities_1, index_2, Callout_1, EventAnnotation_1, index_3) {
|
|
1
|
+
define(["require", "exports", "tslib", "react", "d3-selection", "d3-array", "../Legends/index", "d3-shape", "@fluentui/react/lib/Utilities", "../../index", "@fluentui/react/lib/Callout", "./eventAnnotation/EventAnnotation", "../../utilities/index"], function (require, exports, tslib_1, React, d3_selection_1, d3_array_1, index_1, d3_shape_1, Utilities_1, index_2, Callout_1, EventAnnotation_1, index_3) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.LineChartBase = void 0;
|
|
@@ -8,6 +8,8 @@ define(["require", "exports", "tslib", "react", "d3-selection", "../Legends/inde
|
|
|
8
8
|
PointSize[PointSize["hoverSize"] = 11] = "hoverSize";
|
|
9
9
|
PointSize[PointSize["invisibleSize"] = 1] = "invisibleSize";
|
|
10
10
|
})(PointSize || (PointSize = {}));
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
var bisect = d3_array_1.bisector(function (d) { return d.x; }).left;
|
|
11
13
|
var DEFAULT_LINE_STROKE_SIZE = 4;
|
|
12
14
|
// The given shape of a icon must be 2.5 times bigger than line width (known as stroke width)
|
|
13
15
|
var PATH_MULTIPLY_SIZE = 2.5;
|
|
@@ -204,6 +206,97 @@ define(["require", "exports", "tslib", "react", "d3-selection", "../Legends/inde
|
|
|
204
206
|
}
|
|
205
207
|
return { isInGap: isInGap, gapIndex: gapIndex };
|
|
206
208
|
};
|
|
209
|
+
_this_1._onMouseOverLargeDataset = function (linenumber, lineHeight, mouseEvent) {
|
|
210
|
+
// Run this code for different scenarios. For data and numeric data. Try to satisfy undefined d0/d1 scenario.
|
|
211
|
+
mouseEvent.persist();
|
|
212
|
+
var data = _this_1.props.data;
|
|
213
|
+
var lineChartData = data.lineChartData;
|
|
214
|
+
// This will get the value of the X when mouse is on the chart
|
|
215
|
+
var xOffset = _this_1._xAxisScale.invert(mouseEvent.pageX - 15); //Todo - fix this
|
|
216
|
+
var i = bisect(lineChartData[linenumber].data, xOffset);
|
|
217
|
+
var d0 = lineChartData[linenumber].data[i - 1];
|
|
218
|
+
var d1 = lineChartData[linenumber].data[i];
|
|
219
|
+
var axisType = null;
|
|
220
|
+
var xPointToHighlight = null;
|
|
221
|
+
var index = null;
|
|
222
|
+
if (d0 === undefined && d1 !== undefined) {
|
|
223
|
+
xPointToHighlight = d1.x;
|
|
224
|
+
index = i;
|
|
225
|
+
}
|
|
226
|
+
else if (d0 !== undefined && d1 === undefined) {
|
|
227
|
+
xPointToHighlight = d0.x;
|
|
228
|
+
index = i - 1;
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
axisType = index_3.getTypeOfAxis(lineChartData[linenumber].data[0].x, true);
|
|
232
|
+
var x0 = void 0;
|
|
233
|
+
var point0 = void 0;
|
|
234
|
+
var point1 = void 0;
|
|
235
|
+
switch (axisType) {
|
|
236
|
+
case index_3.XAxisTypes.DateAxis:
|
|
237
|
+
x0 = new Date(xOffset).getTime();
|
|
238
|
+
point0 = d0.x.getTime();
|
|
239
|
+
point1 = d1.x.getTime();
|
|
240
|
+
xPointToHighlight = Math.abs(x0 - point0) > Math.abs(x0 - point1) ? d1.x : d0.x;
|
|
241
|
+
index = Math.abs(x0 - point0) > Math.abs(x0 - point1) ? i : i - 1;
|
|
242
|
+
break;
|
|
243
|
+
case index_3.XAxisTypes.NumericAxis:
|
|
244
|
+
x0 = xOffset;
|
|
245
|
+
point0 = d0.x;
|
|
246
|
+
point1 = d1.x;
|
|
247
|
+
xPointToHighlight = Math.abs(x0 - point0) > Math.abs(x0 - point1) ? d1.x : d0.x;
|
|
248
|
+
index = Math.abs(x0 - point0) > Math.abs(x0 - point1) ? i : i - 1;
|
|
249
|
+
break;
|
|
250
|
+
default:
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
var _a = lineChartData[linenumber].data[index], xAxisCalloutData = _a.xAxisCalloutData, xAxisCalloutAccessibilityData = _a.xAxisCalloutAccessibilityData;
|
|
255
|
+
var formattedDate = xPointToHighlight instanceof Date ? xPointToHighlight.toLocaleString() : xPointToHighlight;
|
|
256
|
+
var modifiedXVal = xPointToHighlight instanceof Date ? xPointToHighlight.getTime() : xPointToHighlight;
|
|
257
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
258
|
+
var found = Utilities_1.find(_this_1._calloutPoints, function (element) {
|
|
259
|
+
return element.x === modifiedXVal;
|
|
260
|
+
});
|
|
261
|
+
var pointToHighlight = lineChartData[linenumber].data[index];
|
|
262
|
+
var pointToHighlightUpdated = _this_1.state.nearestCircleToHighlight === null ||
|
|
263
|
+
(_this_1.state.nearestCircleToHighlight !== null &&
|
|
264
|
+
pointToHighlight !== null &&
|
|
265
|
+
(_this_1.state.nearestCircleToHighlight.x !== pointToHighlight.x ||
|
|
266
|
+
_this_1.state.nearestCircleToHighlight.y !== pointToHighlight.y));
|
|
267
|
+
// if no points need to be called out then don't show vertical line and callout card
|
|
268
|
+
if (found && pointToHighlightUpdated) {
|
|
269
|
+
_this_1._uniqueCallOutID = "#staticHighlightCircle_" + linenumber;
|
|
270
|
+
d3_selection_1.select("#staticHighlightCircle_" + linenumber)
|
|
271
|
+
.attr('cx', "" + _this_1._xAxisScale(pointToHighlight.x))
|
|
272
|
+
.attr('cy', "" + _this_1._yAxisScale(pointToHighlight.y))
|
|
273
|
+
.attr('visibility', 'visibility');
|
|
274
|
+
d3_selection_1.select("#" + _this_1._verticalLine)
|
|
275
|
+
.attr('transform', function () { return "translate(" + _this_1._xAxisScale(pointToHighlight.x) + ", " + _this_1._yAxisScale(pointToHighlight.y) + ")"; })
|
|
276
|
+
.attr('visibility', 'visibility')
|
|
277
|
+
.attr('y2', "" + (lineHeight - _this_1._yAxisScale(pointToHighlight.y)));
|
|
278
|
+
_this_1.setState({
|
|
279
|
+
nearestCircleToHighlight: pointToHighlight,
|
|
280
|
+
isCalloutVisible: true,
|
|
281
|
+
refSelected: "#staticHighlightCircle_" + linenumber,
|
|
282
|
+
stackCalloutProps: found,
|
|
283
|
+
YValueHover: found.values,
|
|
284
|
+
dataPointCalloutProps: found,
|
|
285
|
+
hoverXValue: xAxisCalloutData ? xAxisCalloutData : formattedDate,
|
|
286
|
+
xAxisCalloutAccessibilityData: xAxisCalloutAccessibilityData,
|
|
287
|
+
activePoint: '',
|
|
288
|
+
activeLine: linenumber,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
if (!found) {
|
|
292
|
+
_this_1.setState({
|
|
293
|
+
isCalloutVisible: false,
|
|
294
|
+
nearestCircleToHighlight: pointToHighlight,
|
|
295
|
+
activePoint: '',
|
|
296
|
+
activeLine: linenumber,
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
};
|
|
207
300
|
_this_1._handleFocus = function (lineId, x, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData) {
|
|
208
301
|
_this_1._uniqueCallOutID = circleId;
|
|
209
302
|
var formattedData = x instanceof Date ? x.toLocaleDateString() : x;
|
|
@@ -260,12 +353,16 @@ define(["require", "exports", "tslib", "react", "d3-selection", "../Legends/inde
|
|
|
260
353
|
dataPointCalloutProps: found,
|
|
261
354
|
activePoint: circleId,
|
|
262
355
|
xAxisCalloutAccessibilityData: xAxisCalloutAccessibilityData,
|
|
356
|
+
nearestCircleToHighlight: null,
|
|
357
|
+
activeLine: null,
|
|
263
358
|
});
|
|
264
359
|
}
|
|
265
360
|
}
|
|
266
361
|
else {
|
|
267
362
|
_this_1.setState({
|
|
268
363
|
activePoint: circleId,
|
|
364
|
+
nearestCircleToHighlight: null,
|
|
365
|
+
activeLine: null,
|
|
269
366
|
});
|
|
270
367
|
}
|
|
271
368
|
};
|
|
@@ -287,6 +384,7 @@ define(["require", "exports", "tslib", "react", "d3-selection", "../Legends/inde
|
|
|
287
384
|
_this_1.setState({
|
|
288
385
|
isCalloutVisible: false,
|
|
289
386
|
activePoint: '',
|
|
387
|
+
activeLine: null,
|
|
290
388
|
});
|
|
291
389
|
};
|
|
292
390
|
_this_1._handleLegendClick = function (lineChartItem, selectedLegend) {
|
|
@@ -392,6 +490,8 @@ define(["require", "exports", "tslib", "react", "d3-selection", "../Legends/inde
|
|
|
392
490
|
selectedColorBarLegend: [],
|
|
393
491
|
isSelectedLegend: false,
|
|
394
492
|
activePoint: '',
|
|
493
|
+
nearestCircleToHighlight: null,
|
|
494
|
+
activeLine: null,
|
|
395
495
|
};
|
|
396
496
|
_this_1._refArray = [];
|
|
397
497
|
_this_1._points = _this_1._injectIndexPropertyInLineChartData(_this_1.props.data.lineChartData);
|
|
@@ -509,7 +609,7 @@ define(["require", "exports", "tslib", "react", "d3-selection", "../Legends/inde
|
|
|
509
609
|
};
|
|
510
610
|
LineChartBase.prototype._createLines = function (xElement, containerHeight) {
|
|
511
611
|
var _this_1 = this;
|
|
512
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
612
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
513
613
|
var lines = [];
|
|
514
614
|
if (this.state.isSelectedLegend) {
|
|
515
615
|
this._points = this.state.selectedLegendPoints;
|
|
@@ -517,7 +617,7 @@ define(["require", "exports", "tslib", "react", "d3-selection", "../Legends/inde
|
|
|
517
617
|
else {
|
|
518
618
|
this._points = this._injectIndexPropertyInLineChartData(this.props.data.lineChartData);
|
|
519
619
|
}
|
|
520
|
-
for (var i =
|
|
620
|
+
for (var i = this._points.length - 1; i >= 0; i--) {
|
|
521
621
|
var linesForLine = [];
|
|
522
622
|
var bordersForLine = [];
|
|
523
623
|
var pointsForLine = [];
|
|
@@ -527,59 +627,98 @@ define(["require", "exports", "tslib", "react", "d3-selection", "../Legends/inde
|
|
|
527
627
|
var theme = this.props.theme;
|
|
528
628
|
var verticaLineHeight = containerHeight - this.margins.bottom + 6;
|
|
529
629
|
if (this._points[i].data.length === 1) {
|
|
530
|
-
var
|
|
630
|
+
var _0 = this._points[i].data[0], x1 = _0.x, y1 = _0.y, xAxisCalloutData = _0.xAxisCalloutData, xAxisCalloutAccessibilityData = _0.xAxisCalloutAccessibilityData;
|
|
531
631
|
var circleId = "" + this._circleId + i;
|
|
532
632
|
pointsForLine.push(React.createElement("circle", { id: "" + this._circleId + i, key: "" + this._circleId + i, r: activePoint === circleId ? 5.5 : 3.5, cx: this._xAxisScale(x1), cy: this._yAxisScale(y1), fill: activePoint === circleId ? theme.palette.white : lineColor, onMouseOver: this._handleHover.bind(this, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseMove: this._handleHover.bind(this, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseOut: this._handleMouseOut, strokeWidth: activePoint === circleId ? DEFAULT_LINE_STROKE_SIZE : 0, stroke: activePoint === circleId ? lineColor : '' }));
|
|
533
633
|
}
|
|
534
634
|
var gapIndex = 0;
|
|
535
635
|
var gaps = (_b = (_a = this._points[i].gaps) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.startIndex - b.startIndex; })) !== null && _b !== void 0 ? _b : [];
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
var
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
var
|
|
545
|
-
var
|
|
546
|
-
var strokeWidth = ((_c =
|
|
547
|
-
var isLegendSelected =
|
|
548
|
-
var
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
return _this_1._handleFocus(lineId, x2, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1);
|
|
557
|
-
}, onBlur: this_1._handleMouseOut, onClick: this_1._onDataPointClick.bind(this_1, 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 }));
|
|
558
|
-
/* eslint-enable react/jsx-no-bind */
|
|
636
|
+
// Use path rendering technique for larger datasets to optimize performance.
|
|
637
|
+
if (this._points[i].data.length >= 1000 || this.props.optimizeLargeData) {
|
|
638
|
+
var line = d3_shape_1.line()
|
|
639
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
640
|
+
.x(function (d) { return _this_1._xAxisScale(d[0]); })
|
|
641
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
642
|
+
.y(function (d) { return _this_1._yAxisScale(d[1]); })
|
|
643
|
+
.curve(d3_shape_1.curveLinear);
|
|
644
|
+
var lineId = "" + this._lineId + i;
|
|
645
|
+
var borderId = "" + this._borderId + i;
|
|
646
|
+
var strokeWidth = ((_c = this._points[i].lineOptions) === null || _c === void 0 ? void 0 : _c.strokeWidth) || this.props.strokeWidth || DEFAULT_LINE_STROKE_SIZE;
|
|
647
|
+
var isLegendSelected = this.state.activeLegend === legendVal || this.state.activeLegend === '' || this.state.isSelectedLegend;
|
|
648
|
+
var lineData = [];
|
|
649
|
+
for (var k = 0; k < this._points[i].data.length; k++) {
|
|
650
|
+
lineData.push([
|
|
651
|
+
this._points[i].data[k].x instanceof Date
|
|
652
|
+
? this._points[i].data[k].x.getTime()
|
|
653
|
+
: this._points[i].data[k].x,
|
|
654
|
+
this._points[i].data[k].y,
|
|
655
|
+
]);
|
|
559
656
|
}
|
|
560
657
|
if (isLegendSelected) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
if (lineBorderWidth > 0) {
|
|
567
|
-
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: (_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 }));
|
|
568
|
-
}
|
|
569
|
-
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) {
|
|
570
|
-
_this_1._refCallback(e, lineId);
|
|
571
|
-
}, 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: (_j = (_h = this_1._points[i].lineOptions) === null || _h === void 0 ? void 0 : _h.strokeLinecap) !== null && _j !== void 0 ? _j : 'round', strokeDasharray: (_k = this_1._points[i].lineOptions) === null || _k === void 0 ? void 0 : _k.strokeDasharray, strokeDashoffset: (_l = this_1._points[i].lineOptions) === null || _l === void 0 ? void 0 : _l.strokeDashoffset, opacity: 1, onClick: this_1._onLineClick.bind(this_1, this_1._points[i].onLineClick) }));
|
|
658
|
+
var lineBorderWidth = ((_d = this._points[i].lineOptions) === null || _d === void 0 ? void 0 : _d.lineBorderWidth)
|
|
659
|
+
? Number.parseFloat(this._points[i].lineOptions.lineBorderWidth.toString())
|
|
660
|
+
: 0;
|
|
661
|
+
if (lineBorderWidth > 0) {
|
|
662
|
+
bordersForLine.push(React.createElement("path", { id: borderId, key: borderId, d: line(lineData), fill: "transparent", strokeLinecap: (_f = (_e = this._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._points[i].lineOptions) === null || _g === void 0 ? void 0 : _g.lineBorderColor) || theme.palette.white, opacity: 1 }));
|
|
572
663
|
}
|
|
664
|
+
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 = this._points[i].lineOptions) === null || _h === void 0 ? void 0 : _h.strokeLinecap) !== null && _j !== void 0 ? _j : 'round', onMouseMove: this._onMouseOverLargeDataset.bind(this, i, verticaLineHeight), onMouseOver: this._onMouseOverLargeDataset.bind(this, i, verticaLineHeight), onMouseOut: this._handleMouseOut, onClick: this._onLineClick.bind(this, this._points[i].onLineClick), opacity: 1 }));
|
|
573
665
|
}
|
|
574
666
|
else {
|
|
575
|
-
|
|
576
|
-
|
|
667
|
+
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._points[i].lineOptions) === null || _k === void 0 ? void 0 : _k.strokeLinecap) !== null && _l !== void 0 ? _l : 'round', opacity: 0.1 }));
|
|
668
|
+
}
|
|
669
|
+
var isPointHighlighted = this.state.activeLine !== null && this.state.activeLine === i;
|
|
670
|
+
pointsForLine.push(React.createElement("circle", { id: "staticHighlightCircle_" + i, key: "staticHighlightCircle_" + i, r: 5.5, cx: 0, cy: 0, fill: theme.palette.white, "data-is-focusable": true, strokeWidth: DEFAULT_LINE_STROKE_SIZE, stroke: lineColor, visibility: isPointHighlighted ? 'visibility' : 'hidden', onMouseMove: this._onMouseOverLargeDataset.bind(this, i, verticaLineHeight), onMouseOver: this._onMouseOverLargeDataset.bind(this, i, verticaLineHeight), onMouseOut: this._handleMouseOut }));
|
|
671
|
+
}
|
|
672
|
+
else {
|
|
673
|
+
var _loop_1 = function (j) {
|
|
674
|
+
var gapResult = this_1._checkInGap(j, gaps, gapIndex);
|
|
675
|
+
var isInGap = gapResult.isInGap;
|
|
676
|
+
gapIndex = gapResult.gapIndex;
|
|
677
|
+
var lineId = "" + this_1._lineId + i + j;
|
|
678
|
+
var borderId = "" + this_1._borderId + i + j;
|
|
679
|
+
var circleId = "" + this_1._circleId + i + j;
|
|
680
|
+
var _1 = this_1._points[i].data[j - 1], x1 = _1.x, y1 = _1.y, xAxisCalloutData = _1.xAxisCalloutData, xAxisCalloutAccessibilityData = _1.xAxisCalloutAccessibilityData;
|
|
681
|
+
var _2 = this_1._points[i].data[j], x2 = _2.x, y2 = _2.y;
|
|
682
|
+
var path = this_1._getPath(this_1._xAxisScale(x1), this_1._yAxisScale(y1), circleId, j, false, this_1._points[i].index);
|
|
683
|
+
var strokeWidth = ((_m = this_1._points[i].lineOptions) === null || _m === void 0 ? void 0 : _m.strokeWidth) || this_1.props.strokeWidth || DEFAULT_LINE_STROKE_SIZE;
|
|
684
|
+
var isLegendSelected = this_1.state.activeLegend === legendVal || this_1.state.activeLegend === '' || this_1.state.isSelectedLegend;
|
|
685
|
+
var currentPointHidden = this_1._points[i].hideNonActiveDots && activePoint !== circleId;
|
|
686
|
+
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, onClick: this_1._onDataPointClick.bind(this_1, 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 }));
|
|
687
|
+
if (j + 1 === this_1._points[i].data.length) {
|
|
688
|
+
// If this is last point of the line segment.
|
|
689
|
+
var lastCircleId_1 = "" + circleId + j + "L";
|
|
690
|
+
var lastPointHidden = this_1._points[i].hideNonActiveDots && activePoint !== lastCircleId_1;
|
|
691
|
+
path = this_1._getPath(this_1._xAxisScale(x2), this_1._yAxisScale(y2), lastCircleId_1, j, true, this_1._points[i].index);
|
|
692
|
+
var _3 = this_1._points[i].data[j], lastCirlceXCallout_1 = _3.xAxisCalloutData, lastCirlceXCalloutAccessibilityData_1 = _3.xAxisCalloutAccessibilityData;
|
|
693
|
+
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 () {
|
|
694
|
+
return _this_1._handleFocus(lineId, x2, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1);
|
|
695
|
+
}, onBlur: this_1._handleMouseOut, onClick: this_1._onDataPointClick.bind(this_1, 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 }));
|
|
696
|
+
/* eslint-enable react/jsx-no-bind */
|
|
577
697
|
}
|
|
698
|
+
if (isLegendSelected) {
|
|
699
|
+
// don't draw line if it is in a gap
|
|
700
|
+
if (!isInGap) {
|
|
701
|
+
var lineBorderWidth = ((_o = this_1._points[i].lineOptions) === null || _o === void 0 ? void 0 : _o.lineBorderWidth)
|
|
702
|
+
? Number.parseFloat(this_1._points[i].lineOptions.lineBorderWidth.toString())
|
|
703
|
+
: 0;
|
|
704
|
+
if (lineBorderWidth > 0) {
|
|
705
|
+
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 }));
|
|
706
|
+
}
|
|
707
|
+
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) {
|
|
708
|
+
_this_1._refCallback(e, lineId);
|
|
709
|
+
}, 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, onClick: this_1._onLineClick.bind(this_1, this_1._points[i].onLineClick) }));
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
if (!isInGap) {
|
|
714
|
+
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, stroke: lineColor, strokeLinecap: (_x = (_w = this_1._points[i].lineOptions) === null || _w === void 0 ? void 0 : _w.strokeLinecap) !== null && _x !== void 0 ? _x : 'round', strokeDasharray: (_y = this_1._points[i].lineOptions) === null || _y === void 0 ? void 0 : _y.strokeDasharray, strokeDashoffset: (_z = this_1._points[i].lineOptions) === null || _z === void 0 ? void 0 : _z.strokeDashoffset, opacity: 0.1 }));
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
var this_1 = this;
|
|
719
|
+
for (var j = 1; j < this._points[i].data.length; j++) {
|
|
720
|
+
_loop_1(j);
|
|
578
721
|
}
|
|
579
|
-
};
|
|
580
|
-
var this_1 = this;
|
|
581
|
-
for (var j = 1; j < this._points[i].data.length; j++) {
|
|
582
|
-
_loop_1(j);
|
|
583
722
|
}
|
|
584
723
|
lines.push.apply(lines, tslib_1.__spreadArray(tslib_1.__spreadArray(tslib_1.__spreadArray([], bordersForLine), linesForLine), pointsForLine));
|
|
585
724
|
}
|