PieChart not drawing after querying Spreadsheet

31 views
Skip to first unread message

Greg Fiske

unread,
Oct 19, 2016, 9:30:31 PM10/19/16
to Google Visualization API
Hi folks - I'd like to query a Spreadsheet and use the results in a Pie Chart.  I'm having trouble getting the chart to draw.  Here's my example:


I appreciate any advice that you may provide,

thanks,

Greg

Daniel LaLiberte

unread,
Oct 20, 2016, 11:24:32 AM10/20/16
to Google Visualization API
Hi Greg,

There were three main problems with your example, which I fixed here: https://jsfiddle.net/dlaliberte/16awtj3w/2/
  • You were not loading the loader.
  • Your handleQueryResponse function was not being called.
  • Your data is not of the correct type as expected for PieChart.  I substituted in Table so you can see what is coming back.


--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/3c0fcdf6-193e-4c13-a41c-59c169d4cc6e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Greg Fiske

unread,
Oct 20, 2016, 4:00:16 PM10/20/16
to Google Visualization API
Thank you Daniel - this is very helpful.  And it fills in some gaps as I am learning this API.

I'm sorry for the naive followup question, but is there a way to convert the returned dataTable to the type (string) expected by PieChart?  

Greg


On Thursday, October 20, 2016 at 11:24:32 AM UTC-4, Daniel LaLiberte wrote:
Hi Greg,

There were three main problems with your example, which I fixed here: https://jsfiddle.net/dlaliberte/16awtj3w/2/
  • You were not loading the loader.
  • Your handleQueryResponse function was not being called.
  • Your data is not of the correct type as expected for PieChart.  I substituted in Table so you can see what is coming back.

On Wed, Oct 19, 2016 at 9:30 PM, Greg Fiske <gfi...@gmail.com> wrote:
Hi folks - I'd like to query a Spreadsheet and use the results in a Pie Chart.  I'm having trouble getting the chart to draw.  Here's my example:


I appreciate any advice that you may provide,

thanks,

Greg

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.



--

Daniel LaLiberte

unread,
Oct 20, 2016, 4:09:02 PM10/20/16
to Google Visualization API
Hi Greg,

You can format the number as a string, and then create a DataView with the string as your data.  But I am not sure that is really what you want.  For a PieChart, you need to provide a list of pairs of values, a discrete value (a string) and an number.  Why would it make sense to use a number as a discrete value?


On Thu, Oct 20, 2016 at 4:00 PM, Greg Fiske <gfi...@gmail.com> wrote:
Thank you Daniel - this is very helpful.  And it fills in some gaps as I am learning this API.

I'm sorry for the naive followup question, but is there a way to convert the returned dataTable to the type (string) expected by PieChart?  

Greg

On Thursday, October 20, 2016 at 11:24:32 AM UTC-4, Daniel LaLiberte wrote:
Hi Greg,

There were three main problems with your example, which I fixed here: https://jsfiddle.net/dlaliberte/16awtj3w/2/
  • You were not loading the loader.
  • Your handleQueryResponse function was not being called.
  • Your data is not of the correct type as expected for PieChart.  I substituted in Table so you can see what is coming back.

On Wed, Oct 19, 2016 at 9:30 PM, Greg Fiske <gfi...@gmail.com> wrote:
Hi folks - I'd like to query a Spreadsheet and use the results in a Pie Chart.  I'm having trouble getting the chart to draw.  Here's my example:


I appreciate any advice that you may provide,

thanks,

Greg

--
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 google-visualization-api+unsubscr...@googlegroups.com.



--

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Greg Fiske

unread,
Oct 20, 2016, 5:14:17 PM10/20/16
to Google Visualization API
Ultimately, I am after something like this.  While populating the numeric portion of each value pair from the spreadsheet query.

Thanks again.


On Thursday, October 20, 2016 at 4:09:02 PM UTC-4, Daniel LaLiberte wrote:
Hi Greg,

