You are viewing documentation for an older version. For current documentation - click here.

FusionCharts PHP Class API lets you configure the attributes of various chart elements like dataset, dataplot, categories etc. In this section we will see sample usage of those functions of FusionCharts PHP Class which help you to do the same. Topics include:

 
Provide categories attributes

Attributes which are specific to <categories> element can be set using setCategoriesParams function. We will pass a delimiter (default is ;) separated list of attributes to the function.

Example:
 
$FC->setCategoriesParams("font=Arial;fontSize=13;fontColor=ff0000");
 
Provide attribute for each category

We can configure each category while adding a category using addCategory function. This is done by passing category attributes as a list of delimiter separated attributes as the second parameter to the addCategory function.

Example:
 
$FC->addCategory("Week 1","toolText=Sales for week 1");
$FC->addCategory("Week 2 ","toolText=Sales for second week;showlabel=1");
$FC->addCategory("Week 3 ","showlabel=0");
 
Provide dataset attributes

To provide dataset attributes we need to use the function - addDataset. It accepts the seriesName attribute of the dataset as its first parameter. The other parameter accepts a delimiter (default is ;) separated list of dataset attributes.

The example below will add 3 datasets for a combination chart. The first two datasets with 'This Month' and 'Previous Month' as seriesName (respectively) , will be set to Primary Y-Axis and would not show data values. The third dataset with 'Total Quantity' as seriesName, will be set to Secondary Y-Axis, 5 sided anchors and various other anchor settings.
 
$FC->addDataset("This Month","showValues=0;parentYAxis=P");
...
$FC->addDataset("Previous Month","showValues=0;parentYAxis=P");
...          
$FC->addDataset("Total Quantity","parentYaxis=S;anchorSides=5;anchorradius=6;color=880000;anchorBgcolor=EE0000");

The chart that follows is as shown below:

 
Provide attribute to each dataplot

setChartParams() function sets chart parameters globally. However, we may need to set specific properties to particular dataplot. To do so, we need to send the parameters through addChartData() function while feeding data. Consider the code below:

# Create a line chart object 
   $FC = new FusionCharts("Column3D","300","250");         
        ...
        # add chart values and category names
        $FC->addChartData("48200", "label=Week 1;alpha=40;showlabel=0;showValue=0"); 
        $FC->addChartData("32100", "label=Week 2;alpha=40;showlabel=0;showValue=0"); 
        $FC->addChartData("21400", "label=Week 3;hoverText=Lowest;link=tooLow.php"); 
        $FC->addChartData("54400", "label=Week 4;showlabel=0;showValue=0; alpha=40; hoverText=Highest");
        ...      
 
Here, we provide different alpha values for each dataplot. We also hide the data values and category names of all the data plots except the third one. Again we set a link to the third dataplot. Moreover, we also set tooltext values for third and fourth dataplot.
 
 
This way we can control individual dataplots of Line, Bar, Area and all other charts.