<分区>
我正在寻找基于 PHP 并可与 MySQL 一起使用的基于 Web 的报告框架。
这是我的问题(除了懒得自己编程之外):我有一个大表(超过 50k 行),用于存储多个客户端的日志数据。这些客户需要能够进行排序和搜索,并完成所有这些伟大的事情。
我真的很喜欢背后有相当大的力量的东西,这就是为什么我担心自己 build 一个。这不是一个大到值得投入过多时间的需求,但它是我的客户的必要功能。
理想情况下,我想要某种框架,它既可以传递数据,也可以使用模板引擎获取数据本身(这样它就可以完成所有的演示)。我可以获得呈现的演示文稿并将其放入我的站点。
这么好的东西可能不存在,但也许我会很幸运。
你可以试试 KoolReport .
免责声明:我正在从事这个项目。
这是一个 php 报告框架,正是您要找的。您可以通过网站下载框架,克隆project from github或者使用 composer 安装:composer require koolphp/koolreport
。
安装后,这里是创建销售报告的基本示例
index.php
:这是引导文件
<?php
require_once "SalesByCustomer.php";
$salesByCustomer = new SalesByCustomer;
$salesByCustomer->run()->render();
SaleByCustomer.php
:该文件定义了数据连接和数据处理
<?php
require_once "koolreport/autoload.php";
use \koolreport\processes\Group;
use \koolreport\processes\Limit;
use \koolreport\processes\Sort;
class SalesByCustomer extends \koolreport\KoolReport
{
public function settings()
{
return array(
"dataSources"=>array(
"sales"=>array(
"connectionString"=>"mysql:host=localhost;dbname=db_sales",
"username"=>"root",
"password"=>"",
"charset"=>"utf8"
)
)
);
}
public function setup()
{
$this->src('sales')
->query("SELECT customerName,dollar_sales FROM customer_product_dollarsales")
->pipe(new Group(array(
"by"=>"customerName",
"sum"=>"dollar_sales"
)))
->pipe(new Sort(array(
"dollar_sales"=>"desc"
)))
->pipe(new Limit(array(10)))
->pipe($this->dataStore('sales_by_customer'));
}
}
SalesByCustomer.view.php
:这是您可以可视化数据的 View 文件
<?php
use \koolreport\widgets\koolphp\Table;
use \koolreport\widgets\google\BarChart;
?>
<div class="text-center">
<h1>Sales Report</h1>
<h4>This report shows top 10 sales by customer</h4>
</div>
<hr/>
<?php
BarChart::create(array(
"dataStore"=>$this->dataStore('sales_by_customer'),
"width"=>"100%",
"height"=>"500px",
"columns"=>array(
"customerName"=>array(
"label"=>"Customer"
),
"dollar_sales"=>array(
"type"=>"number",
"label"=>"Amount",
"prefix"=>"$",
)
),
"options"=>array(
"title"=>"Sales By Customer"
)
));
?>
<?php
Table::create(array(
"dataStore"=>$this->dataStore('sales_by_customer'),
"columns"=>array(
"customerName"=>array(
"label"=>"Customer"
),
"dollar_sales"=>array(
"type"=>"number",
"label"=>"Amount",
"prefix"=>"$",
)
),
"cssClass"=>array(
"table"=>"table table-hover table-bordered"
)
));
?>
这里是 the result .
基本上,您可以同时从许多数据源获取数据,将它们通过流程传输,然后将结果存储到数据存储中。然后数据存储中的数据将在 View 中可用以实现可视化。 Google Charts集成在框架内,因此您可以立即使用它来创建漂亮的图表和图形。
好的,这里有一些不错的链接:
- KoolReport Advanced Examples : 看看更多好的例子
- Doc - Data Sources : 支持 MySQL, Oracle, SQLServer, MongoDB, CSV, Microsoft Excel ..
- Doc - Data Processing : 数据分析与转化
- Doc - Data Visualization :使用图表、表格等使您的数据可视化。
- Project on Github .
希望对您有所帮助。