Cathy King wrote on Tuesday, January 07, 2003 4:53 AM
Subject: Chart products

> Could you
> recommend some chart products to me? I really appreciated your help and
> suggestions.

Hi Cathy,

to generate graphics or charts, you can use svg within a customtag in your
jsp (with no additional cost!).

A webapp including samples and sources you can find here:
http://www.p8serv.de/werkstatt/download/BatikLib.zip

It is a basic jsp1.2 custom-tag.
To run this, you need Batik in your classpath.
You find Batik here:
http://xml.apache.org/batik

Using the svg-tag, a simple ( but ugly ) dynamic barchart could be this:
 

 --------------  <forexample.jsp>  --------------

<%@ taglib uri="/WEB-INF/tld/p8-batik.tld" prefix="p8"%>
<%
int rate1=(int)(Math.random()*100);
int rate2=(int)(Math.random()*100); 

int rate3=(int)(Math.random()*100); 

//=Integer.parseInt(request.getParameter("count3"));

String bgcolor="rgb(128,128,128)"; 

//=session.getAttribute("bgcolor").toString();

String color1="rgb(255,0,0)"; 

String color2="rgb(0,255,0)"; 

String color3="rgb(0,0,255)"; 
%>

<p8:batik format="png" imgname="example1" width="175" height="200"
align="left" hspace="0" vspace="0">
<svg width="175" height="200">
<rect x="0" y="0" width="175" height="200" fill="<%=bgcolor%>"/>
<rect x="25px" y="25px" width="25px" height="<%=rate1%>"
fill="<%=color1%>"/>
<rect x="75px" y="25px" width="25px" height="<%=rate2%>"
fill="<%=color2%>"/>
<rect x="125px" y="25px" width="25px" height="<%=rate3%>"
fill="<%=color3%>"/>
</svg>
</p8:batik>


 --------------  </forexample.jsp>  --------------


Regards
Stefan

Reply via email to