message: Protect trendlines from undefined values
diff: @@ -152,7 +152,9 @@ class ChartWithLegend<T extends RichDataPoint, O extends LineInfo> extends React
  }
  });
  }
  - this.props.data.forEach((s, idx) => this.registerEvents(events, idx, ['serie-' + idx, 'serie-reg-' + idx], s.legendItem.name));
  + this.props.data.forEach((s, idx) =>
  + this.registerEvents(events, idx, ['serie-' + idx, 'serie-reg-' + idx], s.legendItem.name)
  + );
  let useSecondAxis = showOverlay;
  let normalizedOverlay: RawOrBucket<O>[] = [];
  let overlayFactor = 1.0;
  @@ -397,7 +399,8 @@ class ChartWithLegend<T extends RichDataPoint, O extends LineInfo> extends React
  const groupOffset = this.props.groupOffset || 0;
  return (
  <ChartGroup offset={groupOffset} height={height}>
  - {this.props.data.map((serie, idx) => {
  + {this.props.data
  + .map((serie, idx) => {
  if (this.state.hiddenSeries.has(serie.legendItem.name)) {
  return undefined;
  }
  @@ -414,9 +417,13 @@ class ChartWithLegend<T extends RichDataPoint, O extends LineInfo> extends React
  )
  );
  - if (this.props.showTrendline === true) {
  + // serie.datapoints may contain undefined values in certain scenarios i.e. "unknown" values
  + if (this.props.showTrendline === true && serie.datapoints[0]) {
  const first_dpx = (serie.datapoints[0].x as Date).getTime() / 1000;
  - const datapoints = serie.datapoints.map(d => [((d.x as Date).getTime()/1000 - first_dpx) / 10000, parseFloat(d.y.toString())]);
  + const datapoints = serie.datapoints.map(d => [
  + ((d.x as Date).getTime() / 1000 - first_dpx) / 10000,
  + parseFloat(d.y.toString())
  + ]);
  const linearRegression = regression.linear(datapoints, { precision: 10 });
  let regressionDatapoints = serie.datapoints.map(d => ({
  @@ -443,7 +450,8 @@ class ChartWithLegend<T extends RichDataPoint, O extends LineInfo> extends React
  }
  return [plot];
  - }).flat()}
  + })
  + .flat()}
  </ChartGroup>
  );
  };
  @@ -477,7 +485,13 @@ class ChartWithLegend<T extends RichDataPoint, O extends LineInfo> extends React
  ? props
  : {
  ...props,
  - style: { data: { fill: this.props.fill ? color : undefined, stroke: this.props.stroke ? color : undefined, strokeDasharray: strokeDasharray === true ? "3 5" : undefined } }
  + style: {
  + data: {
  + fill: this.props.fill ? color : undefined,
  + stroke: this.props.stroke ? color : undefined,
  + strokeDasharray: strokeDasharray === true ? '3 5' : undefined
  + }
  + }
  };
  };
  