public function actionAmChart()
{
$dataProvider = new CActiveDataProvider('OlimpicMedals');
$dataProvider = $dataProvider->getData();
$this->render('AmChart',array('dataProvider'=>$dataProvider));
}
view
$this->widget(‘ext.amcharts.EAmChartWidget’,
array(
'width' => 700, // width of the Chart
'height' => 400, // height of the chart
'chart'=>array(// collections of grpah to display into the chart
'dataProvider'=>$dataProvider, // DataProvider
'categoryField' => 'value' // Field of the DataProvider to set on the X Axis
),
'graphs'=>array(
array(
'valueField' => '1', // Field of the DataProvider to set the Y Axis
'title'=>'Value', // Title of the , used on the Legend
'type' => 'bar' // Type of Graph
),
array(
'valueField' => 'SilverMedals',
'title'=>'Value',
'type' => 'line',
'fillColors'=>'Transparent',
'fillAlphas'=>'0',
'lineColor'=>'#EE2299',
'bullet'=>'round'
)),
'categoryAxis'=>array(
'title'=>'Species Name'
),
'valueAxis'=>array(
'title'=>'Identifier')
));
Hi again, i made some changes now you can use any dataProvider that use CActiveDataProvider or IDataProvider
Download the 1.1 Verison from here.
now you don’t need to send the $dataProvider->getData(), simply send the $dataProvider
Example using your table model:
<?php
// CONTROLLER
/**
*Using a CActiveDataProvider
**/
//$dataProvider = new CActiveDataProvider('ChartData');
/**
*Using a CArrayDataProvider
**/
//SQL Query
$oDbConnection = Yii::app()->db; // Getting database connection (config/main.php has to set up database
// Here you will use your complex sql query using a string or other yii ways to create your query
$oCommand = $oDbConnection->createCommand('SELECT * FROM chart_data');
$oCDbDataReader = $oCommand->queryAll(); // Run query and get all results in a CDbDataReader
// Set DataProvider
$dataProvider=new CArrayDataProvider($oCDbDataReader, array(
'keyField' => 'ID'
));
$this->render('AmChart',array('dataProvider'=>$dataProvider));
//VIEW
$this->widget('ext.amcharts.EAmChartWidget',
array(
'width' => 700,
'height' => 400,
'chart'=>array(
'dataProvider'=>$dataProvider,
'categoryField' => 'time'
),
'chartType' => "AmSerialChart",
'graphs'=>array(
array(
'valueField' => 'data',
'title'=>'Data graph',
'type' => 'column'
)),
'categoryAxis'=>array(
'title'=>'Time'
),
'valueAxis'=>array(
'title'=>'Data')
));
?>
Thanks a lot for your questions, there are very helpful to improve the widget
Hi again, some things like SCROLLBAR & CURSOR are not tested yet, in theory you can do it, i don’t have enough time to release the solution, in the next months i’m going to make same improvements on the widget