Highcharts module for Zend Framework 2 based on HighRoller.
I'm discontinuing this project in favor of more flexible approaches. For my own projects I've switched to HighchartsPHP with ease. I recommend you to also make the switch, since I won't be updating this packages with new features. Thank you all for your support!
Package of Highroller by @jmaclabs ready for Zend Framework 2 integration via Composer.
Require this project using composer:
./composer.phar require jfloff/highroller-zf2:dev-master
Enabling it in your
```php <?php return array( 'modules' => array( // ... 'HighRoller', 'AssetManager', ), // ... ); ```
In this quick guide, we will place a very humble line chart in the ZF2 Skeleton Application. Before starting make sure you are using a clean ZF2 Skeleton Application, and that you already set up highroller-zf2 using the instructions above.
Include HighRoller files:
use HighRoller\LineChart; use HighRoller\SeriesData;
indexActionfunction create a new line chart:
$linechart = new LineChart(); $linechart->title->text = 'Line Chart'; $series = new SeriesData(); $series->name = 'myData'; $chartData = array(5324, 7534, 6234, 7234, 8251, 10324); foreach ($chartData as $value) $series->addData($value); $linechart->addSeries($series);
Pass the your HighRoller object
$linechartto the view:
return new ViewModel(array('highroller' => $linechart));
Include highcharts.js file (you could also do this in your layout):
<script src="http://code.highcharts.com/highcharts.js"></script> <script src="http://code.highcharts.com/modules/exporting.js"></script>
At the top of the file:
- Add a HTML div where your chart will be rendered to,
- Set the div id in the HighRoller object,
- Finally append the render script.
<div id="highroller"></div> <?php $this->highroller->chart->renderTo = "highroller"; $this->headScript()->appendScript($this->highroller->renderChart()); ?>
You should now see a beautiful simple line chart in your main page, just like this one:
HighRoller is licensed by Gravity.com under the Apache 2.0 license, see the LICENSE file for more details.
HighCharts is licensed by Highsoft Solutions AS.
Highcharts is licensed for free for any personal or non-profit projects under the Creative Commons Attribution-NonCommercial 3.0 License.