How to create an area chart using jfreecharts?

Ads
 

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
display combination of a stacked area chart and line chart in one iframe using jfree - JSP-Servlet
how to create 3d chart in dojox charting - XML
Create Chart using Action script in Flex4
Create a Pie Chart in jsp Page using JFree Chart
Create a pie chart in jsp page using JFreeChart
Create a dual axis chart using JFreeChart
How to Create Text Area In Java
create bar chart in jsp using msaccess database
create bar chart in jsp using msaccess database
Create a bar chart in JSP page using JFreeChart
how to create a bar chart in jsp by fetching value from oracle databse?
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 using jsp
Auto grow Text Area using jQuery plug-in
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 chart - JSP-Servlet
how to fetch data from mysql database table and draw a bar chart on that data using in jsp

Ads