@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.
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { IAccessibilityProps, IBasestate, ILineChartProps, ILineChartPoints, ICustomizedCalloutData, IColorFillBarsProps } from '../../index';
2
+ import { IAccessibilityProps, IBasestate, ILineChartProps, ILineChartPoints, ICustomizedCalloutData, IColorFillBarsProps, ILineChartDataPoint } from '../../index';
3
3
  declare type LineChartDataWithIndex = ILineChartPoints & {
4
4
  index: number;
5
5
  };
@@ -11,6 +11,8 @@ export interface ILineChartState extends IBasestate {
11
11
  stackCalloutProps?: ICustomizedCalloutData;
12
12
  activePoint?: string;
13
13
  xAxisCalloutAccessibilityData?: IAccessibilityProps;
14
+ nearestCircleToHighlight: ILineChartDataPoint | null;
15
+ activeLine: number | null;
14
16
  }
15
17
  export declare class LineChartBase extends React.Component<ILineChartProps, ILineChartState> {
16
18
  private _points;
@@ -50,6 +52,7 @@ export declare class LineChartBase extends React.Component<ILineChartProps, ILin
50
52
  private _getStripePattern;
51
53
  private _checkInGap;
52
54
  private _refCallback;
55
+ private _onMouseOverLargeDataset;
53
56
  private _handleFocus;
54
57
  private _handleHover;
55
58
  private _onLineClick;
@@ -1,18 +1,22 @@
1
1
  import { __assign, __extends, __spreadArray } from "tslib";
2
2
  import * as React from 'react';
3
3
  import { select as d3Select } from 'd3-selection';
4
+ import { bisector } from 'd3-array';
4
5
  import { Legends } from '../Legends/index';
6
+ import { line as d3Line, curveLinear as d3curveLinear } from 'd3-shape';
5
7
  import { classNamesFunction, getId, find } from '@fluentui/react/lib/Utilities';
6
8
  import { CartesianChart, } from '../../index';
7
9
  import { DirectionalHint } from '@fluentui/react/lib/Callout';
8
10
  import { EventsAnnotation } from './eventAnnotation/EventAnnotation';
9
- import { calloutData, ChartTypes, getXAxisType, XAxisTypes, tooltipOfXAxislabels, Points, pointTypes, getMinMaxOfYAxis, } from '../../utilities/index';
11
+ import { calloutData, ChartTypes, getXAxisType, XAxisTypes, tooltipOfXAxislabels, Points, pointTypes, getMinMaxOfYAxis, getTypeOfAxis, } from '../../utilities/index';
10
12
  var getClassNames = classNamesFunction();
11
13
  var PointSize;
12
14
  (function (PointSize) {
13
15
  PointSize[PointSize["hoverSize"] = 11] = "hoverSize";
14
16
  PointSize[PointSize["invisibleSize"] = 1] = "invisibleSize";
15
17
  })(PointSize || (PointSize = {}));
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ var bisect = bisector(function (d) { return d.x; }).left;
16
20
  var DEFAULT_LINE_STROKE_SIZE = 4;
17
21
  // The given shape of a icon must be 2.5 times bigger than line width (known as stroke width)
18
22
  var PATH_MULTIPLY_SIZE = 2.5;
@@ -209,6 +213,97 @@ var LineChartBase = /** @class */ (function (_super) {
209
213
  }
210
214
  return { isInGap: isInGap, gapIndex: gapIndex };
211
215
  };
216
+ _this_1._onMouseOverLargeDataset = function (linenumber, lineHeight, mouseEvent) {
217
+ // Run this code for different scenarios. For data and numeric data. Try to satisfy undefined d0/d1 scenario.
218
+ mouseEvent.persist();
219
+ var data = _this_1.props.data;
220
+ var lineChartData = data.lineChartData;
221
+ // This will get the value of the X when mouse is on the chart
222
+ var xOffset = _this_1._xAxisScale.invert(mouseEvent.pageX - 15); //Todo - fix this
223
+ var i = bisect(lineChartData[linenumber].data, xOffset);
224
+ var d0 = lineChartData[linenumber].data[i - 1];
225
+ var d1 = lineChartData[linenumber].data[i];
226
+ var axisType = null;
227
+ var xPointToHighlight = null;
228
+ var index = null;
229
+ if (d0 === undefined && d1 !== undefined) {
230
+ xPointToHighlight = d1.x;
231
+ index = i;
232
+ }
233
+ else if (d0 !== undefined && d1 === undefined) {
234
+ xPointToHighlight = d0.x;
235
+ index = i - 1;
236
+ }
237
+ else {
238
+ axisType = getTypeOfAxis(lineChartData[linenumber].data[0].x, true);
239
+ var x0 = void 0;
240
+ var point0 = void 0;
241
+ var point1 = void 0;
242
+ switch (axisType) {
243
+ case XAxisTypes.DateAxis:
244
+ x0 = new Date(xOffset).getTime();
245
+ point0 = d0.x.getTime();
246
+ point1 = d1.x.getTime();
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
+ case XAxisTypes.NumericAxis:
251
+ x0 = xOffset;
252
+ point0 = d0.x;
253
+ point1 = d1.x;
254
+ xPointToHighlight = Math.abs(x0 - point0) > Math.abs(x0 - point1) ? d1.x : d0.x;
255
+ index = Math.abs(x0 - point0) > Math.abs(x0 - point1) ? i : i - 1;
256
+ break;
257
+ default:
258
+ break;
259
+ }
260
+ }
261
+ var _a = lineChartData[linenumber].data[index], xAxisCalloutData = _a.xAxisCalloutData, xAxisCalloutAccessibilityData = _a.xAxisCalloutAccessibilityData;
262
+ var formattedDate = xPointToHighlight instanceof Date ? xPointToHighlight.toLocaleString() : xPointToHighlight;
263
+ var modifiedXVal = xPointToHighlight instanceof Date ? xPointToHighlight.getTime() : xPointToHighlight;
264
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
265
+ var found = find(_this_1._calloutPoints, function (element) {
266
+ return element.x === modifiedXVal;
267
+ });
268
+ var pointToHighlight = lineChartData[linenumber].data[index];
269
+ var pointToHighlightUpdated = _this_1.state.nearestCircleToHighlight === null ||
270
+ (_this_1.state.nearestCircleToHighlight !== null &&
271
+ pointToHighlight !== null &&
272
+ (_this_1.state.nearestCircleToHighlight.x !== pointToHighlight.x ||
273
+ _this_1.state.nearestCircleToHighlight.y !== pointToHighlight.y));
274
+ // if no points need to be called out then don't show vertical line and callout card
275
+ if (found && pointToHighlightUpdated) {
276
+ _this_1._uniqueCallOutID = "#staticHighlightCircle_" + linenumber;
277
+ d3Select("#staticHighlightCircle_" + linenumber)
278
+ .attr('cx', "" + _this_1._xAxisScale(pointToHighlight.x))
279
+ .attr('cy', "" + _this_1._yAxisScale(pointToHighlight.y))
280
+ .attr('visibility', 'visibility');
281
+ d3Select("#" + _this_1._verticalLine)
282
+ .attr('transform', function () { return "translate(" + _this_1._xAxisScale(pointToHighlight.x) + ", " + _this_1._yAxisScale(pointToHighlight.y) + ")"; })
283
+ .attr('visibility', 'visibility')
284
+ .attr('y2', "" + (lineHeight - _this_1._yAxisScale(pointToHighlight.y)));
285
+ _this_1.setState({
286
+ nearestCircleToHighlight: pointToHighlight,
287
+ isCalloutVisible: true,
288
+ refSelected: "#staticHighlightCircle_" + linenumber,
289
+ stackCalloutProps: found,
290
+ YValueHover: found.values,
291
+ dataPointCalloutProps: found,
292
+ hoverXValue: xAxisCalloutData ? xAxisCalloutData : formattedDate,
293
+ xAxisCalloutAccessibilityData: xAxisCalloutAccessibilityData,
294
+ activePoint: '',
295
+ activeLine: linenumber,
296
+ });
297
+ }
298
+ if (!found) {
299
+ _this_1.setState({
300
+ isCalloutVisible: false,
301
+ nearestCircleToHighlight: pointToHighlight,
302
+ activePoint: '',
303
+ activeLine: linenumber,
304
+ });
305
+ }
306
+ };
212
307
  _this_1._handleFocus = function (lineId, x, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData) {
213
308
  _this_1._uniqueCallOutID = circleId;
214
309
  var formattedData = x instanceof Date ? x.toLocaleDateString() : x;
@@ -265,12 +360,16 @@ var LineChartBase = /** @class */ (function (_super) {
265
360
  dataPointCalloutProps: found,
266
361
  activePoint: circleId,
267
362
  xAxisCalloutAccessibilityData: xAxisCalloutAccessibilityData,
363
+ nearestCircleToHighlight: null,
364
+ activeLine: null,
268
365
  });
269
366
  }
270
367
  }
