Using variable names in pie chart data

34 views
Skip to first unread message

Mario Lopes

unread,
Sep 7, 2015, 8:16:29 AM9/7/15
to Google Visualization API
I am trying to create a pie chart where rather than the data being an actual number, it is the name of a variable as I am doing mathematical operations to the raw data from a database.

var data = new google.visualization.DataTable();
        data.addColumn('string', 'item');
        data.addColumn('number', 'value');
        data.addRows([
          ['A', a],
          ['B', b],
          ['C', c],
          ['D', d],
          ['E', e],
          ['F', f],
          ['G', g]
        ]);

The only time that I can display the graph is when a, b, c, d, e, f, and g are actual numerical values. Unfortunately, I have no idea of knowing those values as they are based on the data from the database. Any help is greatly appreciated. Thanks.

P-A

unread,
Nov 15, 2016, 1:40:26 PM11/15/16
to Google Visualization API
I have the same problem, if anyone have an anwser !  

Daniel LaLiberte

unread,
Nov 15, 2016, 1:53:57 PM11/15/16
to Google Visualization API
This is a very basic JavaScript question, and it is very easy to ensure that the variables have values before they are used.  E.g.

var a = 123;
var b = 456;
var data = new google.visualization.DataTable();
        data.addColumn('string', 'item');
        data.addColumn('number', 'value');
        data.addRows([
          ['A', a],
          ['B', b],
...

So it seems there must be something more to the question.  Perhaps you should give a more complete example of what you are doing.



--
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/bf4d131c-c10a-4c2b-8f81-0699f1dfc0e4%40googlegroups.com.

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



--
Reply all
Reply to author
Forward
0 new messages