However, you can set the DataTable from a JSON object using the JavaScript Literal Initializer<https://developers.google.com/chart/interactive/docs/datatables_dataviews#javascriptliteral>, which would make your your DataTable constructor look like something like the following: var data = new google.visualization.DataTable({ cols: [{label: 'Topping', type: 'string'}, {label: 'Slices', type: 'number'}], rows: [ ['Mushrooms', 3], ['Onions', 1], ['Olives', 1], ['Zucchini', 1], ['Pepperoni', 2]]});
Hope this helps! - Sergey On Mon, Dec 17, 2012 at 10:19 AM, Sergey Grabkovsky <[email protected]>wrote: > Hi, I'm slightly confused by your message. Are you trying to present a Pie > Chart in your Java application? If so, that is not possible. The > Visualization API is JavaScript-based and cannot be used from Java unless > your Java is presenting a web page. > > - Sergey > > > > On Mon, Dec 17, 2012 at 7:48 AM, ah89 <[email protected]> wrote: > >> Hi, >> >> I have a question about the combination of Google Visualization API and >> JSON. >> >> At the moment I use the following DataTable for setting up a Pie Chart: >> >> var data = new google.visualization.DataTable(); >> data.addColumn('string', 'Topping'); >> data.addColumn('number', 'Slices'); >> data.addRows([ >> ['Mushrooms', 3], >> ['Onions', 1], >> ['Olives', 1], >> ['Zucchini', 1], >> ['Pepperoni', 2] >> ]); >> >> Instead of using a DataTable, I would like to use JSON in my J2EE >> application. >> How can I accomplish this? I know how I can setup a JSON string, but not >> when there are both rows and columns in play. >> Hopefully someone will help me. >> >> Thanks in advance! >> >> -- >> 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/-/DBsXT8a-40MJ. >> 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. >> > > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. 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.
