Hi
I use the Flot extension (http://www.yiiframework.com/extension/flot/) for my current project. I would like to draw dynamic values from the database. The table have 2 columns with 800 rows.
My view shows a chart with all values. But i would like to dynamically choose the columns of the database. If checked „checkbox1“, it should draw the chart with only column1/value1.
model
public function getGraphData()
{
$criteria=new CDbCriteria;
$sort = new CSort();
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'sort'=>$sort,
'pagination'=>false,
));
}
view
<?php
foreach($model->getGraphData()->getData() as $row) {
$data[]=array($row['ID'],$row['value1']);
$data2[]=array($row['ID'],$row['value2']);
};
$this->widget('application.extensions.EFlot.EFlotGraphWidget',
array(
'data'=>array(
array(
'label'=> 'value1',
'data'=>$data,
'lines'=>array('show'=>true),
'points'=>array('show'=>true),
),
array(
'label'=> 'value2',
'data'=>$data2,
'lines'=>array('show'=>true),
'points'=>array('show'=>true),
),
),
'options'=>array(
'legend'=>array(
'position'=>'nw',
'show'=>true,
'margin'=>10,
'backgroundOpacity'=> 0.5
),
),
'htmlOptions'=>array(
'style'=>'width:800px;height:400px;'
)
)
);
?>
Can someone help me?