need help in using query

43 views
Skip to first unread message

alireza

unread,
Sep 21, 2012, 4:56:47 PM9/21/12
to google-visua...@googlegroups.com
Hello there
/i used two ready codes: candelstick and query from a google spreadsheet to draw a chart.It draws an incomplete chart and after it writes google.setOnLoadCallback(drawVisualization().I am so thankful of somone who help me solve this problem.here is the code:
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>
      Google Visualization API Sample
    </title>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load('visualization', '1', {packages: ['corechart']});
    </script>
    <script type="text/javascript">
      function drawVisualization() {
      
  var query = new google.visualization.Query(
        'https://docs.google.com/spreadsheet/pub?key=0AsEU1fdbnCNudGpvWk4tZU5iMVdpQ1ZTXzFkb2ZFWUE&single=true&gid=0&output=html');

    // Apply query language statement.
    query.setQuery('SELECT A,C,D,E,F');
   
    // Send the query with a callback function.
    query.send(handleQueryResponse);
  }

  function handleQueryResponse(response) {
    if (response.isError()) {
      alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
      return;
    }

    var data = response.getDataTable();

        var options = {
legend:          'none'
        };

        var chart = new google.visualization.CandlestickChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }

      google.setOnLoadCallback(drawVisualization);
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>


asgallant

unread,
Sep 21, 2012, 5:16:06 PM9/21/12
to google-visua...@googlegroups.com
I don't think the chart is the problem, I think the data is the problem.  In many cases, your open and close values are the same as your high and low values, and in some cases, the open/close values are outside the range of the high/low values, which should never happen, (see 9/20/2012 11:44, where the high value is 99960000 and the open value is 99980000).

Otherwise, your code works fine: http://jsfiddle.net/asgallant/4TfLF/ 

alireza mokhtari

unread,
Sep 22, 2012, 1:12:20 AM9/22/12
to google-visua...@googlegroups.com
You are right.sometimes I am so careless.Thanks a lot for being so helpful.
sincerely yours

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

To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

Reply all
Reply to author
Forward
0 new messages