Skip to main content

Show Posts

This section allows you to view all Show Posts made by this member. Note that you can only see Show Posts made in areas you currently have access to.

Messages - clarenceeda

1
Bugs / Re: Chart Random Color not Working
You can achieve that by using custom code and adding field color to your table.
For example you table named status with the ff fields:
id
status
color


then you'll have to make a new file on the controllers folder.
let's name it ChartController with the ff code:

Code: [Select]
<?php


class ChartController  extends BaseController{

function StatusChart(){
$db = $this->GetModel();
$arr = array();
$sqltext = "select count(id) as value, status as label, color from status";
$queryparams = null;
$dataset1 = $db->rawQuery($sqltext, $queryparams);
$arr['labels']=array_map(function($var){ return $var['label']; }, $dataset1);
$arr['colors']=array_map(function($var){ return $var['color']; }, $dataset1);
                $arr['datasets'][] = array_map(function($var){ return $var['value']; }, $dataset1);
return $arr;
}

}

Then you'll have to supply the code above by

Code: [Select]
                           //Custom controller created
                           $cModel= new ChartController();
                           //Get the value of function status chart
                           $chartdata = $cModel->StatusChart();
                           //Supply the return value to the backgroundColor property.
                           backgroundColor:[
                           <?php echo json_encode($chartdata['colors']); ?>,
                            ]


P.S. sorry for my english
3
Blogs / Re: Chart Components
Thank you for you reply. and now. For example, by default i have a table named 'Products' which makes

http://localhost/myshop/#/products

This product page have a pie chart with the dataset
 "select brand as label, count(*) as value from products"

Now, how can I make the pie dynamic if the products have category, i.e we have this page below

http://localhost/myshop/#/products/list/category/mobile

and

http://localhost/myshop/#/products/list/category/tablet

I want  dynamic dataset of the Pie like using the ff sql below

"select brand as label, count(*) as value from products where category = 'mobile' ".

How do i do that? and again, thanks.