This topic is locked

fusioncharts integration

5/2/2011 6:34:04 AM
PHPRunner Tips and Tricks
D
duck author

After downloading and expanding the package

Installation

1)put the 'fusioncharts' folder complete in the project output folder(this contains the swf files)

2) put FusionCharts.php into the project output include folder

Configuration

3)in the page to put the chart on the events tab

after table initialised:-
include("include/FusionCharts.php");
4) on the page for the chart in visual editor html mode immediately prior to the </head> tag:-
<script type=text/javascript src="FusionCharts/FusionCharts.js">

</SCRIPT>
5) on the page for the chart in visual editor add new snippet to set chart position and size:-

$chart=$_SESSION["fusionchart"];

//picks up session variable for sending data from other pages to the chart

echo renderChart("FusionCharts/xxx.swf", "",$chart,"myChartId", 450, 370, false,true);

// xxx.swf is the chart chosen to display from the fusioncharts folder and 450,370 is size of chart area
6)generate the chart and store in the session variable for display (put on any event that gives the data for the display to use ):-

$strXML = " <chart caption='Weekly Sales Summary' xAxisName='Week' yAxisName='Sales' fix='$'> ";

$strXML .= " <set label='Week 1' value='14400' /> ";

$strXML .= " <set label='Week 2' value='19600' /> ";

$strXML .= " <set label='Week 3' value='24000' /> ";

$strXML .= " <set label='Week 4' value='15700' /> ";

$strXML .= " </chart>";
//Create the Chart with data from $strXML

$_SESSION["fusionchart"] = $strXML;
the xml data for the chart can be laborious but googling the variables within fusioncharts reference pages finds most things