【问题标题】:jfreechart, chart creation errorjfreechart,图表创建错误
【发布时间】:2012-10-31 13:33:36
【问题描述】:

这对你们来说可能是一个愚蠢的问题,但我遇到了以下错误。我认为createLineChart 的所有参数都是正确的。我不知道为什么它说我错了......你能告诉我为什么我会收到这个错误吗?

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);
            }
         }

我通过导入一堆库以某种方式解决了这个问题:/ 感谢您的帮助!

【问题讨论】:

  • 也许你应该试着把你的代码放在一个java类中,只是为了调试。这将更容易追踪错误。
  • 我们能看到声明、初始化和填充CategoryDataset的代码吗?另外,尝试删除PlotOrientation.HORIZONTAL 看看是否有帮助。

标签: java jsp jfreechart


【解决方案1】:

关于错误,您尝试使用 PlotOrientation 参数调用 createLineChart 方法。该方法没有这个参数。

也许这不是您要调用的方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-15
    • 2017-09-11
    • 1970-01-01
    • 2011-07-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多