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
2010-07-29 08:25:53
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
2010-07-29 09:16:24
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
2010-07-31 19:18:30
<fiji:chartData type="name" value="#{GraphBean.names}" /> </fiji:columnChart></ui:composition>
Debarshi DasGupta
2010-07-31 19:18:59
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
2010-07-31 19:20:14
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
2010-07-31 19:20:38
@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
2010-07-31 19:23:40
HiCan you please post a new question for that?
Odelya
2010-07-31 19:32:48
Hi sure I will do that ....I posted here as it was regarding fiji charts.
Debarshi DasGupta
2010-08-01 06:51:02
Ok I will try that too and I will update this blog. Thanks for ur reply.
Debarshi DasGupta
2010-07-29 10:24:30
@Bozho Fiji also has the ability to embed any SWF (like AMCHARTS) with JSF
Odelya
2010-07-29 11:43:19
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
2010-07-29 13:00:56
<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
2010-07-29 13:24:30
@ Taher bro fusioncharts are also awsm i have seen many demos they are rocking......
Debarshi DasGupta
2010-07-31 18:51:22