PIE Chart Using JFree Chart :
First required database connection, as per connection provide sql query to retrieve data from database.
JDBCPieDataset dataset = new JDBCPieDataset(connection);
try {
dataset.executeQuery("SQL QUERY");
JFreeChart chart = ChartFactory.createPieChart
("Performance - Report", dataset, true, true, false);
chart.setBorderPaint(Color.white);
chart.setBorderStroke(new BasicStroke(10.0f));
chart.setBorderVisible(true);
if (chart != null) {
int width = 500;
int height = 350;
final ChartRenderingInfo info = new ChartRenderingInfo (new StandardEntityCollection());
response.setContentType("image/png");
OutputStream out=response.getOutputStream();
ChartUtilities.writeChartAsJPEG(out, chart, width, height,info);
}
}catch (SQLException e) {
e.printStackTrace();
}
First required database connection, as per connection provide sql query to retrieve data from database.
JDBCPieDataset dataset = new JDBCPieDataset(connection);
try {
dataset.executeQuery("SQL QUERY");
JFreeChart chart = ChartFactory.createPieChart
("Performance - Report", dataset, true, true, false);
chart.setBorderPaint(Color.white);
chart.setBorderStroke(new BasicStroke(10.0f));
chart.setBorderVisible(true);
if (chart != null) {
int width = 500;
int height = 350;
final ChartRenderingInfo info = new ChartRenderingInfo (new StandardEntityCollection());
response.setContentType("image/png");
OutputStream out=response.getOutputStream();
ChartUtilities.writeChartAsJPEG(out, chart, width, height,info);
}
}catch (SQLException e) {
e.printStackTrace();
}