Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
291 views
in Technique[技术] by (71.8m points)

google visualization - googlecharts error- Invalid row type for row 0

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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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)%>]


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...