function updateValueObject(
  row,
  indexes,
  columnSettings,
  seenValues,
  collapsedSubtotals = [],
) {
  let currentLevelSeenValues = seenValues;
  const prefix = [];
  for (const index of indexes) {
    const value = row[index];
    prefix.push(value);
    let seenValue = currentLevelSeenValues.find(d => d.value === value);
    const isCollapsed =
      // the specific path is collapsed
      collapsedSubtotals.includes(JSON.stringify(prefix)) ||
      // the entire column is collapsed
      collapsedSubtotals.includes(JSON.stringify(prefix.length));
    if (seenValue === undefined) {
      seenValue = { value, children: [], isCollapsed };
      currentLevelSeenValues.push(seenValue);
      sortLevelOfTree(currentLevelSeenValues, columnSettings[index]);
    }
    currentLevelSeenValues = seenValue.children;
  }
}
// Update the tree with a row of data
Update the tree with a row of data
Update the tree with a row of data
function updateValueObject(
  row,
  indexes,
  columnSettings,
  seenValues,
  collapsedSubtotals = [],
) {
  let currentLevelSeenValues = seenValues;
  const prefix = [];
  for (const index of indexes) {
    const value = row[index];
    prefix.push(value);
    let seenValue = currentLevelSeenValues.find(d => d.value === value);
    const isCollapsed =
      collapsedSubtotals.includes(JSON.stringify(prefix)) ||
      collapsedSubtotals.includes(JSON.stringify(prefix.length));
    if (seenValue === undefined) {
      seenValue = { value, children: [], isCollapsed };
      currentLevelSeenValues.push(seenValue);
      sortLevelOfTree(currentLevelSeenValues, columnSettings[index]);
    }
    currentLevelSeenValues = seenValue.children;
  }
}
function updateValueObject ( row , indexes , columnSettings , seenValues , collapsedSubtotals = [ ] , ) { let currentLevelSeenValues = seenValues ; const prefix = [ ] ; for ( const index of indexes ) { const value = row [ index ] ; prefix . push ( value ) ; let seenValue = currentLevelSeenValues . find ( d => d . value === value ) ; const isCollapsed = collapsedSubtotals . includes ( JSON . stringify ( prefix ) ) || collapsedSubtotals . includes ( JSON . stringify ( prefix . length ) ) ; if ( seenValue === undefined ) { seenValue = { value , children : [ ] , isCollapsed } ; currentLevelSeenValues . push ( seenValue ) ; sortLevelOfTree ( currentLevelSeenValues , columnSettings [ index ] ) ; } currentLevelSeenValues = seenValue . children ; } }
Update the tree with a row of data
Update the tree with a row of data
// the specific path is collapsed // the entire column is collapsed