views:

78

answers:

3

My requirement is I need to populate dyanamic graphs in a jsp page. I am using jsf for my project. I planning to use "jfreecharts" but dont know how to bind my jsp page with the back bean. I have some drop downs on the basis of the selection I my BackBean is fetching the data from the DB. Can you please suggest me some procedure to that with some sample code for my reference?

+4  A: 

You can use Fiji (Exadel) library.

They have charts, as well as support for wrapping SWF elements and sending properties in JSF.

See an example here. For each component, there is source code as well so you can try it yourself.

Odelya
Thankzzzz again for your valuable time.hey this is really gr8 I think this should definately work. I will try and I will update this blog.
Debarshi DasGupta
My jsp page is as follows : <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:fiji="http://exadel.com/fiji"> <fiji:columnChart id="columnChartOne" value="#{GraphBean.monthMap}" title="One-series Column Chart" barCaption="none" barColors="#{GraphBean.colors}" captionX="Months" captionY="Amount" toolTipValue="{y} {name} are sold in {x}" subtitle="Hardware sales per month" width="400" height="400">
Debarshi DasGupta
<fiji:chartData type="name" value="#{GraphBean.names}" /> </fiji:columnChart></ui:composition>
Debarshi DasGupta
My Bean is as follows : import java.util.ArrayList;import java.util.Date;import java.util.LinkedHashMap;import java.util.Map;import java.util.Random;public class GraphBean { private Integer data; private Map<String, Integer> monthMap = new LinkedHashMap<String,Integer>(); private ArrayList<String> names = new ArrayList<String>(); private ArrayList<String> colors = new ArrayList<String>(); Random rnd = new Random(new Date().getTime()); public GraphBean() { super(); generateData(); }
Debarshi DasGupta
private void generateData() { monthMap.put("January", getData()); monthMap.put("February", getData()); monthMap.put("March", getData()); } public Map<String, Integer> getMonthMap() { return monthMap; } public ArrayList<String> getNames(){ names.add("Motherboards"); return names; } public ArrayList<String> getColors(){ colors.add("#5db2c2"); return colors; } public Integer getData() { data = rnd.nextInt(50); return data; }}
Debarshi DasGupta
@Odelya This was the sample code mentioned in the link but on execution of this code I am getting the following exception : "org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP"....Can u pls suggest me some solution?
Debarshi DasGupta
HiCan you please post a new question for that?
Odelya
Hi sure I will do that ....I posted here as it was regarding fiji charts.
Debarshi DasGupta
+2  A: 

Primefaces has a nice chart component as well.

Bozho
Ok I will try that too and I will update this blog. Thanks for ur reply.
Debarshi DasGupta
@Bozho Fiji also has the ability to embed any SWF (like AMCHARTS) with JSF
Odelya
I know. That's what I said "as well", in addition to your answer :)
Bozho
+1  A: 

Fiji is very nice but check out this http://www.fusioncharts.com/

taher
It's not for free:FusionCharts Trial is a no-restriction evaluation of the actual component i.e., there are no days and feature limitations in this trial. The only difference is that in the trial version charts, "FusionCharts" and "InfoSoft Global" imprints would be present on the charts. Once you purchase a license, these imprints would be automatically removed.as well, if he wants to use it, he has to use FIJI integration with SWF.
Odelya
<a4j:outputPanel id="chart"><fc:render chartId="#{MyBean.chartId}" filename="#{MyBean.filename}" width="#{MyBean.width}" height="#{MyBean.height}" xml="#{MyBean.xml}"/> </a4j:outputPanel>no need to use FIJI to include SWF.
taher
thanks for your help.
Debarshi DasGupta
@ Taher bro fusioncharts are also awsm i have seen many demos they are rocking......
Debarshi DasGupta