KWidget
Overview #
KWidget is special widget which is able to wrap any KoolReport Widget so that it will fit into Dashboard environment.
Settings #
Name | description |
---|---|
use | Get/set the class name of KoolReport Widget you want to wrap |
settings | Get/set the settings provided to KoolReport Widget |
dataSource | Get/set the datasource provide to KoolReport Widget |
Note: Those above properties follows this code rules.
Traits #
Google Charts has been provided with following traits:
- TAppLink: Able to refer to application with
app()
method - TDashboadLink: Able to refer to parent dashboard with
dashboard()
method - TEnabledPermit: Use
enabled()
andenabledWhen()
to set permission - TParams: Able to get/set parameters with
params()
method - TWidgetState: Able to get/set persisted state for widget
- TParamsPersisted: Able to make params set to widget persisted
- TDataSource: Able to receive datasource via
dataSource()
method - TDetailAction: Able to open detail modal
- TExportable: Able to export widget to different formats
Examples #
Create chart from dashboard
<?php
use \koolreport\dashboard\Dashboard;
use \koolreport\dashboard\widgets\KWidget;
class StockBoard extends Dashboard
{
protected function content()
{
KWidget::create()
->use(\koolreport\chartjs\ColumnChart::class)
->settings([
"isStacked"=>true
])
->dataSource(
ShopDB::table("stocks")
->groupBy("product")
->select("product")
->sum("store1")
->sum("store2")
)
}
}
Create a separate widget class
<?php
use \koolreport\dashboard\widgets\KWidget;
class MyColumnChart extends KWidget
{
protected function onInit()
{
$this
->use(\koolreport\chartjs\ColumnChart::class)
->settings([
"isStacked"=>true
]);
}
protected function dataSource()
{
return ShopDB::table("stocks")
->groupBy("product")
->select("product")
->sum("store1")
->sum("store2");
}
}
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.