Wednesday, January 30, 2013

jsp, google charts, table has no columns

Hi All

Im getting the "table has no columns" all the time. Please let me know where I went wrong.

Below are my codes.

JSP: pie.jsp (This is to pull data from DB/DS. Currently Im trying with hardcode values as below.)

<%@page contentType="application/json; charset=UTF-8"%>
<%@page import="net.sf.json.JSONObject,net.sf.json.JSONArray"%>

    JSONObject obj=new JSONObject();
    obj.put("num",new Integer(100));
    obj.put("balance",new Double(1000.21));
    obj.put("is_vip",new Boolean(true));

JSP: Charts.jsp (This is to show the output chart)
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <script type="text/javascript" src="js/jsapi.js"></script>
        <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
        <script type="text/javascript">
            google.load("visualization", "1", {packages:["corechart"]});
            function drawChart() {
                var jsonData = $.ajax({
                                url: "./charts/pie.jsp",
                                async: false,
                                options: {'title': 'Reports'}
               var data = new google.visualization.DataTable(jsonData);
              // var data = new google.visualization.arrayToDataTable(jsonData);
               var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
               chart.draw(data, {width: 400, height: 240});
        <h3>Charts Demo</h3>
        <div id="chart_div" style="width: 400px; height: 200px;"></div>

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment