Programowe przestawianie tabeli danych Google Visualization

Podekscytowanyto skrzypce i próbowałem stworzyć ten sam rodzaj w odniesieniu do tego skrzypce. Moja zmodyfikowana próbka jest podanatutaj i próbuję stworzyć widok w następujący sposób.

var distinctValues = data.getDistinctValues(2);

    var viewColumns = [1];
    var groupColumns = [];
    // build column arrays for the view and grouping
    for (var i = 0; i < distinctValues.length; i++) {
        viewColumns.push({
            type: 'number',
            label: distinctValues[i],
            aggregation: google.visualization.data.count
        });
        groupColumns.push({
            column: i+1,
            type: 'number',
            //label: distinctValues[i],
            aggregation: google.visualization.data.sum
        });
    }

Ale moim celem jest stworzenie tabeli przestawnej w następujący sposób.

['Column1', 'Column2', 100, 200, 300, 400],
['A', 'bar', 0, 1, 1, 0],
['A', 'baz', 0, 0, 1, 0],
['A', 'foo', 3, 1, 0, 0],
['B', 'baz', 0, 1, 0, 0],
['B', 'cad', 1, 0, 1, 1],
['B', 'qud', 1, 1, 1, 2]

Jak mogę kontynuować?

questionAnswers(1)

yourAnswerToTheQuestion