I need urgent help...
When I'm darwing a chart in my servlet by this code:
Code: Select all
HttpSession session = req.getSession();
int[][] arr = (int[][])session.getAttribute("cursors");
OutputStream out = res.getOutputStream();
XYSeries s1 = new XYSeries("Cursors");
for(int i=0, j=0; i<arr.length; ++i) {
s1.add(arr[i][j], arr[i][j+1]);
}
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(s1);
JFreeChart chart = ChartFactory.createXYStepChart(null,
"X", "Y",
dataset,
PlotOrientation.VERTICAL,
false,
false,
false);
XYPlot plot = chart.getXYPlot();
ValueAxis axis = plot.getRangeAxis();
axis.setTickLabelsVisible(false);
axis.setTickMarksVisible(false);
axis.setLabel(null);
axis.setLowerMargin(0.0);
axis.setUpperMargin(0.0);
ValueAxis axiz = plot.getDomainAxis();
axiz.setLabel(null);
axiz.setTickMarksVisible(false);
axiz.setTickLabelsVisible(false);
axiz.setLowerMargin(0.0);
axiz.setUpperMargin(0.0);
res.setContentType("image/png");
ChartUtilities.writeChartAsPNG(out, chart, 500, 300);
My question is , how can I make my plot the same size as the chart???
thanks