Thanks for the response.

When I send a query it ignores the refreshinterval and only executes once.

The code looks like:
<html>
  <head>
    <!--Load the AJAX API-->
    <script type="text/javascript" 
src="https://www.google.com/jsapi";></script>
    <script type="text/javascript">

      // Load the Visualization API and the controls package.
      google.load('visualization', '1.0', {'packages':['controls']});

      // Set a callback to run when the Google Visualization API is loaded.
      google.setOnLoadCallback(drawDashboard);

      // Callback that creates and populates a data table,
      // instantiates a dashboard, a range slider and a pie chart,
      // passes in the data and draws it.
      function drawDashboard() {

        var query = new 
google.visualization.Query('http://127.0.0.1:8000/cxp/query');
        query.setRefreshInterval(5);
        query.setQuery('test');
        query.setTimeout(5);
        query.send(handle_query);
        console.log('sending query')

        // Create our data table.
        var data = google.visualization.arrayToDataTable([
          ['Year', 'Sales', 'Expenses'],
          ['2004',  1000,      400],
          ['2005',  1170,      460],
          ['2006',  660,       1120],
          ['2007',  1030,      540]
        ]);


        // Create a dashboard.
        var dashboard = new google.visualization.Dashboard(
            document.getElementById('dashboard_div'));

        // Create a range slider, passing some options
        var slider = new google.visualization.ControlWrapper({
          'controlType': 'ChartRangeFilter',
          'containerId': 'filter_div',
          'options': {
             // Filter by the date axis.
             'filterColumnIndex': 0,
             'ui': {
               'chartType': 'LineChart',
               'chartOptions': {
                 'chartArea': {'height': '45%',
                               'width': '40%'},
                 'hAxis': {'baselineColor': 'none'}
               },
               // Display a single series that shows the closing value of 
the stock.
               // Thus, this view has two columns: the date (axis) and the 
stock value (line series).
               'chartView': {
                 'columns': [0, 1]
               },
             }
           },
         });  

        // Create a pie chart, passing some options
        var chart = new google.visualization.ChartWrapper({
          chartType: 'LineChart',                                           
                     
          options: {                                                       
                         
              'title': 'Title',                                       
              'height': 500,                                               
                           
              'width': 1000,                                      
              'animation': {'duration':1000, 'easing':'inAndOut'}           
         
          },                                                               
                           
          containerId: 'chart_div',                                         
                            
          view: {'columns':[0,1,2]}                                         
                    
        });
        

        // Establish dependencies, declaring that 'filter' drives 
'pieChart',
        // so that the pie chart will only display entries that are let 
through
        // given the chosen slider range.
        dashboard.bind(slider, chart);

        function handle_query(queryResponse){
          console.log('handling query');
          data=queryResponse.getDataTable();
          dashboard.draw(data);
        }

        // Draw the dashboard.
        //dashboard.draw(data);
      }
    </script>
  </head>

  <body>
    <!--Div that will hold the dashboard-->
    <div id="dashboard_div">
      <!--Divs that will hold each control and chart-->
      <div id="chart_div"></div>
      <div id="filter_div"></div>
    </div>
  </body>
</html>

On Monday, November 19, 2012 1:37:23 AM UTC-6, asgallant wrote:
>
> When using Dashboards, you cannot use the refreshInterval to requery your 
> data source.  You have to use the 
> Query<https://developers.google.com/chart/interactive/docs/reference#queryobjects>class
>  to create a query and the setTimeout or setInterval js functions to 
> resend the query.  You fetch the DataTable from the data returned by the 
> query and pass it to the Dashboard object when you call the Dashboard's 
> #draw method.  The Dashboard handles distributing data to all of the 
> controls and charts bound in the Dashboard.
>
> On Sunday, November 18, 2012 8:58:30 PM UTC-5, David Vine wrote:
>>
>> Hi,
>>
>> I'm trying to use ChartWrapper objects in a dahsboard with a remote data 
>> source and have the data refresh using refreshInterval.
>>
>> In the docs it says:
>> Do not set its dataTable, query, dataSourceUrl and refreshInterval 
>> attributes 
>> explicitly.
>> c.f 
>> https://developers.google.com/chart/interactive/docs/gallery/controls#dashboardobject
>>
>> My question is how do I set these if not explicitly? 
>>
>> Thanks,
>> David
>>
>

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