googlecharts error- Invalid row type for row 0

2019-08-30 07:29发布

I am gettting this below error when i try to draw a line graph. i dont understand where i am doing wrong ReferenceError: CAE is not defined

[ "January 16",CAE,18],

Nationa...ers.jsp (line 11, col 36) Error: Invalid row type for row 0

Here is my code
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import="java.sql.*" %> 
    <%@ page import="java.io.*" %>
<!DOCTYPE html>
<html lang="en">
 <head>
        <script type="text/javascript">

            var theData = [ // Start of JavaScript data object
            <%
            Class.forName("oracle.jdbc.OracleDriver").newInstance();
            String connectionURL = "someurl";
            Connection connection = null;
            connection = DriverManager.getConnection(connectionURL);

                PreparedStatement ps = connection.prepareStatement("SELECT TRIM(TO_CHAR(order_date, 'Month')) ||' '|| TO_CHAR(order_date, 'yy') month, order_channel, total FROM ( SELECT order_date, order_channel, COUNT(*) total FROM order_channel WHERE order_date >= TO_DATE('01-Jan-2016', 'dd-Mon-yyyy') GROUP BY order_date, order_channel) ORDER BY TO_DATE(order_date), order_channel");
                ResultSet rs = ps.executeQuery();

                while (rs.next()) {
            %>
            [ "<%= rs.getString(1)%>",<%= rs.getString(2)%>,<%= rs.getString(3)%>],
            <%
                };
                // End of JavaScript object holding the data
            %>
                ];
        </script>

        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript">
            google.load("visualization", "1", {packages:['corechart', 'Bar']});
            google.setOnLoadCallback(drawChart);
           function drawChart() {
                var data = google.visualization.arrayToDataTable([['Month', 'OrderChannel', 'Total']].concat(theData), false);

                var options = {
                        title: 'National Monthly Orders',

                        hAxis: {

                            title: 'Month of Orderdate'

                          },
                          vAxis: {
                            title: 'Distinct count'
                          },
                          legend:{position:'none'}

                       };
                var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
                chart.draw(data, options);
            }
        </script>

    </head>
    <body>
        <div id="chart_div" style="width: 1000px; height: 350px;"></div>

    </body>
</html>

1条回答
别忘想泡老子
2楼-- · 2019-08-30 07:43

looks like the second column should be type: 'string'

try this...

["<%= rs.getString(1)%>", "<%= rs.getString(2)%>", <%= rs.getString(3)%>]

vs.

["<%= rs.getString(1)%>", <%= rs.getString(2)%>, <%= rs.getString(3)%>]

查看更多
登录 后发表回答