Ok, I've seen some posts here about this but I haven't been able to
find any that answer my question specifically.  I have a feeling that
I'm missing something pretty basic.

I have a line chart that I'm populating via a data source.  The data
source itself is actually an exposed controller (python using
turbogears).

I can get the initial chart load to work just fine, but I want to have
the chart re-load with new data when the user clicks a back or forward
button on the page.

Here's what I'm doing in my javascript file for the page:

    10  var setup_scheduler_landing_page = function() {
    ...
    ...
    24      setup_hppd_chart('undefined','undefined');
    25  };


    38  var setup_hppd_chart = function(date_string, shift_type_id) {
    39      add_spinner($("#hppd_chart"));
    40
    41      if ( shift_type_id == 'undefined' ) {
    42          select_element = $
("#hppd_chart_form").children('select')
    43          shift_type_id = select_element.attr('options')
[select_element.attr('selectedIndex')].id
    44      }
    45
    46      var params = "?dt=" + date_string + "&shift_type_id=" +
shift_type_id;
    47
    48      var query = new google.visualization.Query("/landing_page/
get_hppd_chart_data" + params);
    49      query.send(handle_hppd_chart_setup_response);
    50
    51      bind_hppd_chart_nav_click();
    52  };

    64  var handle_hppd_chart_setup_response = function(response) {
    65      if ( response.isError() ) {
    66          alert( "Error in query: " + response.getMessage() + "
" + response.getDetailedMessage() );
    67          return false;
    68      }
    69
    70      var data = response.getDataTable();
    71      var visualization = new
google.visualization.LineChart(document.getElementById('hppd_chart'));
    72      visualization.draw(data,{height:220, title:'HPPD Info',
vAxis:{title:'Hours'}, hAxis:{title:'Dates',textColor:'#666666'}});
    73  };

I also have a click handler on the back/forward buttons that calls the
setup_hppd_chart function with updated parameters (for example, if you
push 'forward', setup_hppd_chart will get passed a date in the future,
which will return chart data for that date).

If you notice, setup_hppd_chart is where the query is being set up and
sent out.  Initially I call setup_hppd_chart through a chain of
commands in the document.ready function.

When I click the back/forward buttons and watch my net requests I see
that the data source is being hit with the correct parameters and it
is returning the json response.  For reference, the response looks
like this:

google.visualization.Query.setResponse({'version':'0.6', 'reqId':'0',
'status':'OK', 'table': {cols:[{id:'date',label:'Date',type:'string'},
{id:'assigned_hours',label:'Hours Assigned',type:'number'},
{id:'required_hours',label:'Hours Required',type:'number'}],rows:[{c:
[{v:'Jul, 01'},{v:112.0},{v:122.08}]},{c:[{v:'Jul, 02'},{v:104.0},{v:
117.6}]},{c:[{v:'Jul, 03'},{v:104.0},{v:117.6}]},{c:[{v:'Jul, 04'},{v:
96.0},{v:117.6}]},{c:[{v:'Jul, 05'},{v:112.0},{v:117.6}]},{c:[{v:'Jul,
06'},{v:104.0},{v:117.6}]},{c:[{v:'Jul, 07'},{v:104.0},{v:
117.6}]}]}});

Unfortunately, the handle_hppd_chart_setup_response function is not
called when the above json response is returned.

Again, this all works the first time the page loads, but subsequent
attempts to get the handle_hppd_chart_setup_response function to
trigger by calling query.send(handle_hppd_chart_setup_response) just
don't work.

Does anyone have any idea as to why this doesn't work the way I think
it should?

I appreciate any help you can offer.

Thanks!

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

Reply via email to