Charts in JSP

Charts in JSP

Hi,

Thanks for replying for the chart query I made 2 days back.. Can u plz provide me an example for creating a series bar chart with the datas coming from the database? Series chart in the sense, If I have x axis as months(Jan, Feb, Mar,.......) and y axis some values say.. For january month itself, there must be three comparisions say one showing the population, other showing the commodity prices and other showing the temperature.. These three has to be differentiated with 3 different colors.. Like wise for all the months....

Plz reply asap...

Regards,
ragav..
View Answers

February 25, 2010 at 11:23 AM

Hi Friend,

Try the following code:

<%@page import="java.io.*"%>
<%@page import="java.sql.*"%>
<%@page import="org.jfree.chart.*"%>
<%@page import="org.jfree.chart.plot.*"%>
<%@page import="org.jfree.data.category.*"%>
<%
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root";);
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from barchart");
while(rs.next()){
dataset.addValue(Double.parseDouble(rs.getString(1)), "Population", rs.getString(4));
dataset.addValue(Double.parseDouble(rs.getString(2)), "Prices", rs.getString(4));
dataset.addValue(Double.parseDouble(rs.getString(2)), "Temperature", rs.getString(4));
}
JFreeChart chart = ChartFactory.createBarChart(
"Bar Chart ",
"Months",
"Value",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false
);
String f="C:/chart.jpg";
ChartUtilities.saveChartAsJPEG(new File(f), chart, 600, 300);
}
catch(Exception e){}
%>

Thanks









