Hi riadhhwajdii,
There is an example in the following thread. May be you can use it as reference.
http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&pattern=JSF&thread=1239105242#N1239810952
Basically, your chart in bean only needs to have one or two properties as output, which is the URL of the created chart image, and the image map (if you are using image map). An example is like:
class MyChart
{
public MyChart()
{
//The followings are cut and paste from the Simple Bar Chart sample code
//that comes with ChartDirector.
//The data for the bar chart
double[] data = {85, 156, 179.5, 211, 123};
//The labels for the bar chart
String[] labels = {"Mon", "Tue", "Wed", "Thu", "Fri"};
//Create a XYChart object of size 250 x 250 pixels
XYChart c = new XYChart(250, 250);
//Set the plotarea at (30, 20) and of size 200 x 200 pixels
c.setPlotArea(30, 20, 200, 200);
//Add a bar chart layer using the given data
c.addBarLayer(data);
//Set the labels on the x axis.
c.xAxis().setLabels(labels);
//output the chart
String chart1URL = c.makeSession(request, "chart1");
//include tool tip for the chart
String imageMap1 = c.getHTMLImageMap("", "", "title='{xLabel}: US${value}K'");
//set to member variables
_url = response.encodeURL("getchart.jsp?"+chart1URL);
_imageMap = "<map name='map1'>" + imageMap1 + "</map>";
}
private String _url;
private String _imageMap;
public String getUrl()
{
return _url;
}
public String getImageMap()
{
return _imageMap;
}
}
Then in your JSF web page, you may use above bean for your image and image map.
<HTML>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<body bgcolor="white">
<f:view>
<h:graphicImage url='#{MyChart.url}' usemap="#map1" style="border:0" />
<h:outputText escape="false" value="#{MyChart.imageMap}" />
</f:view>
</body>
</HTML>
Hope this can help.
Regards
Peter Kwan |