I would like to be able render multi-series, when I select multiple names
from the categoryFilter control. Here is my attempt below, but its failing
to create multi-series for select names.
google.visualization.events.addListener(control, 'statechange', function
() {
var filteredData = control.getState();
// get a list of all the labels in column 0
var group = filteredData.getDistinctValues(0);
// build the columns for the view
var columns = [5], groupColumns = [], viewColumns = [{
type: 'string',
label: data.getColumnLabel(5),
calc: function (dt, row) {
var date = dt.getValue(row, 0);
return dateFormatter.formatValue(date);
}
}];
for (var i = 0; i < group.length; i++) {
var label = group[i];
columns.push({
type: 'number',
label: label,
calc: (function (name) {
return function (dt, row) {
return (dt.getValue(row, 0) == name) ?
dt.getValue(row, 3) : null;
}
})(label)
});
groupColumns.push({
type: 'number',
label: label,
column: i + 1,
aggregation: google.visualization.data.sum
});
viewColumns.push(i + 1);
viewColumns.push({
type: 'string',
role: 'tooltip',
calc: (function (x) {
return function (dt, row) {
return 'Name: ' + dt.getColumnLabel(x) + ',
Price: ' + dt.getValue(row, x) + ', Date: ' + dt.getFormattedValue(row, 0);
}
})(i + 1)
});
}
var view = new google.visualization.DataView(filteredData);
view.setColumns(columns);
var groupedData = google.visualization.data.group(view,
[0], groupColumns);
line.setView({ columns: viewColumns });
line.setDataTable(groupedData);
line.draw();
});
The entire code can be found on here --> http://jsfiddle.net/miss/2c1djqu9/
please advice, if possible.
Thank you for your time and help.
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.