@SuppressWarnings("unchecked")
    public String getEventsLineChart() {
        PreparedStatement st = null;
        ResultSet rs = null;
        JSONArray json = new JSONArray();
        try {
            conn = dbconn.getConnection();
            st = conn.prepareStatement("SELECT m.event_id, e.name, sum(m.auton_top)*6 + sum(m.auton_middle)*4  + sum(m.auton_bottom)*2 + sum(m.teleop_top)*3 + sum(m.teleop_middle)*2 + sum(m.teleop_bottom) + sum(m.teleop_pyramid)*5 + sum(m.pyramid_level)*10 as total FROM match_record_2013 m, events e WHERE team_id = ? and m.event_id = e.id GROUP BY event_id");
            st.setInt(1, getSelectedTeam());
            rs = st.executeQuery();
            while (rs.next()) {
                JSONObject o = new JSONObject();
                o.put("id", rs.getInt("event_id"));
                o.put("name", rs.getString("name"));
                o.put("total_points", rs.getInt("total"));
                json.add(o);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try{
                conn.close();
                st.close();
                rs.close();
            }catch (SQLException e) {
                System.out.println("Error closing query");
            }
        }
        return json.toString();
    }