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

Using FusionCharts PHP Class API we can apply various styles to the charts. Styles lends a simple mechanism using which you can easily control the visual layout of charts. For each defined object on a chart you can apply one or more styles like animation bevel, blur, font, shadow and glow. Let's see how we can accomplish this using FusionCharts PHP Class.

 

defineStyle() and applyStyle() functions of FusionCharts PHP Class let you apply styles to various objects of the chart. The process of applying styles involves two steps:

  • Use defineStyle() to define a custom style.
  • Use applyStyle() to apply the custom defined styles to different chart objects.

Let's take an example.

 

# Define First Style element
$FC->defineStyle("MyFirstFontStyle","font","font=Verdana;size=12;color=FF0000;bgColor=FFFFDD;borderColor=666666");

# Define Second Style element
$FC->defineStyle("MyFirstGlow","Glow","color=FF5904;alpha=75");

# Apply first Style to CAPTION object
$FC->applyStyle("CAPTION","MyFirstFontStyle");

# Apply first and second Style to XAXISNAME object
$FC->applyStyle("XAXISNAME","MyFirstGlow,MyFirstFontStyle");

# Apply second Style to YAXISNAME object
$FC->applyStyle("YAXISNAME","MyFirstGlow");

 

At first, we define two style elements using defineStyle() function. The defineStyle () function takes three parameters viz. custom name, style type and style attributes. First we define a style and name it as "MyFirstFontStyle". It is of "Font" type. The attributes defined in it are font, size, color, border color and background color. Then, we define style "MyFirstGlow" of "Glow" type. The attributes defined in it are color and alpha (i.e., transparency).

Next,we apply those two defined styles to the chart objects. The first applyStyle() function applies style "MyFirstFontStyle" to the "CAPTION" object of the chart. The next applyStyle() applies both "MyFirstGlow" and "MyFirstFontStyle" to "XAXISNAME". So it gives the "Glow" effect and the "Font" effect together. The last applyStyle() applies the style "MyFirstGlow" to "YAXISNAME".


Please go through FusionCharts v3 Styles section to know more about various style types and how they are applied with various attributes.
 
And the resultant chart is: