function fillData(props, datasets) {
  const { fillInMissingData } = props;
  const xMap = datasets.reduce((prev, dataset) => {
    dataset.forEach((datum) => {
      prev[datum._x instanceof Date ? datum._x.getTime() : datum._x] = true;
    });
    return prev;
  }, {});
  const xKeys = keys(xMap).map((k) => +k);
  const xArr = orderBy(xKeys);

  return datasets.map((dataset) => {
    let indexOffset = 0;
    const isDate = dataset[0] && dataset[0]._x instanceof Date;
    const filledInData = xArr.map((x, index) => {
      x = +x;
      const datum = dataset[index - indexOffset];

      if (datum) {
        const x1 = isDate ? datum._x.getTime() : datum._x;
        if (x1 === x) {
          return datum;
        } else {
          indexOffset++;
          const y = fillInMissingData ? 0 : null;
          x = isDate ? new Date(x) : x;
          return { x, y, _x: x, _y: y };
        }
      } else {
        const y = fillInMissingData ? 0 : null;
        x = isDate ? new Date(x) : x;
        return { x, y, _x: x, _y: y };
      }
    });

    return filledInData;
  });
}
function fillData(props, datasets) {
  const { fillInMissingData } = props;
  const xMap = datasets.reduce((prev, dataset) => {
    dataset.forEach((datum) => {
      prev[datum._x instanceof Date ? datum._x.getTime() : datum._x] = true;
    });
    return prev;
  }, {});
  const xKeys = keys(xMap).map((k) => +k);
  const xArr = orderBy(xKeys);

  return datasets.map((dataset) => {
    let indexOffset = 0;
    const isDate = dataset[0] && dataset[0]._x instanceof Date;
    const filledInData = xArr.map((x, index) => {
      x = +x;
      const datum = dataset[index - indexOffset];

      if (datum) {
        const x1 = isDate ? datum._x.getTime() : datum._x;
        if (x1 === x) {
          return datum;
        } else {
          indexOffset++;
          const y = fillInMissingData ? 0 : null;
          x = isDate ? new Date(x) : x;
          return { x, y, _x: x, _y: y };
        }
      } else {
        const y = fillInMissingData ? 0 : null;
        x = isDate ? new Date(x) : x;
        return { x, y, _x: x, _y: y };
      }
    });

    return filledInData;
  });
}
function fillData ( props , datasets ) { const { fillInMissingData } = props ; const xMap = datasets . reduce ( ( prev , dataset ) => { dataset . forEach ( ( datum ) => { prev [ datum . _x instanceof Date ? datum . _x . getTime ( ) : datum . _x ] = true ; } ) ; return prev ; } , { } ) ; const xKeys = keys ( xMap ) . map ( ( k ) => + k ) ; const xArr = orderBy ( xKeys ) ; return datasets . map ( ( dataset ) => { let indexOffset = 0 ; const isDate = dataset [ 0 ] && dataset [ 0 ] . _x instanceof Date ; const filledInData = xArr . map ( ( x , index ) => { x = + x ; const datum = dataset [ index - indexOffset ] ; if ( datum ) { const x1 = isDate ? datum . _x . getTime ( ) : datum . _x ; if ( x1 === x ) { return datum ; } else { indexOffset ++ ; const y = fillInMissingData ? 0 : null ; x = isDate ? new Date ( x ) : x ; return { x , y , _x : x , _y : y } ; } } else { const y = fillInMissingData ? 0 : null ; x = isDate ? new Date ( x ) : x ; return { x , y , _x : x , _y : y } ; } } ) ; return filledInData ; } ) ; }
Assumes data in `datasets` is sorted by `Data.getData`.
Assumes data in datasets is sorted by Data . getData .