Yii Chart

Hello everyone…i just want to ask somethings…i want create chart. but i need to pull data from database and show it in view…anybody can give me any tutorial or solution…please help me…this is my final year project…

Hi, this an example of a pie chart using highchats class:

$this->Widget(‘ext.highcharts.HighchartsWidget’, array(


        'credits' => array('enabled' => FALSE),






        'title' => array('text' => 'Gestion del Programa'),


            'pie'=> array(




















Here´s the extensions link Highcharts

I hope this help you

thanks sanat…but i need show the detail of chart in view and then to pull all data from database…i need coding that can guide me to implement this…please anybody can help me?

Let me try to help you, with an example of a app I’m developing:

First in the controller’s action I’d created this:

public function actionGestiones()


            $model=New Programa;

            $this->gestiones = $model->graficarGestionesClientes();



                                        'gestiones'=>  $this->gestiones,



the code is very simple, i’d inicialized the model and called the method ‘graficarGestionesClientes’ to read and calculated the data from the database, and last send the array ‘gestiones’ to the view.

And in the model I’d the following method:

 public function graficarGestionesClientes()


        $_datos = Yii::app()->db->createCommand()

            ->select('ge.nombre_gestion AS nombre,count(cl.situacion_gestion) AS cantidad')

            ->from(array('tbl_clientes AS cl','tbl_gestiones AS ge'))

            ->where('cl.situacion_gestion = ge.id_gestion')




        return $this->formatearDatos($_datos, 'nombre', 'cantidad');


    public function formatearDatos($_datos,$campo1,$campo2)



        for($i = 0; $i < count($_datos); ++$i)


            $this->datos[]= array($_datos[$i][$campo1],intval($_datos[$i][$campo2]));



        return $this->datos;


In the model, there’s the sql command to read the data and i’d created another method to prepared the data for the insertion in the grafic class.

I hope this help.