How to pass value from backing bean to jqplot script
eswaramoorthy1985 Dec 8, 2010 4:54 AMHi,
I am going to create piechart using richfaces with jQplot. I already create chart using static value.
But i want to pass value from backing bean to jqplot. In my code is
<f:view> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <a4j:loadStyle src="../../resources/chart/css/jquery.jqplot.css"/> <a4j:loadScript src="../../resources/chart/jqplot-javascript/jquery-1.3.2.min.js"/> <a4j:loadScript src="../../resources/chart/jqplot-javascript/jquery.jqplot.min.js"/> <a4j:loadScript src="../../resources/chart/jqplot-javascript/jqplot.pieRenderer.min.js"/> <script type="text/javascript"> var jsonPieObj = { "pageHits": [ ['JAN 2009', 120], ['Feb 2009',60], ['Mar 2009',22], ['Apr 2009',5], ['May 2009',60], ['June 2009',30], ['Jul 2009',22]] }; $(function() { $('#pieChartButton1').click(function() { $('#chartDiv').html(''); $.jqplot('chartDiv', [jsonPieObj.pageHits], CreatePieChartOptions1()); }); }); function CreatePieChartOptions1() { var optionsObj = { title: 'Blog Statistics', legend: { show: true, location: 'nw' }, seriesDefaults:{ shadow: true, renderer:$.jqplot.PieRenderer, rendererOptions:{ sliceMargin:10, shadowOffset:1, shadowAlpha:0.5, shadowDepth:5 } }, highlighter: { showTooltip: true, tooltipFade: true } }; return optionsObj; } </script> </head> <body> <h:form id="chartForm"> <rich:panel id="pieChartRichPanel"> <div> <rich:panel> <div id="chartDiv" style="width:600px; height:400px;" /> </rich:panel> </div> <div> <input id="pieChartButton1" type="button" value="Pie Chart for Page Hits" /> </div> </rich:panel> </h:form> </body> </html> </f:view>
My static code is
var jsonPieObj = { "pageHits": [ ['JAN 2009', 120], ['Feb 2009',60], ['Mar 2009',22], ['Apr 2009',5], ['May 2009',60], ['June 2009',30], ['Jul 2009',22]] };
So how to access value from bean?
Help me about this.
Thanks for your support.