graficzne statystyki

Using JFreeChart with Seam can be quite useful:

package example.chartprocesser;

@Name("chartprocesser")
public class ChartProcesserBean {

@In
EntityManager em; // Entity Manager to access the database

byte[] chart; // chart image (.png) as a byte array

@Factory(value="chart")
public void createChart() {

DefaultCategoryDataset ds = this.getData;

JFreeChart chart = ChartFactory.createLineChart(
"TITLE",
"Category Label",
"Axis Lable",
ds,
PlotOrientation.HORIZONTAL,
false,
false,
false
);

try{
this.chart = ChartUtilities.encodeAsPNG(chart.createBufferedImage(400, 400));
} catch (IOException e){
e.printStackTrace();
}

}

private DefaultCategoryDataset getData(){
//get the data and put into DefaultCategoryDataset
//Then return it.
}
}

In your JSF page:

<
s:graphicImage value="#{chartprocesser.chart}" /
>

Komentarze

Popularne posty z tego bloga

Set up JBoss AS 5.1.0 and Seam 2.2.0 in Ubuntu 9.04