Data Visualization

Overview #

We have learned in previous section how to connect to database, pulling data and piping them through series of processes to get meaningful data. Those data are stored in the data stores of the report ready to be used to create beautiful visualization. In this section, we will learn about the view of report and how to use Widgets in your view.

View #

What is report's view? #

It is another PHP file containing html/css determined how your report will appear. Normally, the view file will be put in the same folder with your report class file and has suffix .view.php.

/
├── SaleReport.php
└── SaleReport.view.php

One report, different views #

A report can have many different views. Each view may hold different charts/tales describe the same data or each view is for different purpose. The purpose could be to display html on web or to generate PDF, XML, JSON.

<?php
...
$saleReport = new SaleReport();
$saleReport->run();
$saleReport->render(); //--> This will render the default view SaleReport.view.php
...
$saleReport->render("SaleReport_AnotherView");//--> This will render the view: SaleReport_AnotherView.view.php

Get content rather than render #

Sometime we may need to get the report rendered content to further process. By enter true in second parameter of render() function, it will return the content instead of sending content to browser.

$content = $saleReport->render("SaleReport",true);//--> Return the view content

Debug view #

If you created a report wihout any view. If you try to render the report, you will get the debug view, which contains list of all datastores as well as their data in table form.

Summary #

A report may have different views or different ways to represent data. The default view of a report has the name of {report_name}.view.php. In a view, you may use any kinds of HTML/CSS/Javascript or pre-built KoolReport's Widget. Widget can be Table. Charts or any forms of data representation.

Get started with KoolReport

KoolReport will help you to construct good php data report by gathering your data from multiple sources, transforming them into valuable insights, and finally visualizing them in stunning charts and graphs.