271
368
  else {
272
369
  _this_1.setState({
273
370
  activePoint: circleId,
371
+ nearestCircleToHighlight: null,
372
+ activeLine: null,
274
373
  });
275
374
  }
276
375
  };
@@ -292,6 +391,7 @@ var LineChartBase = /** @class */ (function (_super) {
292
391
  _this_1.setState({
293
392
  isCalloutVisible: false,
294
393
  activePoint: '',
394
+ activeLine: null,
295
395
  });
296
396
  };
297
397
  _this_1._handleLegendClick = function (lineChartItem, selectedLegend) {
@@ -397,6 +497,8 @@ var LineChartBase = /** @class */ (function (_super) {
397
497
  selectedColorBarLegend: [],
398
498
  isSelectedLegend: false,
399
499
  activePoint: '',
500
+ nearestCircleToHighlight: null,
501
+ activeLine: null,
400
502
  };
401
503
  _this_1._refArray = [];
402
504
  _this_1._points = _this_1._injectIndexPropertyInLineChartData(_this_1.props.data.lineChartData);
@@ -514,7 +616,7 @@ var LineChartBase = /** @class */ (function (_super) {
514
616
  };
515
617
  LineChartBase.prototype._createLines = function (xElement, containerHeight) {
516
618
  var _this_1 = this;
517
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
619
+ 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;
518
620
  var lines = [];
519
621
  if (this.state.isSelectedLegend) {
520
622
  this._points = this.state.selectedLegendPoints;
@@ -522,7 +624,7 @@ var LineChartBase = /** @class */ (function (_super) {
522
624
  else {
523
625
  this._points = this._injectIndexPropertyInLineChartData(this.props.data.lineChartData);
524
626
  }
525
- for (var i = 0; i < this._points.length; i++) {
627
+ for (var i = this._points.length - 1; i >= 0; i--) {
526
628
  var linesForLine = [];
527
629
  var bordersForLine = [];
528
630
  var pointsForLine = [];
@@ -532,59 +634,98 @@ var LineChartBase = /** @class */ (function (_super) {
532
634
  var theme = this.props.theme;
533
635
  var verticaLineHeight = containerHeight - this.margins.bottom + 6;
534
636
  if (this._points[i].data.length === 1) {
535
- var _r = this._points[i].data[0], x1 = _r.x, y1 = _r.y, xAxisCalloutData = _r.xAxisCalloutData, xAxisCalloutAccessibilityData = _r.xAxisCalloutAccessibilityData;
637
+ var _0 = this._points[i].data[0], x1 = _0.x, y1 = _0.y, xAxisCalloutData = _0.xAxisCalloutData, xAxisCalloutAccessibilityData = _0.xAxisCalloutAccessibilityData;
536
638
  var circleId = "" + this._circleId + i;
537
639
  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 : '' }));
538
640
  }
539
641
  var gapIndex = 0;
540
642
  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 : [];
541
- var _loop_1 = function (j) {
542
- var gapResult = this_1._checkInGap(j, gaps, gapIndex);
543
- var isInGap = gapResult.isInGap;
544
- gapIndex = gapResult.gapIndex;
545
- var lineId = "" + this_1._lineId + i + j;
546
- var borderId = "" + this_1._borderId + i + j;
547
- var circleId = "" + this_1._circleId + i + j;
548
- var _s = this_1._points[i].data[j - 1], x1 = _s.x, y1 = _s.y, xAxisCalloutData = _s.xAxisCalloutData, xAxisCalloutAccessibilityData = _s.xAxisCalloutAccessibilityData;
549
- var _t = this_1._points[i].data[j], x2 = _t.x, y2 = _t.y;
550
- var path = this_1._getPath(this_1._xAxisScale(x1), this_1._yAxisScale(y1), circleId, j, false, this_1._points[i].index);
551
- var strokeWidth = ((_c = this_1._points[i].lineOptions) === null || _c === void 0 ? void 0 : _c.strokeWidth) || this_1.props.strokeWidth || DEFAULT_LINE_STROKE_SIZE;
552
- var isLegendSelected = this_1.state.activeLegend === legendVal || this_1.state.activeLegend === '' || this_1.state.isSelectedLegend;
553
- var currentPointHidden = this_1._points[i].hideNonActiveDots && activePoint !== circleId;
554
- 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 }));
555
- if (j + 1 === this_1._points[i].data.length) {
556
- var lastCircleId_1 = "" + circleId + j + "L";
557
- var lastPointHidden = this_1._points[i].hideNonActiveDots && activePoint !== lastCircleId_1;
558
- path = this_1._getPath(this_1._xAxisScale(x2), this_1._yAxisScale(y2), lastCircleId_1, j, true, this_1._points[i].index);
559
- var _u = this_1._points[i].data[j], lastCirlceXCallout_1 = _u.xAxisCalloutData, lastCirlceXCalloutAccessibilityData_1 = _u.xAxisCalloutAccessibilityData;
560
- 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 () {
561
- return _this_1._handleFocus(lineId, x2, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1);
562
- }, 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 }));
563
- /* eslint-enable react/jsx-no-bind */
643
+ // Use path rendering technique for larger datasets to optimize performance.
644
+ if (this._points[i].data.length >= 1000 || this.props.optimizeLargeData) {
645
+ var line = d3Line()
646
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
647
+ .x(function (d) { return _this_1._xAxisScale(d[0]); })
648
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
649
+ .y(function (d) { return _this_1._yAxisScale(d[1]); })
650
+ .curve(d3curveLinear);
651
+ var lineId = "" + this._lineId + i;
652
+ var borderId = "" + this._borderId + i;
653
+ var strokeWidth = ((_c = this._points[i].lineOptions) === null || _c === void 0 ? void 0 : _c.strokeWidth) || this.props.strokeWidth || DEFAULT_LINE_STROKE_SIZE;
654
+ var isLegendSelected = this.state.activeLegend === legendVal || this.state.activeLegend === '' || this.state.isSelectedLegend;
655
+ var lineData = [];
656
+ for (var k = 0; k < this._points[i].data.length; k++) {
657
+ lineData.push([
658
+ this._points[i].data[k].x instanceof Date
659
+ ? this._points[i].data[k].x.getTime()
660
+ : this._points[i].data[k].x,
661
+ this._points[i].data[k].y,
662
+ ]);
564
663
  }
565
664
  if (isLegendSelected) {
566
- // don't draw line if it is in a gap
567
- if (!isInGap) {
568
- var lineBorderWidth = ((_d = this_1._points[i].lineOptions) === null || _d === void 0 ? void 0 : _d.lineBorderWidth)
569
- ? Number.parseFloat(this_1._points[i].lineOptions.lineBorderWidth.toString())
570
- : 0;
571
- if (lineBorderWidth > 0) {
572
- 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 }));
573
- }
574
- 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) {
575
- _this_1._refCallback(e, lineId);
576
- }, 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) }));
665
+ var lineBorderWidth = ((_d = this._points[i].lineOptions) === null || _d === void 0 ? void 0 : _d.lineBorderWidth)
666
+ ? Number.parseFloat(this._points[i].lineOptions.lineBorderWidth.toString())
667
+ : 0;
668
+ if (lineBorderWidth > 0) {
669
+ 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 }));
577
670
  }
