2012-10-31 64 views
2

這可能是一個愚蠢的問題給你們,但我有以下錯誤。我認爲createLineChart的所有參數都是正確的。我不知道爲什麼它說我錯了...你能告訴我爲什麼我得到這個錯誤嗎?jfreechart,圖表創建錯誤

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 102 in the jsp file: /graph.jsp 
The method createLineChart(String, String, String, CategoryDataset, boolean, boolean, boolean) in the type ChartFactory is not applicable for the arguments (String, String, String, DefaultCategoryDataset, PlotOrientation, boolean, boolean, boolean) 
99:   } 
100:   
101:   
102:   JFreeChart chart = ChartFactory.createLineChart("Houlry", "Usage", "time", hourlydata , PlotOrientation.HORIZONTAL, true, true, false); 
103:   

編輯感謝您的迴應!

但如果我刪除PlotOrientation,我得到

method createLineChart n class org.jfree.jfreechartChartFactory cannot be applied to given types; 
required java.lang.String,java.langString,java.langString,org.jfree.data.category.CategoryDataset,org.jfree.chart.plot.PlotOrientatio,boolean,boolean boolean 

初始化:

DefaultCategoryDataset hourlydata = new DefaultCategoryDataset(); 
for (int k = 1; k <= i; k++) { 
     if (k == 1){ 
      label = "CPU Average"; 
     } 
     if (k == 2){ 
      label = "CPU Max"; 
     } 
     if (k == 3){ 
      label = "RAM Average"; 
     } 
     if (k == 4){ 
      label = "RAM Max"; 
     } 

     for (int j = 1; j < 7; j++) { 
      if (j == 1){ 
       time = "10"; 
      } 
      if (j == 2){ 
       time = "20"; 
      } 
      if (j == 3){ 
       time = "30"; 
      } 
      if (j == 4){ 
       time = "40"; 
      } 
      if (j == 5){ 
       time = "50"; 
      } 
      if (j == 6){ 
       time = "60"; 
      } 
      hourlydata.addValue(arr[k][j], label, time); 
      } 
     } 

不知何故,我想通了,通過導入一堆庫的這個問題:你的幫助/謝謝!

+1

也許你應該嘗試把你的代碼放在java類中,只是爲了調試。這將更容易追蹤錯誤。 –

+1

我們可以看到聲明,初始化和填充'CategoryDataset'的代碼嗎?此外,嘗試刪除'PlotOrientation.HORIZONTAL',看看是否有幫助。 – brimborium

回答

1

關於錯誤,您試圖使用PlotOrientation參數調用createLineChart方法。該方法沒有這個參數。

也許這不是你想要調用的方法。