Problem: does not allow me to renderBinary. The method renderBinary(InputStream) in the type Controller is not applicable for the arguments (JFreeChart).
I have this controller:
public static void index() {
// create a dataset...Default
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Category 1", 43.2);
dataset.setValue("Category 2", 27.9);
dataset.setValue("Category 3", 79.5);
// create a chart...
JFreeChart chart = ChartFactory.createPieChart(
"Sample",
dataset,
true,
true,
false
);
List<User> usersA = Department.getUsersA();
List<User> usersB = Department.getUsersB();
render(usersA, usersB, chart);
}
You need to create an Img to return. JfreeChart is not an image.
Also, you need to create a single controller to return the image. You cannot return the image in a normal render result.
So you’d have a controller like, renderChart(String chartId){ …. make the chart … renderBinary(img); }
Here code that creates an image from JFreeChart (from http://www.jfree.org/phpBB2/viewtopic.php?t=113 )