_formatData()

in modules/core/src/components/declarative-ui/xviz-table.js [71:104]


  _formatData({columns, nodes, displayObjectId}) {
    if (!columns || !nodes) {
      return {columns: null};
    }

    columns = columns.map(col => ({
      name: col.display_text,
      type: col.type
    }));

    const rowIds = {};
    const rows = [];

    nodes.forEach(node => {
      const row = {
        data: node.column_values || [],
        children: []
      };
      rowIds[node.id] = row;

      // Validate the property is on the instance, and not just in the
      // prototype chain. This comes from how protobuf.js implements messages
      if (!node.hasOwnProperty('parent') || node.parent === undefined) {
        rows.push(row);
      } else {
        const parentRow = rowIds[node.parent];
        if (parentRow) {
          parentRow.children.push(row);
        }
      }
    });

    return {columns, rows};
  }