Multi line graph

Ads

 
 

Share on Google+Share on Google+

Dedeepya
Multi line graph
3 Answer(s)      7 years ago
Posted in : Java Beginners
Hi,

I want a multi line graph on a single chart using jfree in java....
Can you please let me know the code...

thanks in advance
Ads
View Answers

March 10, 2010 at 10:34 AM


Hi Friend,
Loginto the below mentioned URl & download the file available on that site. And then keep that file into your webapps folder and then run it. There are lot of sample charts are available on that. Hope that may help you...
http://sourceforge.net/projects/cewolf/files/cewolf/cewolf-1.0/cewolf-1.0-bin-src.zip/download

Regards...,Britto.M
Cell:9611822112


March 10, 2010 at 11:46 AM


Hi Friend,

Try the following code:

import java.awt.*;
import org.jfree.ui.*;
import org.jfree.chart.*;
import org.jfree.chart.plot.*;
import org.jfree.data.xy.*;
import org.jfree.chart.axis.NumberAxis;

public class MultiLineChart extends ApplicationFrame {
public MultiLineChart(final String title) {
super(title);
final XYDataset dataset = createDataset();
final JFreeChart chart = createChart(dataset);
final ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
setContentPane(chartPanel);
}
private XYDataset createDataset() {
final XYSeries series1 = new XYSeries("I test");
series1.add(1.0, 60.0);
series1.add(2.0, 80.0);
series1.add(3.0, 90.0);
series1.add(4.0, 100.0);
series1.add(5.0, 95.0);
series1.add(6.0, 85.0);
series1.add(7.0, 70.0);
series1.add(8.0, 65.0);
series1.add(9.0, 45.0);
series1.add(10.0, 50.0);

final XYSeries series2 = new XYSeries("II test");
series2.add(1.0, 30.0);
series2.add(2.0, 55.0);
series2.add(3.0, 70.0);
series2.add(4.0, 85.0);
series2.add(5.0, 90.0);
series2.add(6.0, 100.0);
series2.add(7.0, 70.0);
series2.add(8.0, 80.0);
series2.add(9.0, 50.0);
series2.add(10.0, 40.0);

final XYSeries series3 = new XYSeries("III test");
series3.add(1.0, 40.0);
series3.add(2.0, 40.0);
series3.add(3.0, 40.0);
series3.add(4.0, 35.0);
series3.add(5.0, 80.0);
series3.add(6.0, 90.0);
series3.add(7.0, 95.0);
series3.add(8.0, 75.0);
series3.add(9.0, 40.0);
series3.add(10.0, 60.0);

final XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series1);
dataset.addSeries(series2);
dataset.addSeries(series3);

return dataset;
}
private JFreeChart createChart(final XYDataset dataset) {
final JFreeChart chart = ChartFactory.createXYLineChart(
"Marks obtained by students in three tests",
"Roll No of the students",
"Marks",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false
);
chart.setBackgroundPaint(Color.white);
final XYPlot plot1 = chart.getXYPlot();
plot1.setBackgroundPaint(Color.lightGray);
plot1.setDomainGridlinePaint(Color.white);
plot1.setRangeGridlinePaint(Color.white);

final XYPlot plot2 = chart.getXYPlot();
plot2.setBackgroundPaint(Color.lightGray);
plot2.setDomainGridlinePaint(Color.white);
plot2.setRangeGridlinePaint(Color.white);

final XYPlot plot3 = chart.getXYPlot();
plot3.setBackgroundPaint(Color.lightGray);
plot3.setDomainGridlinePaint(Color.white);
plot3.setRangeGridlinePaint(Color.white);

return chart;
}
public static void main(final String[] args) {
final MultiLineChart demo = new MultiLineChart("Multi Line Chart");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}

Thanks


April 8, 2015 at 2:37 AM


How can we plot the xy chart for the data present in the database that is i should get three lines in the same graph. How can i do it?


Ads









