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



Home Answers Viewqa Java-Beginners Line Graphs in java
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Valli
Line Graphs in java
1 Answer(s)      4 years and 4 months ago
Posted in : Java Beginners


Hi...

I need to generate a graph by using the database values using java
I know about the JFreeChart class...
But by using that...I'm unable to display the values in the chart.
I'm just getting the points...
I need to get the values also at the specific point in the chart..
and it should be only xyline graph and the values should be in the chart itself...
Is there any way to solve this..??
can anyone help...


Thanks in advance

Advertisement
View Answers

May 28, 2010 at 11:49 AM


Hi Friend,

Try the following code:

import java.sql.*;
import java.io.*;
import org.jfree.ui.*;
import org.jfree.chart.ChartPanel;
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.createLineChart("Test", "Id", "Score",
dataset, PlotOrientation.VERTICAL, true, true, false);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
ApplicationFrame f=new ApplicationFrame("Chart");
f.setContentPane(chartPanel);
f.pack();
f.setVisible(true);
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:
Line Graphs in java - Java Beginners
Line Graphs in java  Hi... I need to generate a graph by using the database values using java I know about the JFreeChart class... But by using that...I'm unable to display the values in the chart. I'm just getting
Graphs in java - Java Beginners
Graphs in java  Hi... I need to generate a graph by using the database values using java I know about the JFreeChart class... But by using...;The Above code is good... But i need a line graph with the data values
Advertisements
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
Multiline graphs in java - Java Beginners
Multiline graphs in java  How to draw a multiline graph in java, One will b constant straight line and the other is changing  Hi Friend... String[] args) { final MultiLineChart demo = new MultiLineChart("Multi Line
Chart & Graphs Tutorials in Java
Chart & Graphs Tutorials in Java  ... in Java. Our Chart and Graphs tutorials will help learn everything you need to learn about chart and graphs programming in Java. We have provided many examples
Graphs using JFreeChart - Java Beginners
Graphs using JFreeChart  Hi Friend, I need to draw a graph of the powerconsumed by a consumer in specific dates with a const line showing the max power can be consumed. Now My data is like this 15-12-2009 150 16-12-2009
thanks deepak for guiding me to draw graphs using org.jfree - Java Beginners
thanks deepak for guiding me to draw graphs using org.jfree  Hi deepak, thanks deepak....... i got the graphs using org.jfree.......... as u said, i set the class path............ thanks mate
Java - How to read a string line per line
Java - How to read a string line per line  Java - How to read... to read the big String line per line? Is there any API available in Java...(System.getProperty("line.separator")); Read more at: Java Read File Line
Java Command Line Input
Java Command Line Input  How to get input from command line in java ?   Hi please Find the code for inputting data from the command line System.out.println("Please Input A Number"); BufferedReader br
java line chart
java line chart  Hi, I want to draw a graphic in java line chart and ? searched the documents ?n the web. I found the example codes ?n your site (http://www.roseindia.net/chartgraphs/xyline-chart.shtml) and tr?ed ?n my
How to read big file line by line in java?
Learn how to write a program in java for reading big text file line by line... is very useful in reading big file line by line in Java. In this tutorial we.... It returns string line. Following is complete example of java program that reads big
Java Read File Line by Line - Java Tutorial
Java Read File Line by Line - Example code of reading the text file in Java one line at a time     ... to write java program to read file line by line. We will use the DataInputStream
How to write file by line in Java
How to write file by line in Java  How to write file by line in Java   Hi, For Write to a file by line using java programming language we... in a new line. How to use Write To File By Line in Java programs
graphs in jsp - Java3D
graphs in jsp  i want to present my data from database in graphs how can i present in jsp and servlet.please guide me.thanz in advance
How to read a large text file line by line in java?
How to read a large text file line by line in java?  I have been... you kind advice and let's know how to read a large text file line by line in java... of the application and the memory available for the Java program. For Java program max
What is command line argument in Java
example of command line argument program in Java?? It will be really helpful... visit the following link: http://www.roseindia.net/java/beginners/cmnd-line...://www.roseindia.net/java/beginners/cmnd-line-arguments.shtml
How to Read file line by line in Java program
by line in Java. But there are various ways that can help read a larger file... having less amount of memory. In the example of Java Read line by line below...()?. The output of read file line by line in Java is printed on console
line length in java - Java Beginners
line length in java  Write a program that asks the user to enter two words. The program then prints out both words on one line. The words will be separated by enough dots so that the total line length is 30  Hi friend
Java read file line by line - Java Tutorial
C:\nisha>javac ReadFile.java C:\nisha>java... input line by line with an appropriate BufferedReader...;By Line   while ((strLine = br.readLine()) 
Types of Graphs and Charts
applications charts and graphs are extensively used for visualizing the data. In Java... for showing business reports. These are listed as follows. Line graphs... Types of Graphs and Charts   
Java Read File Line By Line, Video Tutorial of Java Read File Line By Line
a program in Java programming language to read a text file line by line. The "Java Read File Line by line" is most searched topics by the Java developers. This means Java developers are using the Java for reading the file line
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
Multi line graph - Java Beginners
Multi line graph  Hi, I want a multi line graph on a single chart using jfree in java.... Can you please let me know the code... thanks... MultiLineChart("Multi Line Chart"); demo.pack
Java read file line by line
Java read file line by line In this section, you will learn how to read a file line by line. Java has provide several classes for file manipulation. Here we are going to read a file line by line. For reading text from a file it's better
command line arguments - Java Beginners
command line arguments  how can i findout the minimum and maximum no's at the command prompt if i give some values?????????  hi friend, We are providing you a code that will prompt the user to input some numbers
Draw a line in a JPanel with button click in Java
Draw a line in a JPanel with button click in Java  Draw a line in a JPanel with button click in Java
Drawing Graphs - Java3D
Drawing Graphs  how to draw graphs using certain parameters  Hi Friend, To draw a graph using JfreeChart library, please visit the following link: http://www.roseindia.net/chartgraphs/index.shtml Here you
Java write to file line by line
Java write to file line by line In this section, you will learn how to write a file line by line. It is better to use Writer class instead of OutputStream... to a byte array. The method newLine() is used for writing a new line character. We
Java Generic program with command line argument
Java Generic program with command line argument  Implement Generic to perform arithmetic evaluation using command line argument by using Java
Command line argument in java
Command line argument in java. In this section we are going to discuss about command line argument in java. Command line argument allow a user to pass arguments at the time of running the application , after the class name. Java allow
Command Line Arguments in Java
Command Line Arguments in Java The ongoing Java application can accept any...-line argument is an argument, which passed at the time of running of the Java... command line arguments in java program. */ class CmndLineArguments { public
 

 

 

DMCA.com