Hi,
I have a problem of displaying more than one graphs on a page. They are currently drawn on top of each other. I'm very new in java and jsp. Please show me what I did wrong here. And if you have any good suggestion, please help. Thanks.
- Maggie
----------------------------------
TimeSeriesCollection[] graphs = new TimeSeriesCollection[lossLogs.size()];
// ....
double x = 0;
double y = 0;
double w = 500;
double h = 400;
Rectangle areaDrawing = new Rectangle();
areaDrawing.setFrame(x, y, w, h);
ChartRenderingInfo info = new ChartRenderingInfo();
info.setPlotArea(areaDrawing);
// Draw the graphs out
// Go to loop to draw all graphs
for (int i = 0; i < graphs.length; i++)
{
// create the chart...
JFreeChart chart = ChartFactory.createXYChart("Prober Testing", "X", "Y", graphs, true);
response.setContentType("image/png");
ChartUtilities.writeChartAsPNG(out, chart, (int)w, (int)h, info);
y += (450);
areaDrawing.setFrame(x, y, w, h);
}
List more than one graphs on a page
Re: List more than one graphs on a page
I found a solution to fix this. I need to have two servlets, one for display and for chart generator (like the one in the documentation). Here is a piece of code to loop through:
"&graph=" + i will tell the chart which graph to draw
That's the general idea. It has been a great experience learning this API. I also recommend buying the documentation.
Thanks for reading this. - Maggie
String requestedSecs = request.getParameter("view");
String rate = request.getParameter("rate");
response.setContentType("text/html");
out.println("<HTML>");
out.println("<meta http-equiv=\"refresh\" content=" + rate + "\">");
out.println("<HEAD>");
out.println("<TITLE>Probing Results</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("<P>");
for (int i=0; i < lossLogs.size(); i++)
{
out.println("<IMG SRC=\"chart?view=" +requestedSecs + "&graph=" + i + "&rate=" + rate + "\" BORDER=1>");
out.println("<P>");
}
out.println("</BODY>");
out.println("</HTML>");
out.flush();
out.close();
"&graph=" + i will tell the chart which graph to draw
That's the general idea. It has been a great experience learning this API. I also recommend buying the documentation.
Thanks for reading this. - Maggie
String requestedSecs = request.getParameter("view");
String rate = request.getParameter("rate");
response.setContentType("text/html");
out.println("<HTML>");
out.println("<meta http-equiv=\"refresh\" content=" + rate + "\">");
out.println("<HEAD>");
out.println("<TITLE>Probing Results</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("<P>");
for (int i=0; i < lossLogs.size(); i++)
{
out.println("<IMG SRC=\"chart?view=" +requestedSecs + "&graph=" + i + "&rate=" + rate + "\" BORDER=1>");
out.println("<P>");
}
out.println("</BODY>");
out.println("</HTML>");
out.flush();
out.close();