671
+ 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 }));
578
672
  }
579
673
  else {
580
- if (!isInGap) {
581
- 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: (_o = (_m = this_1._points[i].lineOptions) === null || _m === void 0 ? void 0 : _m.strokeLinecap) !== null && _o !== void 0 ? _o : 'round', strokeDasharray: (_p = this_1._points[i].lineOptions) === null || _p === void 0 ? void 0 : _p.strokeDasharray, strokeDashoffset: (_q = this_1._points[i].lineOptions) === null || _q === void 0 ? void 0 : _q.strokeDashoffset, opacity: 0.1 }));
674
+ 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 }));
675
+ }
676
+ var isPointHighlighted = this.state.activeLine !== null && this.state.activeLine === i;
677
+ 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 }));
678
+ }
679
+ else {
680
+ var _loop_1 = function (j) {
681
+ var gapResult = this_1._checkInGap(j, gaps, gapIndex);
682
+ var isInGap = gapResult.isInGap;
683
+ gapIndex = gapResult.gapIndex;
684
+ var lineId = "" + this_1._lineId + i + j;
685
+ var borderId = "" + this_1._borderId + i + j;
686
+ var circleId = "" + this_1._circleId + i + j;
687
+ var _1 = this_1._points[i].data[j - 1], x1 = _1.x, y1 = _1.y, xAxisCalloutData = _1.xAxisCalloutData, xAxisCalloutAccessibilityData = _1.xAxisCalloutAccessibilityData;
688
+ var _2 = this_1._points[i].data[j], x2 = _2.x, y2 = _2.y;
689
+ var path = this_1._getPath(this_1._xAxisScale(x1), this_1._yAxisScale(y1), circleId, j, false, this_1._points[i].index);
690
+ var strokeWidth = ((_m = this_1._points[i].lineOptions) === null || _m === void 0 ? void 0 : _m.strokeWidth) || this_1.props.strokeWidth || DEFAULT_LINE_STROKE_SIZE;
691
+ var isLegendSelected = this_1.state.activeLegend === legendVal || this_1.state.activeLegend === '' || this_1.state.isSelectedLegend;
692
+ var currentPointHidden = this_1._points[i].hideNonActiveDots && activePoint !== circleId;
693
+ 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 }));
694
+ if (j + 1 === this_1._points[i].data.length) {
695
+ // If this is last point of the line segment.
696
+ var lastCircleId_1 = "" + circleId + j + "L";
697
+ var lastPointHidden = this_1._points[i].hideNonActiveDots && activePoint !== lastCircleId_1;
698
+ path = this_1._getPath(this_1._xAxisScale(x2), this_1._yAxisScale(y2), lastCircleId_1, j, true, this_1._points[i].index);
699
+ var _3 = this_1._points[i].data[j], lastCirlceXCallout_1 = _3.xAxisCalloutData, lastCirlceXCalloutAccessibilityData_1 = _3.xAxisCalloutAccessibilityData;
700
+ 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 () {
701
+ return _this_1._handleFocus(lineId, x2, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1);
702
+ }, 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 }));
703
+ /* eslint-enable react/jsx-no-bind */
582
704
  }
705
+ if (isLegendSelected) {
706
+ // don't draw line if it is in a gap
707
+ if (!isInGap) {
708
+ var lineBorderWidth = ((_o = this_1._points[i].lineOptions) === null || _o === void 0 ? void 0 : _o.lineBorderWidth)
709
+ ? Number.parseFloat(this_1._points[i].lineOptions.lineBorderWidth.toString())
710
+ : 0;
711
+ if (lineBorderWidth > 0) {
712
+ 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 }));
713
+ }
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, ref: function (e) {
715
+ _this_1._refCallback(e, lineId);
716
+ }, 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) }));
717
+ }
718
+ }
719
+ else {
720
+ if (!isInGap) {
721
+ 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 }));
722
+ }
723
+ }
724
+ };
725
+ var this_1 = this;
726
+ for (var j = 1; j < this._points[i].data.length; j++) {
727
+ _loop_1(j);
583
728
  }
584
- };
585
- var this_1 = this;
586
- for (var j = 1; j < this._points[i].data.length; j++) {
587
- _loop_1(j);
588
729
  }
589
730
  lines.push.apply(lines, __spreadArray(__spreadArray(__spreadArray([], bordersForLine), linesForLine), pointsForLine));
590
731
  }