Creating a SVG Chart Without Downloading a File
This technique is used when a chart image (SVG) will be generated by the
server side component. The idea is as simple as including the <EMBED> tag
wherever you want the chart to be displayed and the SRC parameter points to the
jsp that generates the BitStream by invoking the getHtmlData method. The
IMG tag should read as follows:
<EMBED SRC="chart.jsp" NAME="Chart1" TYPE="image/svg-xml" PLUGINSPAGE="http://www.adobe.com/svg/viewer/install/" WIDTH="400" HEIGHT="300">
|
The chart.jsp file will contain the necessary code that
generates the desired chart and invokes the getHtmlData method as a result of
the page. A very important issue when generating this JSP is to make sure
there are no other HTML tags or Line feeds in the resulting file as the chart
may not be correctly returned and displayed in the browser. In other words,
make sure the chart.aspx file only returns the results of the getHtmlData method
with no additional characters. For example a valid chart.aspx file may look
like:
<%@page import="SoftwareFX.ChartFX.*"%> <%ChartServer chart1 = new ChartServer(application,request,response); SVGWriter w = new SVGWriter(); chart1.setOutputWriter(w); //response.setHeader("Content-Type","image/svg-xml"); chart1.getHtmlData("400","240","SVG");%>
|
Please remember there must not be any spaces or carriage returns before the
start of the jsp code (<%). If you press [Enter] then a carriage return will
be generated in the result of the jsp and the IMG source will not be able to
read the image generated by Chart FX for Java. Therefore it is
strongly advised that you use a plain text editor when generating these files
as many advanced editors may include undesired HTML tags in the resulting file.
|