Results 1 to 4 of 4

Thread: Graphs in JSP

  1. #1
    Join Date
    Feb 2009
    Posts
    43

    Graphs in JSP

    Hello ,

    I Want To make Graphs in Jsp I am looking for a solution as JpGraph in php. which allows me to generate images from the dynamic values. Could you help me to make graphs in JSP, Also Tell me Which Format Would be Better to use Jpg or Png

    Thank you in advance.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Graphs in JSP

    Hello

    In fact if I am not mistaken, JPGRAGH works as follows more or less: The page that wants to display graph will contain the Following HTML tags:

    Select All
    <img src="Link to Php Script" width="x" height="y" />
    And when you receive Command, it will execute the php script which reverse an image. To do the same thing in Java, it would suffice in my opinion that your jsp should check the sources of your images on servlet that will create images,

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Graphs in JSP

    I Think You Should Also checkout SwiftChart as This example shows you how to generate PNG images, using Sun's Java Advanced Imaging (JAI) API. We suggest to use PNG rather than JPG since JPG is ideal for photographic images while PNG is ideal for charts and text. all modern browsers do support PNG, but some older browser versions might not.

    Code:
    <html>
    <body>
    <%@ page session="false"%>
    <%@ page contentType="image/jpeg" import="com.sun.image.codec.jpeg.*,swiftchart.swiftchart_app.*" %>
    <%
    swiftchart.swiftchart_app mychart= new swiftchart.swiftchart_app(400,300);
    mychart.setParam("x_axis_font_orientation","HORIZONTAL");
    mychart.setParam("chart_type","bar");
    mychart.setParam("applet_bg","EEEEEE");
    mychart.setParam("chart_bg","FFFFFF");
    mychart.setParam("title_text","Bar chart");
    mychart.setParam("title_font_color","000000");
    mychart.setParam("title_font_size","18");
    mychart.setParam("x_axis_font_color","000000");
    mychart.setParam("x_axis_font_size","12");
    mychart.setParam("y_axis_font_color","000000");
    mychart.setParam("y_axis_font_size","12");
    mychart.setParam("legend_position","RIGHT");
    mychart.setParam("legend_font_color","000000");
    mychart.setParam("legend_font_size","12");
    mychart.setParam("data_value","NONE");
    mychart.setParam("data_value_font_color","000000");
    mychart.setParam("data_value_font_size","12");
    mychart.setParam("grid_line","Y");
    mychart.setParam("grid_line_color","999999");
    mychart.setParam("x_value","Jan,Feb,Mar,Apr,May,Jun");
    mychart.setParam("s1_value","22,34,38,29,32,28");
    mychart.setParam("s1_label","Serie 1");
    mychart.setParam("s1_color","6699CC");
    ServletOutputStream sos = response.getOutputStream();
    PNGEncodeParam encParam = new PNGEncodeParam.Gray();
    ImageEncoder encoder2=ImageCodec.createImageEncoder ("PNG", sos, encParam);
    encoder2.encode(mychart.getChart());
    </body>
    </html>

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    Re: Graphs in JSP

    in fact, there is that JFreeChart can generate images it is sufficient to create a servlet ImgGenServlet which generates an image and integrate it into the img tag and PNG by a long way. JPEG is designed for compressing photographs where a small loss in quality is usually acceptable (and not very noticeable). For chart images, where there are usually sharp distinctions between areas of color, the artifacts introduced by the JPEG format are very noticeable. Don't use JPEG unless you absolutely have to. The PNG format is "lossless", so chart images are always reproduced perfectly.

Similar Threads

  1. Cant read charts and graphs in PDF files on Kindle 2
    By Aandaleeb151 in forum Portable Devices
    Replies: 5
    Last Post: 19-03-2010, 09:19 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,306,813.30658 seconds with 16 queries