need help?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
happythach864
Posts: 2
Joined: Thu Jul 26, 2018 8:00 am
antibot: No, of course not.

need help?

Post by happythach864 » Thu Jul 26, 2018 8:02 am

Hi,

I has problem in drawing graph in servlet by using JFreeChart. Below is a part of my servlet program :

...

xyData = createXYDataSource2();
chart.setAntiAlias(false);
chart = JFreeChart.createTimeSeriesChart(xyData);
StandardTitle title = (StandardTitle)chart.getTitle();
title.setTitle("Value of GBP");
chart.setChartBackgroundPaint(new GradientPaint(0, 0, Color.red,0, 1000, Col
or.blue));
Plot myPlot = chart.getPlot();
Axis myVerticalAxis = myPlot.getAxis(Plot.VERTICAL_AXIS);
myVerticalAxis.setLabel("USD per GBP");

try {

frame = new Frame();
frame.addNotify();

Image image = frame.createImage(WIDTH, HEIGHT);
g = image.getGraphics();
chart.draw((Graphics2D)g,new Rectangle2D.Double(10, 10, 430,250));
res.setContentType("image/gif");
GifEncoder encoder = new GifEncoder(image, out);
encoder.encode();

...

GifEncoder is a class for encoding GIF image that I downloaded in Acme. My program can be compiled successfully. However when I run it, it will return a blank image. What's wrong ?

Please help since I am urgent in doing it. Thank you very much.

Stanley
Top

Post Reply