How to create an area chart using jfreecharts?

How to create an area chart using jfreecharts?

i want to create an area chart that represents ip addresses of top countries. i have gone thru the area chart example using jfreechart but i am still not clear with its method. If u please explain in detail what the reaminning statements means after populating dataset?

Thank you in advance.

View Answers

March 29, 2011 at 10:21 AM

import java.awt.*;
import java.io.*;
import org.jfree.chart.*;
import org.jfree.data.category.*;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.*;
import org.jfree.chart.renderer.category.*;
import org.jfree.chart.plot.*;

public class Area{
public static void main(String arg[]){
  DefaultCategoryDataset dataset = new DefaultCategoryDataset();
  dataset.addValue(4.0, "Science", "Rahul");
  dataset.addValue(3.0, "Maths", "Rahul");
  dataset.addValue(5.0, "Science", "Vinod");
  dataset.addValue(2.0,"Maths", "Vinod");
  dataset.addValue(3.0, "Science", "Prashant");
  dataset.addValue(5.0, "Maths", "Prashant");
  dataset.addValue(6.0, "Science", "Tapan");
  dataset.addValue(2.0, "Maths", "Tapan");
  dataset.addValue(3.0,"Science", "Santosh");
  dataset.addValue(5.0, "Maths", "Santosh");

    JFreeChart chart = ChartFactory.createAreaChart
   ("Comparison between Students Marks","Students", "Marks ",
    dataset, PlotOrientation.VERTICAL, true,true, false);
  chart.setBackgroundPaint(Color.yellow);
  chart.getTitle().setPaint(Color.blue); 
  CategoryPlot p = chart.getCategoryPlot(); 
  p.setForegroundAlpha(0.7f);
  p.setRangeGridlinePaint(Color.red); 
  p.setDomainGridlinesVisible(true);
  p.setDomainGridlinePaint(Color.black);
  CategoryItemRenderer renderer = p.getRenderer();
  renderer.setSeriesPaint(1, Color.red);
  renderer.setSeriesPaint(0, Color.green);
  ChartFrame frame1=new ChartFrame("Area Chart",chart);
  frame1.setVisible(true);
  frame1.setSize(300,300);
  }
}

Java Area Chart









Related Tutorials/Questions & Answers:
How to create an area chart using jfreecharts?
Create area chart in JSP page using JFreeChart
Advertisements
How to create bar chart using database values
how to create bar chart in jsp using msaccess database
Area Chart
Create a polar chart using JFreeChart
display combination of a stacked area chart and line chart in one iframe using jfree - JSP-Servlet
Create a Pie Chart in jsp Page using JFree Chart
Create Chart using Action script in Flex4
create bar chart in jsp using msaccess database
Create a pie chart in jsp page using JFreeChart
create bar chart in jsp using msaccess database
how to create 3d chart in dojox charting - XML
Create a dual axis chart using JFreeChart
Create a bar chart in JSP page using JFreeChart
How to Create Text Area In Java
Create a 3D bar chart in JSP page using JFreeChart
Create Pie Chart using database values
Stacked Bar Chart using JFreeChart
Stacked Bar Chart Example using JFreeChart
hybrid chart(Stacked Area and Line ) - Swing AWT
how to create a bar chart in jsp by fetching value from oracle databse?
how to create using jsp
create chart - JSP-Servlet
Stacked 3d Bar Chart Example using JFreeChart
Auto grow Text Area using jQuery plug-in
Box And Whisker Chart Example using JFreeChart
Category Step Chart Example using JFreeChart
Candle Stick Chart Example using JFreeChart
Create pie chart
How to Create Instance using PHP
Horizontal Bar Chart Example using JFreeChart
Create Bar Chart with database values
how to fetch data from mysql database table and draw a bar chart on that data using in jsp
Create multiple pie chart in single frame using JFreeChart
Pie chart Jfree create error
how to create exce sheet using java
how to create an excel file using java
How to create primary key using hibernate?
how to create users in LDAP using java?
how to create a header in jtable using java swing
how to create a text box using awt
how to create pdf file using java and itextjar
how to create pdf file using java and itextjar
how to create a zip by using byte array
how to create this structure in json using grails
how to create database and table using jsp
How to Create Quiz Application using iPhone
How to create web application using maven in Eclipse?
how to create a progarame using jboss drools rules

Ads