There is nothing, insofar as I am aware, that does this specifically, but 
you could code your own:

// data is the dataTable object to convert
// rows is an object containing:
//      indices: an array of the indices of the rows to convert to columns, 
in the order you want the new columns (see format of dataView setRows 
method)
//      types: an array of the data types for the new columns
//      labels: an array of labels for the new columns
// columns is an array of the indices of the columns to convert to rows, in 
the order you want the new rows (see format of dataView setColumns method); 
leave blank to include all columns
function columnsToRows(data, rows, columns) {
     if (columns.length == 0) {
          columns = [];
          for (var i = 0; i < data.getNumberOfColumns(); i++) {
               columns.push(i);
          }
     }
     var newData = new google.visualization.DataTable();
     for (var i = 0; i < rows['types'].length; i++) {
          newData.addColumn(rows['types'][i], rows['labels'][i]));
     }
     for (var i = 0; i < columns.length; i++) {
          newData.addRow();
          for (var j = 0; j < rows['indices'].length; j++) {
               newData.setValue(columns[i], rows['indices'][j], 
data.getValue(rows['indices'][j], columns[i]));
          }
     }
     return newData;
}

It's not very efficient, and not very elegant, but with some tweaking it 
would probably get the job done.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/cWxlRU9heXhkQ1VK.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to