Chart / Gridview

Strange deal, if you look at the images provided, the grid view shows county and polecount but if you look at the chart (see attached image) you will see under categories it is 0 1 2 etc… instead of LOS ANGELES COUNTY, ORANGE COUNTY etc…

Below is the code for the widget.

Any help would be great.


<?php








 $query = "SELECT ownership.id,COUNT( deviations.id ) as polecount , counties.name as county

FROM  `ownership` , counties, deviations

WHERE ownership.county_id = counties.id

AND ownership.id = deviations.pole_id

AND deviations.commondeviation_id <>1

AND deviations.inspection_date between DATE_FORMAT(NOW() ,'%Y-01-01') AND NOW()

GROUP BY counties.name";

$count=Yii::app()->db->createCommand($query)->queryScalar();

$dataProvider = new CSqlDataProvider($query, array(

         'totalItemCount'=>$count,

		 

		 

		 

		 ));


$model = new Ownership;


$newDataProvider=$model->newsearch();


$this->widget('bootstrap.widgets.TbExtendedGridView', array(

    //'filter'=>$model,

    'type'=>'striped bordered',

    'dataProvider' => $dataProvider,

    'template' => "{items}\n{extendedSummary}",

     'columns' => array( 

	 		'polecount',

	 		'county'

	 ),

    'chartOptions' => array(

		'defaultView' => true,

		'data' => array(

			'series' => array(

				array(

					'name' => 'Poles',

					'attribute' => 'polecount'

				)

			),

			'xAxis' => array(

				'categories' => 'county'),

			),

			

		),

		'config' => array(

			'chart' => array(

				// 'width' => '800' // default reflow

			)

		),

	),

));





?>

Same result with:


public function mysearch() {

	

		$criteria=new CDbCriteria;

		$criteria->select = 'COUNT(deviations.id) as polecount , counties.name AS bycounty';


    	$criteria->with = array('counties', 'deviations');

		$criteria->condition = "deviations.commondeviation_id <>1

								AND deviations.inspection_date between DATE_FORMAT(NOW() ,'%Y-01-01') AND NOW()";

		$criteria->compare('deviations.pole_id',$this->id);

		$criteria->compare('counties.id',$this->county_id);

    	$criteria->group = 'counties.name';

		$criteria->together = true;

    return new CActiveDataProvider($this, array(

		

        'criteria' => $criteria,

        'pagination' => array(

            'pageSize' => 10,

			

        ),

		

    ));

	

	}