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
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 BeginnersMulti 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 graphline 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 JFreeChartLine 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 JFreeChartLine 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 JFreeChartLine 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 JSPJFreechart
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 valuesCreate
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 graphto 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
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
Autoupdating graphAutoupdating 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 languagemulti 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 threadmulti 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 dimensionmulti 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 windowMulti 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 ThreadingMulti 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
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 SWINGGraph in JAVA SWING Hi,
How to draw a simple
GRAPH in JAVA SWING ?
...,
Please visit the following link:
Bar
Graph in Java Swing
Thanks
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'
What is Graph DatabaseWhat 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 DatabaseWhat 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 Java multi-threadingJava
multi-threading What method is invoked to cause an object to begin executing as a separate thread
Java multi-threadingJava
multi-threading How does multithreading take place on a computer with a single CPU
about graph - Appletabout 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
Multi-value data - JDBCMulti-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 - JDBCMulti 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
datewise/monthwise bar graphdatewise/monthwise bar graph How to make a datewise/monthwise bar
graph using the values from the ms access database? please help its urgent
Create Bar graphCreate 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
sendimg multi smssendimg
multi sms i want to send multiple sms from a distribution list decleared in the server...how do i connect my code to server
Multi PortType in NuSOAP - WebSevicesMulti 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