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

Ads









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
Create a Pie Chart in jsp Page using JFree Chart
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
Create a dual axis chart using JFreeChart
How to Create Text Area In Java
Create a bar chart in JSP page using JFreeChart
Create a 3D bar chart in JSP page using JFreeChart
how to create using jsp
Stacked Bar Chart using JFreeChart
how to create a bar chart in jsp by fetching value from oracle databse?
Stacked Bar Chart Example using JFreeChart
Stacked 3d Bar Chart Example using JFreeChart
How to Create Instance using PHP
Box And Whisker Chart Example using JFreeChart
Category Step Chart Example using JFreeChart
Candle Stick Chart Example using JFreeChart
Create pie chart
how to fetch data from mysql database table and draw a bar chart on that data using in jsp
Horizontal Bar Chart Example using JFreeChart
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

Ads