JavaScript
google.load('visualization', '1', {packages: ['treemap']});
google.setOnLoadCallback(drawVisualization);
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['Location', 'Parent', 'Market trade volume (size)', 'Market increase/decrease (color)'],
['Global', null, 0, 0],
['America', 'Global', 0, 0],
['Europe', 'Global', 0, 0],
['Asia', 'Global', 0, 0],
['Australia', 'Global', 0, 0],
['Africa', 'Global', 0, 0],
['Brazil', 'America', 11, 10],
['USA', 'America', 52, 31],
['Mexico', 'America', 24, 12],
['Canada', 'America', 16, -23],
['France', 'Europe', 42, -11],
['Germany', 'Europe', 31, -2],
['Sweden', 'Europe', 22, -13],
['Italy', 'Europe', 17, 4],
['UK', 'Europe', 21, -5],
['China', 'Asia', 36, 4],
['Japan', 'Asia', 20, -12],
['India', 'Asia', 40, 63],
['Laos', 'Asia', 4, 34],
['Mongolia', 'Asia', 1, -5],
['Israel', 'Asia', 12, 24],
['Iran', 'Asia', 18, 13],
['Pakistan', 'Asia', 11, -52],
['Egypt', 'Africa', 21, 0],
['S. Africa', 'Africa', 30, 43],
['Sudan', 'Africa', 12, 2],
['Congo', 'Africa', 10, 12],
['Zair', 'Africa', 8, 10]
]);
// group data by region
var group = google.visualization.data.group(data, [1], [{
column: 2,
type: 'number',
aggregation: google.visualization.data.sum
}, {
column: 3,
type: 'number',
aggregation: google.visualization.data.sum
}]);
var baseView = new google.visualization.DataView(group);
baseView.hideRows(baseView.getFilteredRows([{
column: 0,
value: null
}]));
baseView.setColumns([0, {
type: 'string',
calc: function (dt, row) {
return (dt.getValue(row, 0) == 'Global') ? null : 'Global';
}
...