Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Jfreechart with jsp and servlet giving error

Jfreechart with jsp and servlet giving error

Scheduled Pinned Locked Moved Java
javahtmlcollaborationhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cmaheshwari16
    wrote on last edited by
    #1

    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

    G 1 Reply Last reply
    0
    • C cmaheshwari16

      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

      G Offline
      G Offline
      Gerben Jongerius
      wrote on last edited by
      #2

      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.

      C 1 Reply Last reply
      0
      • G Gerben Jongerius

        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.

        C Offline
        C Offline
        cmaheshwari16
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups