Link to home
Start Free TrialLog in
Avatar of northborneo
northborneo

asked on

How to show a XY Chart using JFreeChart ??

Hi guys,

   I got the following code :

import java.awt.*;
import java.awt.event.*;
import java.io.PrintStream;
import java.util.ResourceBundle;
import java.util.Vector;
import javax.swing.*;

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

public class JChartXY implements ActionListener, WindowListener
{

    public static void main(String[] args) {
      
      XYSeries series = new XYSeries("Average Size");
      series.add(20.0, 10.0);
      series.add(40.0, 20.0);
      series.add(70.0, 50.0);
      XYDataset xyDataset = new XYSeriesCollection(series);
      
      JFreeChart chart = ChartFactory.createXYAreaChart
                           ("Sample XY Chart",  // Title
                            "Height",           // X-Axis label
                            "Weight",           // Y-Axis label
                            xyDataset,          // Dataset
                            PlotOrientation.HORIZONTAL,
                            true,                // Show legend
                            false,
                            false
                           );
                     }
}

it compiled successfully but nothing show up ! So how to make the XY Chart appear ? Thanks !
Avatar of northborneo
northborneo

ASKER

guys .... pls help. ...pls ..pls
ASKER CERTIFIED SOLUTION
Avatar of jimmack
jimmack

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial