behelmy

Simple Chart With Servlet

Recommended Posts

Dears,

Hope everything is going well.

I need to know how to show a chart from a Servlet.

I will not use Jsp.

I tried many times but without success.

 

So could anyone put a sample code for an example line2d, for any simple data, using servlet.

 

best regards.

Share this post


Link to post
Share on other sites

Hi

 

I found this code in archives. Please try it out. I haven't tested it recently.

 

String chartStr = FusionChartsHelper.createChart("FusionCharts/Column2D.swf", "Data/Data.xml", "", "ChartFromServlet", 600, 300, false, false);

StringBuffer chartHTML= new StringBuffer();

chartHTML.append("<HTML>");

chartHTML.append("<HEAD>");

chartHTML.append("<TITLE>FusionCharts - Export Example</TITLE>");

 

chartHTML.append("<script LANGUAGE='Javascript' SRC='FusionCharts/FusionCharts.js'></SCRIPT>");

 

chartHTML.append("</HEAD>");

chartHTML.append("<BODY>");

chartHTML.append(" <CENTER>");

chartHTML.append(" <h2>FusionCharts Example</h2>");

chartHTML.append("<h4>From servlet</h4>");

chartHTML.append(chartStr);

chartHTML.append("<BR>");

 

chartHTML.append("</CENTER>");

chartHTML.append("</BODY>");

chartHTML.append("</HTML>");

 

PrintWriter out = response.getWriter();

out.write(chartHTML.substring(0));

 

The class FusionChartsHelper is present in com.fusioncharts package. Import it in your servlet.

 

Hope this helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now