public DataPanel(String title){
  setLayout(new BorderLayout());
  positionSer=new XYSeries("True Position");
  XYSeriesCollection dataset1=new XYSeriesCollection(positionSer);
  JFreeChart chart=ChartFactory.createTimeSeriesChart("Position","Time (seconds)","Angle (degrees)",dataset1,true,true,false);
  plot=(XYPlot)chart.getPlot();
  plot.setRenderer(1,new DefaultXYItemRenderer());
  plot.mapDatasetToRangeAxis(1,1);
  ValueAxis axis=plot.getDomainAxis();
  axis.setAutoRange(true);
  axis.setFixedAutoRange(20000.0);
  ChartUtilities.applyCurrentTheme(chart);
  ChartPanel chartPanel=new ChartPanel(chart);
  chartPanel.setPreferredSize(new java.awt.Dimension(500,270));
  exportXlsBtn.setActionCommand("EXPORT_XLS");
  exportCsvBtn.setActionCommand("EXPORT_CSV");
  exportXlsBtn.addActionListener(this);
  exportCsvBtn.addActionListener(this);
  JPanel exportPanel=new JPanel();
  exportPanel.add(exportXlsBtn);
  exportPanel.add(exportCsvBtn);
  JPanel mainPanel=new JPanel(new BorderLayout());
  mainPanel.add(chartPanel);
  mainPanel.add(exportPanel,BorderLayout.SOUTH);
  add(mainPanel);
}

public DataPanel ( String title ) { setLayout ( new BorderLayout ( ) ) ; positionSer = new XYSeries ( "True Position" ) ; XYSeriesCollection dataset1 = new XYSeriesCollection ( positionSer ) ; JFreeChart chart = ChartFactory . createTimeSeriesChart ( "Position" , "Time (seconds)" , "Angle (degrees)" , dataset1 , true , true , false ) ; plot = ( XYPlot ) chart . getPlot ( ) ; plot . setRenderer ( 1 , new DefaultXYItemRenderer ( ) ) ; plot . mapDatasetToRangeAxis ( 1 , 1 ) ; ValueAxis axis = plot . getDomainAxis ( ) ; axis . setAutoRange ( true ) ; axis . setFixedAutoRange ( 20000.0 ) ; ChartUtilities . applyCurrentTheme ( chart ) ; ChartPanel chartPanel = new ChartPanel ( chart ) ; chartPanel . setPreferredSize ( new java . awt . Dimension ( 500 , 270 ) ) ; exportXlsBtn . setActionCommand ( "EXPORT_XLS" ) ; exportCsvBtn . setActionCommand ( "EXPORT_CSV" ) ; exportXlsBtn . addActionListener ( this ) ; exportCsvBtn . addActionListener ( this ) ; JPanel exportPanel = new JPanel ( ) ; exportPanel . add ( exportXlsBtn ) ; exportPanel . add ( exportCsvBtn ) ; JPanel mainPanel = new JPanel ( new BorderLayout ( ) ) ; mainPanel . add ( chartPanel ) ; mainPanel . add ( exportPanel , BorderLayout . SOUTH ) ; add ( mainPanel ) ; }
creates a new self - contained demo panel .
