Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
Those widgets looks great. You may create new widget by extends the \koolreport\core\Widget
and overwrite two important methods onInit()
and onRender()
. In the onRender()
method, you call $this->template($data)
to render. It automatically load the template file of widget {widgetname}.tpl.php
.
would the following be the smartest way to work with single value fields?
Number::create([
"title" => "KPI 2",
"dataSource" => array(
array("value1" => "25")
)
]);
(I would like to keep the dataStore approach to be able to retrieve values through the framework)
and in .tpl.php
<?php echo $this->title; ?>:
<?php
foreach ($this->dataStore as $row) {
echo $row['value1'];
}
?>
Forget to answer your question, may be you do not need to use the datasource here. We only need single value to display so you may make it simple like this:
Number::create([
"title"=>"Income",
"value"=>5434.12,
"prefix"=>"$",
"suffix"=>"".
"decimals"=>2
"thousandSeparator"=>",",
"decimalPoint"=>"."
]);
The value receive number and you can feed any number there. You can use like this as well:
"value"=>$this->dataStore("orders")->sum("amount")
My current solution to combine different visualisations into one report is to use html code within the *.view.php to layout the different components.
For simple numeric values I access the datastore object directly like this (instead of building a dedicated component):
<div>count: <?php echo $this->dataStore("orders")->count('*'); ?></div>
can you confirm that this is an valid approach?
Or is there a way to build complex reusable components, which utilise existing components (graphs, tables...), and can be called like this:
myComplexComponent::create([
"dataSource" => $this->dataStore("orders")
]);
(which would then render a revenue number, a trendline, a trend indicator, list of latest orders etc...)
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo