java - Creating a bar chart using JSP -
how create bar chart through data database using jsp.i created 2 tables in database (1)cust_entry,(2)cust_response.so plz give me correct code , place put code in coding.
thanks in advance.
thanks
<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>customer response</title> </head> <body> <%@page import="java.sql.*" %> <%! string name,date,desg,org,add,q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,q11,q12,q13,q14,q15,q16; connection con=null; statement stmt=null; // statement stmt1=null; // resultset rs=null; string drivername="com.mysql.jdbc.driver"; string url="jdbc:mysql://106.197.161.194/wiprofeedback.jsp/wipro"; string user="root"; string password ="root"; %> <% name= request.getparameter("person"); date= request.getparameter("date"); desg=request.getparameter("designation"); org=request.getparameter("organisation"); add=request.getparameter("address"); q1=request.getparameter("group1"); q2=request.getparameter("group2"); q3=request.getparameter("group3"); q4=request.getparameter("group4"); q5=request.getparameter("group5"); q6=request.getparameter("group6"); q7=request.getparameter("group7"); q8=request.getparameter("group8"); q9=request.getparameter("group9"); q10=request.getparameter("group10"); q11=request.getparameter("group11"); q12=request.getparameter("group12"); q13=request.getparameter("group13"); q14=request.getparameter("group14"); q15=request.getparameter("group15"); q16=request.getparameter("group16"); %> <% try{ class.forname(drivername); connection con=drivermanager.getconnection(url,user,password); statement stmt = con.createstatement(); stmt.executeupdate("insert cust_entry(name,date,desg,org,address) values('"+name+"','"+date+"','"+desg+"','"+org+"','"+add+"')"); stmt.executeupdate("insert cust_response(q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,q11,q12,q13,q14,q15,q16) values('"+q1+"','"+q2+"','"+q3+"','"+q4+"','"+q5+"','"+q6+"','"+q7+"','"+q8+"','"+q9+"','"+q10+"','"+q11+"','"+q12+"','"+q13+"','"+q14+"','"+q15+"','"+q16+"')"); }catch(sqlexception e) { system.out.println(e); } %> name :<%=name%> <br> date:<%=date%> <br> desg:<%=desg%> <br> org:<%=org%> <br> add:<%=add%> <br> group1:<%=q1%> <br> group2:<%=q2%> <br> group3:<%=q3%> <br> group4:<%=q4%> <br> group5:<%=q5%> <br> group6:<%=q6%> <br> group7:<%=q7%> <br> group8:<%=q8%> <br> group9:<%=q9%> <br> group10:<%=q10%> <br> group11:<%=q11%> <br> group12:<%=q12%> <br> group13:<%=q13%> <br> group14:<%=q14%> <br> group15:<%=q15%> <br> group16:<%=q16%> </body> </html>
use highcharts library... put dynamic jsp value in.
$(function () { var chart = new highcharts.chart({ chart: { renderto: 'container', type: 'column' }, xaxis: { categories: ['q_1', 'q_2', 'q_3', 'q_4'] }, plotoptions: { series: { cursor: 'pointer', point: { events: { click: function() { (var = 0; < this.series.data.length; i++) { this.series.data[i].update({ color: '#ecb631' }, true, false); } this.update({ color: '#f00' }, true, false) } } } } }, series: [{ data: [<%=q_1%>,<%=q_2%>,<%=q_3%>,<%=q_4%>] }] }); });
Comments
Post a Comment