|
Project Information
Featured
Downloads
Links
|
PHP Wrapper for the highcharts library (http://highcharts.com). IMPORTANTUpdate - 2010-06-11 A major improvement of the libraryis scheduled to be released in the last week of June 2010.
Stay Tuned ! Configure your charts programmatically in pure PHP-object style. It generates a js file for the rendering of the charts by the excellent HighCharts Library How to use the HighCharts Wrapper1 get the last version of the software- First you need to download the highCharts librairy at http://www.highcharts.com - Next you must download (if not yet) the HighSlide PHP Wrapper at http://code.google.com/p/highchartwrapper/ 2 Add the js librairiesInclude the following lines in the <head></head> section of your page : <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script src="/path-to/highcharts.js" type="text/javascript"></script> <script src="path-to/excanvas-compressed.js" type="text/javascript"></script> 3 Go PHP !You can found this example in pure HighChart JS Synthax here : http://www.highcharts.com/demo/?example=line-basic&theme=default Here is the same graph, but with this PHP style synthax : <?php // We are assuming you place this example file at the root of the HighChart Wrapper folder require_once("dependancy.php"); $oChart = new CHCChart('container'); //title $oChart->setTitle('Monthly Average Temperature'); $oChart->setTitle->setStyle(array('margin' => '10px 100px 0 0', 'color' => 'red')); // subtitle $oChart->setSubTitle('Source: WorldClimate.com'); $oChart->setSubTitle->setStyle(array('margin' => '10px 100px 0 0')); // X Axis $oChart->setXAxis->setCategories(array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')); $oChart->setXAxis->setTitle('Month'); // Y Axis $oChart->setYAxis->setTitle('Temperature (°C)'); $oChart->setYAxis->addPlotLines('#808080', 0, 1); // Tooltip $sTooltipFormatter = "function() {return ''+ this.series.name +' $oChart->setTooltip->setFormatter($sTooltipFormatter); // Legend $oChart->setLegend->setLayout('vertical'); $oChart->setLegend->setStyle(array('left' => 'auto', 'bottom' => 'auto', 'right' => '10px', 'top' => '100px')); // series $oSerie01 = new CHCSeries(); $oSerie01->setName('Tokyo'); $oSerie01->setType('column'); // those coords use the addPoint() Method instead of the addDataSerie() method $oSerie01->addPoint(7.0); $oSerie01->addPoint(6.9); $oSerie01->addPoint(9.5); $oSerie01->addPoint(14.5); $oSerie01->addPoint(18.2); $oSerie01->addPoint(21.5); $oSerie01->addPoint(25.2); $oSerie01->addPoint(26.5); $oSerie01->addPoint(23.3); $oSerie01->addPoint(18.3); $oSerie01->addPoint(13.9); $oSerie01->addPoint(9.6); // Serie 02 $oSerie02 = new CHCSeries(); $oSerie02->setName('New York'); $oSerie02->addDataSerie(array(-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5)); // Serie 03 $oSerie03 = new CHCSeries(); $oSerie03->setName('Berlin'); $oSerie03->addDataSerie(array(-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0)); // Serie 04 $oSerie04 = new CHCSeries(); $oSerie04->setName('London'); $oSerie04->addDataSerie(array(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8)); // adding the series to the chart $oChart->addSerie($oSerie01); $oChart->addSerie($oSerie02); $oChart->addSerie($oSerie03); $oChart->addSerie($oSerie04); // generate the js for the chart's render $sChart = $oChart->getDisplay(); ?> <html>
<!-- We are assuming all the js resources are located in a directory called js/ --> <!-- js code for the chart --> <?php echo $sGraph; ?>
</html> done ! |