Hi, hoping to get some help with DataViews.  My ultimate goal is to draw 
Pie Charts and Column Charts form one DataTable - my understanding is that 
I can create different DataViews from that DataTable to support this.

I've created a DataTable with columns 'KGs', 'Year', 'Country', and 
'Material'.  I was able to create a pie chart that aggregated each 
country's KG's by year using the following code:

var by_year = google.visualization.data.group(dt, [1], [{'column': 0, 
'aggregation': google.visualization.data.sum, 'type': 'number'}]);
var chart = new 
google.visualization.PieChart(document.getElementById('chart_year'));
chart.draw(by_year, options);

I then wanted to create a Column Chart with KGs on the y-axis, Year on the 
x-axis and Country in the Legend.  I grouped the data as follows:

var by_year_country = google.visualization.data.group(dt, [1,2], 
[{'column': 0, 'aggregation': google.visualization.data.sum, 'type': 
'number'}]);

Then I tried to tell the API what was data and what was grouping with the 
following code, which produced a Column Chart but one in which the x-axis 
repeats the year for every country, and the legend has just one entry with 
no label:

var view = new google.visualization.DataView(by_year_country);
view.setColumns([
{sourceColumn:0, type:'string', role:'domain', label:'Year'},
{sourceColumn:1, type:'string', role:'domain', label:'Country'},
{sourceColumn:2, type:'number', role:'data'}
]);
chart.draw(view, options);

Can anyone provide any advice on how this is supposed to be implemented, or 
the appropriate terminology upon which to seek an answer?

Many thanks in advance,
Iain

-- 
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/-/WkwptTSEiTQJ.
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