Hi,
Checked and fixed, with help from Ken, a colleague! Here is the
result for a generalized data with N rows displayed
var chart = new
google.visualization.AnnotatedTimeLine(document.getElementById('dave_chart'));
chart.draw(data, {displayAnnotations: false});
google.visualization.events.addListener(chart,
'rangechange',function(event) {
r = chart.getVisibleChartRange();
n = data.getNumberOfRows();
m = data.getNumberOfColumns();
for (i=0;i<n;i++) {
if (r.start < data.getValue(i,0)) { break;}
}
var base=new Array(m);
base[0]=0;
for (k=1;k<m;k++) { base[k]=data.getValue(i,k);}
for (j=0;j<n;j++) {
for (k=1;k<m;k++) {
data.setValue(j,k,data.getValue(j,k)-base[k]);
}
}
chart.draw(data, {displayAnnotations: false});
chart.setVisibleChartRange(r.start,r.end);
});
Make sure that you send in all your fixes so we can help each other!
Yours
Enock
PS Keep up the good work Viz Kid!
On Mar 9, 4:44 am, Viz Kid <[email protected]> wrote:
> Hi.
>
> Calling the draw method again should work. Double check to see that all the
> variables are indeed available when you are inside the called function.
>
> Viz Kid
>
> On Sat, Mar 6, 2010 at 2:29 AM, Enock <[email protected]> wrote:
> > Hi,
>
> > I have a static set of data for a chart for a range chart. The data
> > is changes in percentage. I would like to rebase all the data to
> > start at 0 when the range changes.
>
> > I have got the google.visualization.events.addListener(chart1,
> > 'rangechange',function(event) {}) to work and I can now isolate the
> > correct date to make zero.
>
> > I have been going through the data and altering the values to rebase
> > it, BUT the chart does not update...
>
> > Any clues would be gratefully received.
>
> > Yours
>
> > Enock
>
> > var dataChanged = data.clone()
>
> > var chart1 = new
>
> > google.visualization.AnnotatedTimeLine(document.getElementById('dave_chart'));
> > chart1.draw(dataChanged, {displayAnnotations: false});
>
> > google.visualization.events.addListener(chart1,
> > 'rangechange',function(event) {
> > r1 = chart1.getVisibleChartRange();
> > var value = 0.0;
> > var i=0;
> > do
> > {
> > var currCell = data.getValue(i,0);
>
> > if ( r1.start < currCell ) {
> > value = data.getValue(i-1,1);
> > i = data.getNumberOfRows();
> > alert('Found the date '+r1.start+' is more than
> > '+currCell+' value '+value+' i '+i);
> > }
> > i++;
> > }
> > while(i<data.getNumberOfRows());
>
> > for(i=0;i<dataChanged.getNumberOfRows();i++) {
> > dataChanaged.setValue(i,1,data.getValue(i,1)-value);
> > }
> > chart1.draw(dataChanaged, {displayAnnotations: false});
> > });
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Visualization API" group.
> > To post to this group, send email to
> > [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<google-visualization-api%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-visualization-api?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
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.