3
import java.io.*;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.chart.ChartFactory; 
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.JFreeChart; 
import org.jfree.chart.ChartUtilities; 
public class xyLine {  
      public static void main(String[] args){
         try {

                /* Step - 1: Define the data for the line chart  */
                DefaultCategoryDataset line_chart_dataset = new DefaultCategoryDataset();
                line_chart_dataset.addValue(15, "schools", "1970");
                line_chart_dataset.addValue(30, "schools", "1980");
                line_chart_dataset.addValue(60, "schools", "1990");
                line_chart_dataset.addValue(120, "schools", "2000");
                line_chart_dataset.addValue(240, "schools", "2010");                

                /* Step -2:Define the JFreeChart object to create line chart */
                JFreeChart lineChartObject=ChartFactory.createLineChart("Schools Vs Years","Year","Schools Count",line_chart_dataset,PlotOrientation.VERTICAL,true,true,false);                

                /* Step -3 : Write line chart to a file */               
                 int width=640; /* Width of the image */
                 int height=480; /* Height of the image */                
                 File lineChart=new File("line_Chart_example.png");              
                 ChartUtilities.saveChartAsPNG(lineChart,lineChartObject,width,height); 
         }
         catch (Exception i)
         {
             System.out.println(i);
         }
     }
 }

我正在创建一个带有点的折线图。导致问题的行如下... JFreeChart lineChartObject=ChartFactory.createLineChart("Schools Vs Years","Year","Schools Count",line_chart_dataset,PlotOrientation.VERTICAL,true,true,false);

错误是:无法解析类型 org.jfree.util.PublicCloneable。它是从所需的 .class 文件中间接引用的

我已经尝试添加 jar 文件(jfreechart-1.0.14.jar),但它仍然无法正常工作。任何有任何帮助的人将不胜感激。

4

1 回答 1

3

你也需要jcommon-1.0.14.jar。有关更多信息,请参阅下载 JFreeChart

于 2013-04-05T17:58:13.317 回答