There are many different ways to get data from a database into a DataTable 
for the charts to use.  The simplest method is to output the values 
directly into javascript in jsp.  The syntax for this might change 
depending on the java framework you are using, but here's a basic example 
of how you might go about it:

function drawChart () {
    var data = new google.visualization.DataTable();
    data.addColumn('string', 'Category');
    data.addColumn('number', 'Value');
    data.addRows([
        // replace ${a} and ${b} with the requisite tags for outputting 
variables in your chosen framework
        ['A', ${a}],
        ['B', ${b}]
    ]);

    var chart = new 
google.visualization.PieChart(document.querySelector('#myPieChart');
    chart.draw(data, {
        height: 400,
        width: 600
    });
}

You can also set up an AJAX data source to query for your data instead of 
directly outputting the data.  There is a java library for creating a data 
source if you are interested in giving that a try (documentation 
here<https://developers.google.com/chart/interactive/docs/dev/dsl_intro>
).

On Thursday, March 13, 2014 10:56:15 PM UTC-4, Kunal singh wrote:
>
> I want the values used in my column chat and pie chart to come from my 
> database. I have the values in 2 variable suppose "var a" and "var b",how 
> do i use these values in order to get desired result i.e get the charts 
> drawn according to these values .i am doing a web-based project using jsp.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to