Multi line graph

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 in advance
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?









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
Line Graph using JFreeChart
Line Graph using JFreeChart  I need to draw a line graph of the (no. of sales made on y axis) by a shop with (dates on x axis) using data from MySQL database and JFreeChart
Line Graph using JFreeChart
Line Graph using JFreeChart  I need to draw a line graph of the (no. of sales made on y axis) by a shop with (dates on x axis) using data from MySQL database and JFreeChart. DRIVER: com.mysql.jdbc.Driver URL: jdbc:mysql
Line Graph using JFreeChart
Line Graph using JFreeChart  I need to draw a line graph of the (no. of sales made on y axis) by a shop with (dates on x axis) using data from MySQL database and JFreeChart. DRIVER: com.mysql.jdbc.Driver URL: jdbc:mysql
PHP GD line graph
($im,3,10,$height-20,'Line Graph by: Roseindia Technologies',$red);ADS_TO_REPLACE_12
How to make a line graph in Matplotlib?
Matplotlib Examples - How to make a line graph in Matplotlib? In this tutorial we are going to create simple line graph in Matplotlib library. You can run... simple example is to generate a line graph in Matplotlib and in this example
How to make a line graph in Matplotlib?
Matplotlib Examples - How to make a line graph in Matplotlib? In this tutorial we are going to create simple line graph in Matplotlib library. You can run... simple example is to generate a line graph in Matplotlib and in this example
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
ModuleNotFoundError: No module named 'odoo11-addon-stock-move-line-multi-company-security'
ModuleNotFoundError: No module named 'odoo11-addon-stock-move-line-multi...: ModuleNotFoundError: No module named 'odoo11-addon-stock-move-line-multi...;odoo11-addon-stock-move-line-multi-company-security' error? Thanks  
ModuleNotFoundError: No module named 'odoo12-addon-stock-move-line-multi-company-security'
ModuleNotFoundError: No module named 'odoo12-addon-stock-move-line-multi...: ModuleNotFoundError: No module named 'odoo12-addon-stock-move-line-multi...;odoo12-addon-stock-move-line-multi-company-security' error? Thanks  
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
ModuleNotFoundError: No module named 'odoo8-addon-sale-sourced-by-line-sale-transport-multi-address'
-by-line-sale-transport-multi-address' How to remove the ModuleNotFoundError: No module named 'odoo8-addon-sale-sourced-by-line-sale-transport-multi-address... odoo8-addon-sale-sourced-by-line-sale-transport-multi-address After
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
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
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
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
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
Graph
ModuleNotFoundError: No module named 'graph'
ModuleNotFoundError: No module named 'graph'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'graph' How to remove the ModuleNotFoundError: No module named 'graph'
ModuleNotFoundError: No module named 'graph'
ModuleNotFoundError: No module named 'graph'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'graph' How to remove the ModuleNotFoundError: No module named 'graph'
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
Version of com.daedafusion>graph dependency
List of Version of com.daedafusion>graph dependency
what is multi-threading .?
what is multi-threading .?   what is multi-threading.what is the use in real time, with example programs
What is Graph Database
What is Graph Database  Hi, What is Graph Database? Thanks   Graph Database? Graph Database is special kind of database which is used to store graph data formats. It provides API for saving the graph data into Graph
What is Graph Database
What is Graph Database  Hi, What is Graph Database? Thanks   Graph Database? Graph Database is special kind of database which is used to store graph data formats. It provides API for saving the graph data into Graph
ModuleNotFoundError: No module named 'multi'
ModuleNotFoundError: No module named 'multi'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'multi' How to remove the ModuleNotFoundError: No module named 'multi'
Artifacts of commons-graph
List of Artifacts of commons-graph maven depenency
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
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
janusgraph clear graph
developed it is filled with all junk data. I want do clear my graph by deleting... with following query: JanusGraphFactory.drop(graph) This will delete all data and schema of graph database. Thanks
Changing 2D graph using slider.
Changing 2D graph using slider.  Code for changing a 2d graph with help of slider
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
datewise/monthwise bar graph
datewise/monthwise bar graph  How to make a datewise/monthwise bar graph using the values from the ms access database? please help its urgent
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
Create Bar graph
Create Bar graph  hi............. In my project i want to create a BAR GRAPH to display the result. I HAVE certain values that want to show in graph form. Can u help me plzzzzzzz i require a very simple code in java swings were
Maven Dependency commons-graph >> 0.8
You should include the dependency code given in this page to add Maven Dependency of commons-graph >> commons-graph version0.8 in your project
Maven Dependency commons-graph >> 0.8.1
You should include the dependency code given in this page to add Maven Dependency of commons-graph >> commons-graph version0.8.1 in your project
plotting a graph - Java Beginners
plotting a graph  pls help me out regarding plotting a graph. I have done that through LiveGraph API. but now i required the graph to be displayed on the gui- window. and whatever inputs i will pass it must change the graph
Version of com.ncona>conversion-graph dependency
List of Version of com.ncona>conversion-graph dependency
Version of com.qwazr>qwazr-graph dependency
List of Version of com.qwazr>qwazr-graph dependency
Version of com.seancheatham>graph-core_2.11 dependency
List of Version of com.seancheatham>graph-core_2.11 dependency

Ads