JFreeChart does the job
It was quite a busy month before, I rarely even had time to post an entry. Luckily I am here now to tell about this exciting tool from the java community. It's called JFreeChart. Our team decided to use it(ehem, thanks to my research) and it seems to do a very good job. Although, the online documentation isn't complete... You have to buy it which doesn't make JFreeChart a free software after all. But with or without the docs they sell you can still use it effectively.
Here's a snipper of code that loads a data from a database, puts them in a List and sets the value for a PieChart. This is by no means a complete code.
public JFreeChart createChart()
DAOFactory dao = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
GeographicDAO geographicdao = dao.getGeographicDAO();
ArrayList<CountryBean> countryList = geographicdao.selectCountryList(magazine, timeStamp);
DefaultPieDataset dataSet = new DefaultPieDataset();
Country country = null;
for (int i = 0; i < countryList.size(); i++)
dataSet.setValue( country.getCountryName() + " = " + country.getPercentage() + "%", Float.parseFloat( country.getPercentage() ) );
country = null;
chart = ChartFactory.createPieChart3D("Country graph", dataSet, true, true, false);
public void writeChart(OutputStream ostream, int width, int height) throws IOException
ChartUtilities.writeChartAsJPEG( ostream, chart, width, height);
And here's how it might look