You can format the number as a string, and then create a DataView with the string as your data.  But I am not sure that is really what you want.  For a PieChart, you need to provide a list of pairs of values, a discrete value (a string) and an number.  Why would it make sense to use a number as a discrete value?

On Thu, Oct 20, 2016 at 4:00 PM, Greg Fiske <gfi...@gmail.com> wrote:
Thank you Daniel - this is very helpful.  And it fills in some gaps as I am learning this API.

I'm sorry for the naive followup question, but is there a way to convert the returned dataTable to the type (string) expected by PieChart?  

Greg

On Thursday, October 20, 2016 at 11:24:32 AM UTC-4, Daniel LaLiberte wrote:
Hi Greg,

There were three main problems with your example, which I fixed here: https://jsfiddle.net/dlaliberte/16awtj3w/2/
  • You were not loading the loader.
  • Your handleQueryResponse function was not being called.
  • Your data is not of the correct type as expected for PieChart.  I substituted in Table so you can see what is coming back.

On Wed, Oct 19, 2016 at 9:30 PM, Greg Fiske <gfi...@gmail.com> wrote:
Hi folks - I'd like to query a Spreadsheet and use the results in a Pie Chart.  I'm having trouble getting the chart to draw.  Here's my example:


I appreciate any advice that you may provide,

thanks,

Greg

--
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 google-visualization-api+unsub...@googlegroups.com.



--

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.



--

Daniel LaLiberte

unread,
Oct 21, 2016, 12:05:50 AM10/21/16
to Google Visualization API
Then you will want your table to look more like this:

var data = google.visualization.arrayToDataTable([
  ['source', 'amount'],
  ['grid', 103,990.0223],
  ['renewable', 683.25]
  ]);

Here it is in the jsfiddle:  https://jsfiddle.net/dlaliberte/16awtj3w/4/


On Thu, Oct 20, 2016 at 5:14 PM, Greg Fiske <gfi...@gmail.com> wrote:
Ultimately, I am after something like this.  While populating the numeric portion of each value pair from the spreadsheet query.

Thanks again.

On Thursday, October 20, 2016 at 4:09:02 PM UTC-4, Daniel LaLiberte wrote:
Hi Greg,

You can format the number as a string, and then create a DataView with the string as your data.  But I am not sure that is really what you want.  For a PieChart, you need to provide a list of pairs of values, a discrete value (a string) and an number.  Why would it make sense to use a number as a discrete value?

On Thu, Oct 20, 2016 at 4:00 PM, Greg Fiske <gfi...@gmail.com> wrote:
Thank you Daniel - this is very helpful.  And it fills in some gaps as I am learning this API.

I'm sorry for the naive followup question, but is there a way to convert the returned dataTable to the type (string) expected by PieChart?  

Greg

On Thursday, October 20, 2016 at 11:24:32 AM UTC-4, Daniel LaLiberte wrote:
Hi Greg,

There were three main problems with your example, which I fixed here: https://jsfiddle.net/dlaliberte/16awtj3w/2/
  • You were not loading the loader.
  • Your handleQueryResponse function was not being called.
  • Your data is not of the correct type as expected for PieChart.  I substituted in Table so you can see what is coming back.

On Wed, Oct 19, 2016 at 9:30 PM, Greg Fiske <gfi...@gmail.com> wrote:
Hi folks - I'd like to query a Spreadsheet and use the results in a Pie Chart.  I'm having trouble getting the chart to draw.  Here's my example:


I appreciate any advice that you may provide,

thanks,

Greg

--
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 google-visualization-api+unsubscr...@googlegroups.com.



--

--
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 google-visualization-api+unsubscr...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.



--

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Daniel LaLiberte

unread,
Oct 21, 2016, 12:06:37 AM10/21/16
to Google Visualization API
Sorry, I meant more like this: 

var data = google.visualization.arrayToDataTable([
  ['source', 'amount'],
  ['grid', 990.0223],
  ['renewable', 683.25]
  ]);

--
Reply all
Reply to author
Forward
0 new messages