Related Tutorials/Questions & Answers:
Charts in JSP - JSP-Servlet
of charts in JSP.. So, Can i know the pre requirement for that? Do i need...Charts in JSP  Hi Roseindia team, This is ragav.. I... the following link: http://www.roseindia.net/jsp/draw-statistical-chart
generate charts using JSP
generate charts using JSP  any one know coding for generate bar chart or pie chart using JSP
Advertisements
java bar charts and jsp
java bar charts and jsp  Hi, Can any one help me out in how to create java bar charts using jsp with the help of data base table values? thanks.../jsp/draw-statistical-chart-jsp.shtml
java charts - JSP-Servlet
java charts  Hi,can any one tell me how to create dyanamic charts wrt database contents by using jsp-servlet
Bar charts and jsp
Bar charts and jsp  Hi, How to generate Dynamic Bar Chart Images using jsp with placing any image location in weebroots? Thanks in advance
Charts in JSP - JSP-Servlet
Charts in JSP  Hi, Thanks for replying for the chart query I made 2 days back.. Can u plz provide me an example for creating a series bar chart with the datas coming from the database? Series chart in the sense, If I have x
Doubt regarding charts and jsp
Doubt regarding charts and jsp  Hi, I successfully executed... in web application(jsp). So,please help me out in how to connect the normal java application output to an jsp page? thanks in advance   Put the jar
Statistical charts in JSP - problem
Statistical charts in JSP - problem  hey! i get this error when i run... to compile class for JSP: An error occurred at line: 9 in the generated.... org.jfree.data.jdbc.JDBCCategoryDataset resolves to a package An error occurred at line: 11 in the jsp
Doubt regarding charts and jsp
Doubt regarding charts and jsp  Hi in the http://www.roseindia.net/chartgraphs/barchart-jsppage.shtml of the code (new StandardEntityCollection()); final File file1 = new File("../webapps/jspchart/web/barchart.png
java with jsp and dynamic database retrival for bar charts
java with jsp and dynamic database retrival for bar charts  Hi, I am having a table name tablelogin,it consists of columns userid,logintime,sessionid,ip_address,logout. so,can any one help me out how to get the bar chart
graphs/charts - JSP-Servlet
graphs/charts - JSP-Servlet
java charts - Development process
java charts  Hi,i want to create charts wrt database by using jsp?please help me
flow charts
flow charts   draw a flow chart program with a user prompt of 5 numbers computing the maximum, minimum and average
jree charts
jree charts  i have to use jfree charts how to download its api and where to keep it in jdk order to execute   Please visit the following link: Download JFreechart Download jfreechart-1.0.13.zip from the given link
jsp code - JSP-Servlet
jsp code  I need code for bar charts using jsp. I searched some code but they are contain some of their own packages. Please give me asimple code for bar charts and what are the topics required for that charts.  Hi
fusion charts
fusion charts  hi i have to use the fusion chart. i don't know how to use and code in jsp and i have to create the chart by using the data from db. please help me doing that with exapmles. thank you
ModuleNotFoundError: No module named 'charts'
ModuleNotFoundError: No module named 'charts'  Hi, My Python... 'charts' How to remove the ModuleNotFoundError: No module named 'charts'... to install padas library. You can install charts python with following command
How to create charts in Java?
How to create charts in Java?  Is there any example of creating charts and graphs in Java? thanks   Hi, check the tutorial: Chart & Graphs Tutorials in Java Thanks
Doubt Regarding Charts
Doubt Regarding Charts  Hi, Can you please help me out by answering "hoe to include charts in core java code and struts code" thanks in advance... charts and graphs
Version of com.ahome-it>lienzo-charts dependency
List of Version of com.ahome-it>lienzo-charts dependency
Merge XYLine and XYArea Charts
Merge XYLine and XYArea Charts  I wonder how to merge two charts... (this website) how to use two XYLine Charts and display them. Please, see screenshot... appreciate any help. Please, bear in mind I am new to charts plotting in java
ModuleNotFoundError: No module named 'agate-charts'
ModuleNotFoundError: No module named 'agate-charts'  Hi, My Python... 'agate-charts' How to remove the ModuleNotFoundError: No module named 'agate-charts' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'djangocms-charts'
ModuleNotFoundError: No module named 'djangocms-charts'  Hi, My... named 'djangocms-charts' How to remove the ModuleNotFoundError: No module named 'djangocms-charts' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'plotly-charts'
ModuleNotFoundError: No module named 'plotly-charts'  Hi, My... 'plotly-charts' How to remove the ModuleNotFoundError: No module named 'plotly-charts' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'plotly-charts'
ModuleNotFoundError: No module named 'plotly-charts'  Hi, My... 'plotly-charts' How to remove the ModuleNotFoundError: No module named 'plotly-charts' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pudzu-charts'
ModuleNotFoundError: No module named 'pudzu-charts'  Hi, My Python... 'pudzu-charts' How to remove the ModuleNotFoundError: No module named 'pudzu-charts' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'agate-charts'
ModuleNotFoundError: No module named 'agate-charts'  Hi, My Python... 'agate-charts' How to remove the ModuleNotFoundError: No module named 'agate-charts' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-charts'
ModuleNotFoundError: No module named 'django-charts'  Hi, My... 'django-charts' How to remove the ModuleNotFoundError: No module named 'django-charts' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'djangocms-charts'
ModuleNotFoundError: No module named 'djangocms-charts'  Hi, My... named 'djangocms-charts' How to remove the ModuleNotFoundError: No module named 'djangocms-charts' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'Flask-Charts'
ModuleNotFoundError: No module named 'Flask-Charts'  Hi, My Python... 'Flask-Charts' How to remove the ModuleNotFoundError: No module named 'Flask-Charts' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'helm-charts'
ModuleNotFoundError: No module named 'helm-charts'  Hi, My Python... 'helm-charts' How to remove the ModuleNotFoundError: No module named 'helm-charts' error? Thanks   Hi, In your python environment
Good Looking Java Charts and Graphs
Good Looking Java Charts and Graphs  Is there a java chart library that will generate charts and graphs with the quality of visifire or fusion charts? The JFreeChart graph quality is not professional looking. Unless it can
jsp
jsp  how jsp translated into servlets
JSP
JSP  How to run jsp program in eclipse
jsp
jsp  how to create jsp page
Jsp
Jsp  Can I implement interface in jsp
JSP
what is JSP forward tag for  what is JSP forward tag for   It forwards the current request to another JSP page. Below is the syntax for the same:- <jsp:forward page="...url..." /> We can also forward parameter
jsp
jsp  how to include two jsp page
jsp
jsp  how to create a table in oracle using jsp and the table name is entered in text feild of jsp page
jsp
jsp  write a code for jsp file generator to generate a jsp page automatically taking html page as input
JSP
JSP  Hi, What is JSP? What is the use of JSP? Thanks   Hi, JSP Stands for Java Server Pages. It is Java technology for developing web applications. JSP is very easy to learn and it allows the developers to use Java
jsp
jsp   what is the basic necessities reguired for running jsp using JDBC bridge?? and how to write a jsp code to access the detail present in microsoft access pls send link regarding above
jsp
jsp  how to pass jsp variable to an html page
JSP
JSP  relevant difference between servlet and jsp in 1 line
jsp
jsp  how to include google map in our jsp page
JSP
JSP   How to create CAPTCHA creation by using JSP? I need an code for CAPTCHA creation by using JSP...   You can create a captcha validation using jsp. Have a look at the following tutorial: Captcha Creation
jsp
jsp  how to write a servlet and jsp program for user login form
jsp
jsp  how to write a servlet and jsp program for user login form
jsp
jsp  why jsp is translated into servlet?pls describe precisly

Ads