Hi Guys,

I am trying to integrate charts in tapestry page.

Here is the code written for servlet which will enable me to display the
chart. I am stuck on how do I do in Tapestry? Please help.

Thanks,

Ashish

 

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

OutputStream out = response.getOutputStream();

try {

DefaultCategoryDataset dataset = new DefaultCategoryDataset();

dataset.addValue(10.0, "S1", "C1");

dataset.addValue(4.0, "S1", "C2");

dataset.addValue(15.0, "S1", "C3");

dataset.addValue(14.0, "S1", "C4");

dataset.addValue(-5.0, "S2", "C1");

dataset.addValue(-7.0, "S2", "C2");

dataset.addValue(14.0, "S2", "C3");

dataset.addValue(-3.0, "S2", "C4");

JFreeChart chart = ChartFactory.createBarChart(

"Bar Chart",

"Category",

"Value",

dataset,

PlotOrientation.VERTICAL,

true, true, false

);

response.setContentType("image/png");

ChartUtilities.writeChartAsPNG(out, chart, 400, 300);

}

catch (Exception e) {

System.err.println(e.toString());

}

finally {

out.close();

 

Reply via email to