我第二个phpChart。过去将其用于在线报告任务。非常容易快速创建图表。
这是基于他们的在线示例使用phpChart解决您的场景的解决方案- Axis Labels Rotated Text 2:
<?php
$line = array(array('user', 12), array('admin', 3), array('user2', 1), array('user3', 1));
$pc = new C_PhpChartX(array($line),'user_chart');
$pc->add_plugins(array('canvasTextRenderer'));
//set series
$pc->add_series(array('renderer'=>'plugin::BarRenderer'));
//set axes
$pc->set_axes(array(
'xaxis' => array(
'renderer'=>'plugin::CategoryAxisRenderer',
'tickRenderer'=>'plugin::CanvasAxisTickRenderer'),
'yaxis' => array(
'autoscale'=>true,
'tickRenderer'=>'plugin::CanvasAxisTickRenderer')
));
$pc->draw(800,500);
?>
结果:
将第 6 行更改为 PieRenderer,您将得到一个饼图。
<?php
$line = array(array('user', 12), array('admin', 3), array('user2', 1), array('user3', 1));
$pc = new C_PhpChartX(array($line),'chart_1');
$pc->add_plugins(array('canvasTextRenderer'));
//set series
$pc->add_series(array('renderer'=>'plugin::PieRenderer'));
//set axes
$pc->set_series_default(array(
'renderer'=>'plugin::PieRenderer',
'rendererOptions'=>array('showDataLabels'=>true)));
$pc->set_legend(array('show'=>true,
'rendererOptions'=> array('numberRows'=> 1),
'location'=> 's'));
$pc->draw(800,500);
?>
这是我发现的关于 Codeproject 的精彩介绍:http:
//www.codeproject.com/Articles/604542/Creating-Interactive-HTML5-Graphs-in-PHP