koenster/php-graphs

一个用于JS图表的PHP库。

安装次数: 4,792

依赖项: 0

建议者: 0

安全性: 0

星标: 4

关注者: 2

分支: 1

类型:项目

v0.1.2 2016-06-12 14:35 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:58:40 UTC


README

#PHP 图表

一个PHP库,可以将数据集合转换为图形对象,然后您最喜欢的JS图表库可以将它转换为应用程序中美丽的图表。

##要求

  • PHP 5.5.9 或更高版本

##支持的JavaScript库

当前JS实现

##实现

###应用程序


use koenster\PHPGraphs\contract\ChartContract;
use koenster\PHPGraphs\PHPChart;

$chart = new PHPChart(PHPChart::IMPLEMENTATION_CHART_JS);

$graph = $chart->add(PHPChart::TYPE_LINE, 'results', ['width' => 400, 'height' => 400]);
$graph->setLine([100,75,50,75,50,75,100], ['label' => 'Costs'])
    ->setLine([90,65,40,65,40,65,150], ['label' => 'Revenue'])
    ->setDimensions(['2006', '2007', '2008', '2009', '2010', '2011', '2012']);

###视图


<!doctype html>
<html>
<head>
    <!-- This is optional -->
    <?php foreach ($chart->getFactory()->getCss() as $css) : ?>
    <link rel="stylesheet" href="{{ $css }}">
    <?php endforeach; ?>

    <!-- This is optional -->
    <?php foreach ($chart->getFactory()->getJs() as $js) : ?>
    <script src="<?php echo $js; ?>"></script>
    <?php endforeach; ?>
</head>
<body>

<!-- This will generate the HTML code -->
<?php echo $graph->generate(); ?>

<script>
    // This will gather all charts and activate the JS library to convert the provided JSON to a Graph
    <?php echo $chart->getFactory()->getJsPartial(); ?>
</script>

对于完整实现(折线图、面积图、饼图等),请参阅示例目录。

##贡献

##待办事项(随机顺序)

  • 更详细的wiki/文档
  • 更多实现
  • 每个实现更多的配置(添加更多配置变量)
  • 更好的验证

##未来的实现

##许可

此PHP Graph库是开源软件,采用MIT许可。