function splitPivotData(data, rowIndexes, columnIndexes) {
  const groupIndex = data.cols.findIndex(isPivotGroupColumn);
  const columns = data.cols.filter(col => !isPivotGroupColumn(col));
  const breakouts = columns.filter(col => col.source === "breakout");

  const pivotData = _.chain(data.rows)
    .groupBy(row => row[groupIndex])
    .pairs()
    .map(([key, rows]) => {
      key = parseInt(key);
      const indexes = _.range(breakouts.length).filter(
        index => !((1 << index) & key),
      );
      const keyAsIndexes = JSON.stringify(indexes);
      const rowsWithoutColumn = rows.map(row =>
        row.slice(0, groupIndex).concat(row.slice(groupIndex + 1)),
      );

      return [keyAsIndexes, rowsWithoutColumn];
    })
    .object()
    .value();
  return { pivotData, columns };
}
// We use that column to split apart the data and convert the field refs to indexes.
We use that column to split apart the data and convert the field refs to indexes.
We use that column to split apart the data and convert the field refs to indexes .
function splitPivotData(data, rowIndexes, columnIndexes) {
  const groupIndex = data.cols.findIndex(isPivotGroupColumn);
  const columns = data.cols.filter(col => !isPivotGroupColumn(col));
  const breakouts = columns.filter(col => col.source === "breakout");
  const pivotData = _.chain(data.rows)
    .groupBy(row => row[groupIndex])
    .pairs()
    .map(([key, rows]) => {
      key = parseInt(key);
      const indexes = _.range(breakouts.length).filter(
        index => !((1 << index) & key),
      );
      const keyAsIndexes = JSON.stringify(indexes);
      const rowsWithoutColumn = rows.map(row =>
        row.slice(0, groupIndex).concat(row.slice(groupIndex + 1)),
      );
      return [keyAsIndexes, rowsWithoutColumn];
    })
    .object()
    .value();
  return { pivotData, columns };
}
function splitPivotData ( data , rowIndexes , columnIndexes ) { const groupIndex = data . cols . findIndex ( isPivotGroupColumn ) ; const columns = data . cols . filter ( col => ! isPivotGroupColumn ( col ) ) ; const breakouts = columns . filter ( col => col . source === "breakout" ) ; const pivotData = _ . chain ( data . rows ) . groupBy ( row => row [ groupIndex ] ) . pairs ( ) . map ( ( [ key , rows ] ) => { key = parseInt ( key ) ; const indexes = _ . range ( breakouts . length ) . filter ( index => ! ( ( 1 << index ) & key ) , ) ; const keyAsIndexes = JSON . stringify ( indexes ) ; const rowsWithoutColumn = rows . map ( row => row . slice ( 0 , groupIndex ) . concat ( row . slice ( groupIndex + 1 ) ) , ) ; return [ keyAsIndexes , rowsWithoutColumn ] ; } ) . object ( ) . value ( ) ; return { pivotData , columns } ; }
We use that column to split apart the data and convert the field refs to indexes.
We use that column to split apart the data and convert the field refs to indexes .