I believe you want to set the chart range after redrawing.  Try using a 
"ready" event handler to do this:

function Callback(result) {
    data = new google.visualization.DataTable(result);
    var range = data.getColumnRange(0);
    google.visualization.events.addOneTimeListener(chart, 'ready', function 
() {
        chart.setVisibleChartRange(new Date(range.max.getFullYear() - 1, 
range.max.getMonth(), range.max.getDate()), null); //null sets the maximum 
date
    }
    chart.draw(data,options);
}

On Monday, September 15, 2014 3:27:48 AM UTC-4, Shivani Kanakhara wrote:
>
> Hi,
> I am using annotation chart where the data changes according to item 
> selected from DropDownlist.
> It works fine . But every time the data is loaded i want 1 year range to 
> be selected by default.
> I used chart.setVisibleRange() but its not working..don't know why.
> I have used webService to load data.
> Here's my code:
>
> google.visualization.events.addListener(chart, 'ready', function () {
>             document.getElementById('DropDownList1').onchange = function 
> () {
>
>                 var dropDown = document.getElementById('DropDownList1');
>                 var value = dropDown[dropDown.selectedIndex].value;
>                 ChartsDemo.WebService1.GetData(value, Callback);
>
>             }
>
>             function Callback(result) {
>
>                 data = new google.visualization.DataTable(result);
>                 var range = data.getColumnRange(0);
>                 chart.setVisibleChartRange(new 
> Date(range.max.getFullYear() - 1, range.max.getMonth(), 
> range.max.getDate()), null); //null sets the maximum date     
>                 chart.draw(data,options);
>             }
>
>
>         });
>

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

Reply via email to