passing parameter issue

36 views
Skip to first unread message

sk

unread,
May 30, 2012, 1:58:11 AM5/30/12
to google-visua...@googlegroups.com
hello
i'm trying to display the piechart using spreadsheet data  https://docs.google.com/spreadsheet/ccc?key=0ArFGfpB6duBGdFpSa2s0TEliUlVBVWdDbEs2N0ttNnc#gid=0
1) problem is that only two states details are being dispayed in the chart,the code i did is
2) i need to pass state as parameter to the chart
how can do this ,please kindly help me

 function draw(response) {
        if (response.isError()) {
          alert('Error in query');
        }

        var data = response.getDataTable();
        var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
        chart.draw(data, {'isStacked': true, 'legend': 'bottom','vAxis': {'title': ''}});

      }
function drawPieChart(){
                var queryP = new google.visualization.Query(
              'https://docs.google.com/spreadsheet/ccc?key=0ArFGfpB6duBGdFpSa2s0TEliUlVBVWdDbEs2N0ttNnc#gid=0' );
     
           queryP.send(handleQueryResponse);
       }

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

         var dataP = response.getDataTable();
        var chart1 = new google.visualization.PieChart(document.getElementById('pie_div'));
         chart1.draw(dataP);
    }
  google.setOnLoadCallback(drawVisualization);

Jinji

unread,
May 30, 2012, 9:19:53 AM5/30/12
to google-visua...@googlegroups.com
I don't have permissions to access the spreadsheet, so I can't really look at it. Make sure the data adheres to the PieChart data format.



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

sk

unread,
May 31, 2012, 5:37:28 AM5/31/12
to google-visua...@googlegroups.com
sorry,now i shared the the data please kindly check

asgallant

unread,
May 31, 2012, 9:21:55 AM5/31/12
to google-visua...@googlegroups.com
For part 1, the chart is using only the first two columns of data (state and agro) to draw the pie (this is the expected behavior of a PieChart).  Since only two states have non-zero values in the second column, those are the only two that will show up.

For part 2, what do you want to happen when you pass the state to the draw function?

I suspect what you are looking for here is draw a pie chart for a single state comparing the values in all columns.  If so, then you have to change the structure of the data to put it the format that PieCharts use.  I wrote an example that might help you: http://jsfiddle.net/asgallant/tn8Bk/ 
Reply all
Reply to author
Forward
0 new messages