graphs/charts

graphs/charts

View Answers

November 18, 2009 at 3:19 PM

Hi Friend,

Try the following 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.ADS_TO_REPLACE_1 All forms of Graphs and Charts
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, 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
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
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 R programming language?
Visualization: It provides various graphs and charts for proper visualization
Why should we learn R programming?
for analyzing data and then presenting in nice pictorial graphs, charts and other
Why should we learn R programming?
for analyzing data and then presenting in nice pictorial graphs, charts and other
Why should we learn R programming?
for analyzing data and then presenting in nice pictorial graphs, charts and other
What is Web Graphics
depiction next to them. It is better to use logos, cartoons, graphs and charts where they make a reasonable sense.ADS_TO_REPLACE_1

Ads