Related Tutorials/Questions & Answers:
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
line graph
line graph  I have developed an application and in that i have to compare 2 reports using line graph from the data taken from ms access database?please help
Advertisements
PHP GD line graph
,'Line Graph by: Roseindia Technologies',$red); imagepng($im); ?> After
JFreechart multi line chart help in JSP
JFreechart multi line chart help in JSP  Hi, I am am looking for and help in getting multi line chart with Jfree chart, i had manage to write a singe line chart but i need multy line can you please help. <%@page
Setting Multi-Line label on the Button
Setting Multi-Line label on the Button       This section shows you how to set the multi line label on the button in Java Swing Applications. This program uses html class
Create Line Graph using database values
Create Line Graph using database values JFreeChart library has made... retrieved from the database. In this section, you will learn how to create a x-y line graph by retrieving the values from the database. Here is the code: import
to show graph
to show graph  by clicking on submit button how to show the graph by fetching data in mysql?   Please visit the following link: JSP graph by fetching data in mysql
multi language
multi language  Hello friends please help me Hi how can i do a java program using swing that changes the language like malayalam/tamil etc with languages on a drop down menu I am using netbeans IDE
multi thread
multi thread   Multiple Clients Connect to a server and communicate among the themselves. When a new Client is connected to the server, all other clients get the notification and they can chat with each other. Similarly when
Version of commons-graph>commons-graph dependency
List of Version of commons-graph>commons-graph dependency
Applet Graph
columns-names by using check box and click on graph button, 3..then i have to get a graph between those columns in a applet plz send me the code thank u
multi dimension
multi dimension  class TwoDAgain{ public static void main(String args[]){ int twoD[][]=new int[4][]; twoD[0]= new int[1]; twoD[1]= new int[2]; twoD[2]= new int[3]; twoD[3]= new int[4]; int i, j, k = 0; for (i=0; i<4; i
Multi window
Multi window  I am making a bank app using struts 1.2. using only the struts tags and nno jsp tags and scriplets. db connected thru dao. 1st page contains all the details. when i submit this page, a new window opens and asks
Multi Threading
Multi Threading  Hi... I need to solve the following question: Input an array of 10 integers. Separate the odd numbers, even numbers, positive numbers and negative numbers by different threads. I tried to solve it but I dont
Java multi-threading
Java multi-threading  What is multi-threading
Autoupdating graph
Autoupdating graph  Hey Anyone who might help me making a XY graph, that autoupdates lets say every 5th minute. All the datasets comes from an mySQL database, and the dataset in the database, comes from a txt file and are being
what is multi-threading .?
what is multi-threading .?   what is multi-threading.what is the use in real time, with example programs
Graph in JAVA SWING
Graph in JAVA SWING  Hi, How to draw a simple GRAPH in JAVA SWING ?  ..., Please visit the following link: Bar Graph in Java Swing Thanks
hybrid graph (jfree chart) - Swing AWT
hybrid graph (jfree chart)  hello i have a problem related to jfree chart.I want to display hybrid graph (Stacked Area and Line ).combination of stacked area chart and Line chart in one frame. Plese anybody help me out
Version of com.daedafusion>graph dependency
List of Version of com.daedafusion>graph dependency
Java multi-threading
Java multi-threading  What method is invoked to cause an object to begin executing as a separate thread
Java multi-threading
Java multi-threading  How does multithreading take place on a computer with a single CPU
Multi-value data - JDBC
Multi-value data  hey! actually am supposed to create this database that allows multi-value data.its supposedly going to become a very large database.only i dont know just how to begin creating it.what i need is mysql syntax
Multi value data - JDBC
Multi value data  Hello, please help,how do i use Multi-value data with mysql database. thank you  Hi friend, Plz explain your problem in details what you want and visit to : http://www.roseindia.net/jdbc/jdbc
about graph - Applet
about graph  How to draw a graph in applet and that should be display in web browser? How to make a running applet in our browser? for example ticker
Artifacts of commons-graph
List of Artifacts of commons-graph maven depenency
plot a graph in Java
plot a graph in Java   I need to plot a graph in Java but the samples are not known in advance. The samples keep on coming through callback and I... and the final graph may be quite congested. So please guide me on this. Thanks
nio read file line by line
nio read file line by line  Is there any way to read file line by line using the Java nio package? How to use the nio classes to read file line by line? Thanks   Hi, The easiest way to read file line by line is to use
Multi PortType in NuSOAP - WebSevices
Multi PortType in NuSOAP  I would like to create a SOAP Server with atleast 2 PortType UserPortType and AccountPortType my problem is I cant combine both 2 PortType in the same Server page
sendimg multi sms
sendimg multi sms  i want to send multiple sms from a distribution list decleared in the server...how do i connect my code to server