Archive

Archive for July, 2009

Liferay FusionCharts Integration

July 24, 2009 rajcheram Comments off

How to do ” Liferay FusionCharts Integration”
Its easy simple …
Problem:exists:
You might given the syntax to include flash chart swf, xml [say for eg ]

I pasted Only Snippets in the html/jsp file used to include fusion charts ……
1.
<script language=”JavaScript” src=”js/FusionCharts.js”></script>
<link  rel=’stylesheet’ href=”Contents/Style.css” />

2. <script type=”text/javascript”>
var myChart = new FusionCharts(“Charts/StackedColumn3D.swf”, “chart1″, “580″, “300″, “0″, “0″);
myChart.setDataURL(“Data/Summary/Revenue2005.xml”);
myChart.render(“chart1″);
</script>

the problem

In portlet the location of swf, xml file cannot be known ..

Solution is to let portlet identify the location of swf/ xml file to display charts

Solution

1. Get the location of the portlet by

String pathPrefix=renderRequest.getContextPath();  //in jsp

1.<script language=”JavaScript” src=’<%=pathPrefix%>/js/FusionCharts.js’></script>
<link  rel=’stylesheet’ href=’<%=pathPrefix%>/Contents/Style.css’ />

2. <script type=”text/javascript”>
var myChart = new FusionCharts(“<%=pathPrefix%> /Charts/StackedColumn3D.swf?registerWithJS=1″, “chart1″, “580″, “300″, “0″, “0″);
myChart.setDataURL(“<%=pathPrefix%>Data/Summary/Revenue2005.xml”);
myChart.render(“chart1″);
</script>

FOLLOW THE SAME WHERE EVER NEEDED …….

ENJOY ..