sorry but i cant post a link or the code with data..
when i use your code (exactly as you wrote it) i have this error: Expected
identifier, string or number
the line is this:
------------------------------------------------------------------
view.setColumns([0, {
type: 'number',
label: 'foo',
func: function (dataTable, rownum) {
return dataTable.getValue(rownum, 1) / fooBase;
}, {
<----------------------------------------------------------------
ERROR
type: 'number',
label: 'bar',
func: function (dataTable, rownum) {
return dataTable.getValue(rownum, 2) / barBase;
}]);
-----------------------------------------------------------------
the code as i write it doesn't return any error, draw the chart, but nothing
happens when i change range data selection...
i post u again the code, this time with some exemple data:
google.load('visualization', '1', {'packages':['annotatedtimeline']});
google.setOnLoadCallback(drawchart);
function drawchart() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Data');
data.addColumn('number', 'fondo');
data.addColumn('number', 'Benchmark');
data.addRows([[new Date(2007, 8, 24), 5, 100], [new Date(2007, 8, 25),
4.992, 99.3632911510798], [new Date(2007, 8, 26), 5.026, 100.075701244891],
[new Date(2007, 8, 27), 5.029, 100.568918725117], [new Date(2007, 8, 28),
5.028, 100.422972180913], [new Date(2007, 9, 1), 5.066, 100.983706987663], [
new Date(2007, 9, 2), 5.105, 101.33220551144], [new Date(2007, 9, 3), 5.116,
101.223086599886], [new Date(2007, 9, 4), 5.107, 101.199216837983], [newDate(
2007, 9, 5), 5.12, 101.900033047442], [new Date(2007, 9, 8), 5.109,
101.509796539995], [new Date(2007, 9, 9), 5.132, 101.744811395756]);
var chart = new
google.visualization.AnnotatedTimeLine(document.getElementById('chart_div'));
var options = {width: 300, height: 300, displayAnnotations: 'false',
legend: 'right', scaleType: 'allmaximized'};
chart.draw(data, options);
google.visualization.events.addListener(chart, 'rangechange', normalize);
function normalize() {
var start = chart.getVisibleChartRange().start;
var end = chart.getVisibleChartRange().end;
var fooBase = chart.getValue(chart.getFilteredRows(start)[0], 1);
var barBase = chart.getValue(chart.getFilteredRows(start)[0], 2);
var view = new google.visualization.DataView(data);
view.setColumns([0, {type: 'number', label: 'foo', calc:colone }, {type:
'number', label: 'bar', calc:coltwo}]);
function colone(dataTable, rownum) {
return (dataTable.getValue(rownum, 1)/fooBase);
}
function coltwo(dataTable, rownum) {
return (dataTable.getValue(rownum, 2)/barBase);
}
chart.draw(view, options);
};
}
--
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/-/46Fig_8HMnsJ.
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.