Jfreechart with jsp and servlet giving error
-
Hi All, I am using JSP and servlet technology for making graphs. Below please find my jsps, Display.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.awt.*" %>
<%@ page import="java.io.*" %>
<%@ page import="org.jfree.chart.*" %>
<%@ page import="org.jfree.chart.axis.*" %>
<%@ page import="org.jfree.chart.entity.*" %>
<%@ page import="org.jfree.chart.labels.*" %>
<%@ page import="org.jfree.chart.plot.*" %>
<%@ page import="org.jfree.chart.renderer.CategoryItemRenderer" %>
<%@ page import="org.jfree.chart.urls.*" %>
<%@ page import="org.jfree.data.*" %>
<%@ page import="org.jfree.data.CategoryDataset" %><%
final double[][] data = new double[][]{{210, 300, 320, 265, 299},{200, 304, 201, 201, 340}};final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Team ", "", data);
final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", "", "Value", dataset, PlotOrientation.VERTICAL,true, true, false);
final CategoryPlot plot = chart.getCategoryPlot();
plot.setForegroundAlpha(0.5f);chart.setBackgroundPaint(new Color(249, 231, 236));
try {
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());//String sname = request.getRealPath("/");
//sname = sname.concat("web/areachart.png"); //out.println(sname); //file = new File(sname);
//final File file1 = new File(sname);
File file1 = new File("../webapps/jspGraphFunction/web/areachart.png");ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
} catch (Exception e) {
out.println(e);
}%>
JSP Page
Now its giving the below error for the bolded statement in the code: Quote: The method createAreaChart(String, String, String, CategoryDataset, PlotOrientation, boolean, boolean, boolean) in the type ChartFactory is not applicable for the arguments (String, String, String, CategoryDataset, PlotOrientation, boolean, boolean, boolean) On net only this way of using the jfreechart is given I ha
-
Hi All, I am using JSP and servlet technology for making graphs. Below please find my jsps, Display.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.awt.*" %>
<%@ page import="java.io.*" %>
<%@ page import="org.jfree.chart.*" %>
<%@ page import="org.jfree.chart.axis.*" %>
<%@ page import="org.jfree.chart.entity.*" %>
<%@ page import="org.jfree.chart.labels.*" %>
<%@ page import="org.jfree.chart.plot.*" %>
<%@ page import="org.jfree.chart.renderer.CategoryItemRenderer" %>
<%@ page import="org.jfree.chart.urls.*" %>
<%@ page import="org.jfree.data.*" %>
<%@ page import="org.jfree.data.CategoryDataset" %><%
final double[][] data = new double[][]{{210, 300, 320, 265, 299},{200, 304, 201, 201, 340}};final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Team ", "", data);
final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", "", "Value", dataset, PlotOrientation.VERTICAL,true, true, false);
final CategoryPlot plot = chart.getCategoryPlot();
plot.setForegroundAlpha(0.5f);chart.setBackgroundPaint(new Color(249, 231, 236));
try {
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());//String sname = request.getRealPath("/");
//sname = sname.concat("web/areachart.png"); //out.println(sname); //file = new File(sname);
//final File file1 = new File(sname);
File file1 = new File("../webapps/jspGraphFunction/web/areachart.png");ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
} catch (Exception e) {
out.println(e);
}%>
JSP Page
Now its giving the below error for the bolded statement in the code: Quote: The method createAreaChart(String, String, String, CategoryDataset, PlotOrientation, boolean, boolean, boolean) in the type ChartFactory is not applicable for the arguments (String, String, String, CategoryDataset, PlotOrientation, boolean, boolean, boolean) On net only this way of using the jfreechart is given I ha
You need to check if the FQN (full qualified name) of the classes that you are passing to the function are the same as those expected by the class. Make sure the CategoryDataset and the PlotOrientation are correct. Also your programming environment should already be warning you when calling this type of method incorrect.
-
You need to check if the FQN (full qualified name) of the classes that you are passing to the function are the same as those expected by the class. Make sure the CategoryDataset and the PlotOrientation are correct. Also your programming environment should already be warning you when calling this type of method incorrect.
All things are correct it is giving error in the below code of line final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", "", "Value", dataset, PlotOrientation.VERTICAL,true, true, false); telling that The method createAreaChart(String, String, String, CategoryDataset, PlotOrientation, boolean, boolean, boolean) in the type ChartFactory is not applicable for the arguments (String, String, String, CategoryDataset, PlotOrientation, boolean, boolean, boolean) everything is correct seems, dont bother about the names these are correct, also CategoryDataset and the PlotOrientation are correct I have given the warning and error in the underline lines above. |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Regards Chandan