SAMPLE: Simple Pie Chart - PHP
The information in this article applies to:
- Swiff Chart Generator 2
- Swiff Chart Generator 3
This example illustrates how to generate a simple pie chart in PHP.
<?php require( "SwiffChart.php" ); $chart= new SwiffChart; $sep= ';'; $ignoremultseparators= true; $chart->SetSeparators($sep, $ignoremultseparators); // Fill the series and categories $categories= "USA" . $sep . "Germany" . $sep . "United Kingdom"; $chart->SetCategoriesFromString($categories); $series= "45" . $sep . "28" . $sep . "16"; $chart->AddSeries(); $chart->SetSeriesValuesFromString(0, $series); // Set the chart title $chart->SetTitle("Geographical Distribution"); // Apply a Pie style // The chart type is stored in the style file (*.scs) // Here the selected style is the predefined pie style "Honolulu" $style = "pie/Honolulu"; $chart->LoadStyle( $style ); $chart->SetWidth( 400 ); $chart->SetHeight( 200 ); $chart->SetLooping( false ); $chart_res= $chart->GetHTMLTag(); ?> <H1>The Pie Chart</H1> <br><?=$chart_res?>
Keywords: | PHP Pie Chart |