tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Charts > JFreeChart > XY Area Chart

XY Area Chart 

JFreeChart is a free and pure java chart library for creating professional quality charts. This requires the libraries jfreechart-1.0.13.jar and jcommon-1.0.8.jar to be in classpath. The following example shows creating a simple XY area chart.

File Name  :  
com/bethecoder/tutorials/jfree_charts/tests/XYAreaChart.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.jfree_charts.tests;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

public class XYAreaChart {

  public static void main(String arg[]) {

    // Prepare the data set
    XYSeries xySeries = new XYSeries("Number & Square Chart");
    xySeries.add(11);
    xySeries.add(24);
    xySeries.add(39);
    xySeries.add(416);
    xySeries.add(525);
    xySeries.add(636);
    XYDataset xyDataset = new XYSeriesCollection(xySeries);
    
    //Create the chart
    JFreeChart chart = ChartFactory.createXYAreaChart(
        "Number & Square Chart""Number""Square", xyDataset,
        PlotOrientation.VERTICAL, true, true, false);

    //Render the frame
    ChartFrame chartFrame = new ChartFrame("XYArea Chart", chart);
    chartFrame.setVisible(true);
    chartFrame.setSize(300300);

  }
}
   

It gives the following output,
xyarea.jpg


 
  


  
bl  br