Download the PHP package scorpionslh/highcharts-php without Composer
On this page you can find all versions of the php package scorpionslh/highcharts-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download scorpionslh/highcharts-php
More information about scorpionslh/highcharts-php
Files in scorpionslh/highcharts-php
Package highcharts-php
Short Description A php wrapper for highcharts and highstock javascript libraries
License GPL-3.0
Homepage http://goncaloqueiros.net/highcharts.php
Informations about the package highcharts-php
HighchartsPHP
HighchartsPHP is a PHP library that works as a wrapper for the Highchart js library (http://www.highcharts.com) and it was built with flexibility and maintainability in mind. It isn't a simple port of the JavaScript library to PHP, it was designed in a way that mimics the JavaScript counterpart API, so that the developer only needs to learn one API.
The companion webpage can be found at http://www.goncaloqueiros.net/highcharts.php
Setup
The recommended way to install HighchartsPHP is through Composer
. Just create a composer.json
file and run the php composer.phar install
command to install it:
Usage
Simple
You can create a highchart or highstock chart using one of the three js engine available (jQuery, mootools, and prototype), using the Highchart constructor.
Now that there's a valid $chart
object the developer only needs to add elements to it as if it was writing them in JavaScript.
You can also create simple arrays
Render
To get all the script necessary to render your chart you can use the printScripts()
method:
Or if you don't want to directly echo the scripts and rather the function to return the script string:
And finally to render the chart object use the render()
method:
The first (optional) argument passed to render method is the var name to be used by JavaScript and the second (optional) argument is the callback to be passed to the Highcharts.Chart
method. The third and last (optional) argument flags that you want your script already wrapped around HTML script tags.
Its also possible to render the chart options only by calling the method. Useful for times where the chart is used inside a call for example
Javascript expressions
If one of the chart options must be a JavaScript expression, you can't assign a simple string to it, otherwise it will be printed as a simple JavaScript string also. For that you must use the special HighchartJsExpr
object:
Empty javascript object {}
If you wish to render an empty javascript object , just assign the variable you want with
Extra scripts
To manually include a script for render use the function:
To include an extra script use the key that's on the config file or that was given manually via
To include more than one script just add it to the array
If no arguments are passed, it will include all the extra scripts
If you want to add any extra script to the default config file, feel free to open a PR. Here is the list of the current extra scripts available:
Use new Highcharts 3.0 charts
Highcharts 3.0 introduced a new set of charts that require an additional javascript file .
To include this extra script you need to call the method with the highcharts-more key.
Render only some options
If you need to render a small portion of options, you can use the method.
A good example of this can be found at clock demo
This way it is possible to include option rendering inside a javascript expression
Set up a general configuration
There are cases where a configuration is not created only for a chart, but for all the charts on the page (lang and global) are examples of this.
To set a general option, just create a new (not chart) and send it to method.
The must be placed before the chart render
Themes
Theme creation follows the same process for a general option. You create a new object, use it has if it was a chart and then call method.
Configuration
By default HighchartsPHP library comes with configurations to work out of the box. If you wish to change the path of any js library loaded, have a look at src/config.php
.
In case you need to change some of this values you should use the setConfigurations
method:
Demos
All the Highcharts and Highstocks live demos present on http://www.highcharts.com under the demo gallery were reproduced using this library and you can find them on the demos folder or see a live example on http://www.goncaloqueiros.net/highcharts/demos.php
Tests
You can run the unit tests with the following command: