Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


geetha
graphs/charts
1 Answer(s)      4 years and 11 months ago
Posted in : JSP-Servlet



Advertisement
View Answers

November 18, 2009 at 4:47 PM


Hi Friend,

We have used jfreechart library to create a bar graph. And the chart displays the database values.If you want to download the jar files,please visit the following link:

http://www.roseindia.net/chartgraphs/jfreechart-introduction.shtml

Here is the code:

import java.sql.* ;
import java.io.* ;
import org.jfree.chart.ChartFactory ;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart ;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.* ;
import org.jfree.data.jdbc.JDBCCategoryDataset;

public class Chart{
public static void main(String[]args) throws Exception{


String query="SELECT * from chart";
JDBCCategoryDataset dataset=new JDBCCategoryDataset("jdbc:mysql://localhost:3306/test";;,
"com.mysql.jdbc.Driver","root","root");

dataset.executeQuery( query);
JFreeChart chart = ChartFactory .createBarChart3D(
"Test",
"Id",
"Score",
dataset,
PlotOrientation.VERTICAL,true, true, false);
try
{
ChartUtilities.saveChartAsJPEG(new File("C:/chart.jpg"), chart, 400, 300);
}
catch (IOException e)
{
System.out.println("Problem in creating chart.");
}
}
}

Thanks


Related Tutorials/Questions & Answers:
Introduction to Graphs and Charts
Introduction to Graphs and Charts       Why Charts and GraphsGraphs... difficult and tedious process. All forms of Graphs and Charts embodies some Visual
Types of Graphs and Charts
Types of Graphs and Charts   ... applications charts and graphs are extensively used for visualizing the data. In Java... the data and call the few methods to generate the charts or graphs of your
Advertisements
graphs/charts - JSP-Servlet
graphs/charts  hi frens, How to create a bar graph by reading values from mysql database. Please help me out...   Hi Friend, We have used jfreechart library to create a bar graph. And the chart displays
graphs/charts - JSP-Servlet
graphs/charts  hi, How to create a graph/chart in java by reading values from my sql database.   Hi Friend, Try the following code: import java.sql.* ; import java.io.* ; import org.jfree.chart.ChartFactory
Chart & Graphs Tutorials in Java
;     Best collection of Graphs and Charts Tutorials... to Charts & Graphs Graphs and Charts is the most efficient method...; Types of Charts There are many types of graphs and charts
What is Web Graphics
depiction next to them. It is better to use logos, cartoons, graphs and charts where they make a reasonable sense. Basics Tips
 

 

 

DMCA.com