petesiss/phphc
Composer 安装命令:
composer require petesiss/phphc
包简介
Wrapper for HighCharts js charting lib
关键字:
README 文档
README
Wrapper for highcharts js lib, allowing for easy config of charts via php arrays.
<?php use Petesiss\PhpHc\ChartFactory; use Petesiss\PhpHc\Renderer\Renderer; $factory = new ChartFactory(); $chart = $factory->create() ->setChart(array('renderTo' => 'container', 'type' => 'line')) ->setTitle(array('text' => 'Traffic Flow')) ->setXAxis(array('categories' => array('Mon', 'Tue', 'Wed', 'Thurs', 'Fri'))) ->setYAxis(array('title' => array('text' => 'Vehicles per minute'))) ; // add data series $chart->addSeries('Main Street', array(44, 30, 34, 29, 48)); $chart->addSeries('Tower Road', array(29, 24, 27, 24, 28)); $renderer = new Renderer(); echo $renderer->render($chart);
Once a chart is created it can be configured using php arrays matching the highcharts API (http://api.highcharts.com/highcharts). There are accessor methods for each of the top level items - some of these shown in the example above.
The script block for the chart js can be easily rendered using the renderer as in the example. For more flexability just take the json from $chart->getJson() and deal with the rendering as required.
##Installation
Use composer to install, and make use of the autoload file composer will generate.
####Add to your composer.json
{ "require": { "petesiss/phphc": "dev-master" } }
####Then update your project dependencies
php composer.phar update petesiss/phphc
####Require composers generated autoload file
<?php require 'vendor/autoload.php';
Alternatively the lib follows the PSR-0 convention so you can clone the repo and use any compatible autoloader.
This lib doesnt redistribute the highcharts js - you need to include that in your project yourself. It is currently available via the highcharts CDN (http://code.highcharts.com).
统计信息
- 总下载量: 741
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-02-04