Jonnny
Jonnny

Reputation: 5039

Yii HighCharts not displaying from $vars but display when hardcoded

I'm experiencing this strange thing. I'm testing some data for a really simple chart in Yii using HighCharts. But I can't seem to get the chart to display properly.

Here is the widget

echo 'Views - '.$stat['total_item_views']; // Displays 0
echo '<br />Offers - ' . $stat['offers']; // Displays 1

$this->widget('bootstrap.widgets.TbHighCharts', array(
 'options'=>array(
 'chart' => array(
    'type' => 'column'
    ),
    /*'theme' => 'gray',*/
    'title' => array('text' => $stat['title']),
    'xAxis' => array(
        'title' => 'Totals to Date',
        'categories' => array(
            'Totals',
        ),
    ),
    'yAxis' => array(
       array('title' => array('text' => 'Offers')),
       array('title' => array('text' => 'Views'), 'opposite' => true),  

    ),
    'tooltip' => array(
        'shared' =>true,
    ),
    'series' => array(
       array('name' => 'Views', 'data' => array(0), 'type' => 'column', 'color' => '#8CBD0F'),
       array('name' => 'Offers', 'data' => array(1), 'type' => 'column', 'color' => '#2AA2CC')
    )
 )

));

If I use this code then the chart displays fine. If I then use $stat['total_item_views'] and $stat['offers'] for instance in place of the hard coded arrays in the data aspect of the series then the graph shows nothing. I've tested at the top that the variables have the values that I expect and they echo out fine, I've also replaced the $stat['title'] inside the widget with both other variables (total_item_views & offers) and they display there fine. But inside the 'data' array I get nothing.

Not sure why, wondered if anyone may be able to help

Thanks

Jonny

Upvotes: 0

Views: 938

Answers (1)

ineersa
ineersa

Reputation: 3435

array('name'=> 'Failed records',
                'data'=> $rec_data_bad,
                'color' => '#ff0000',
                'shadow'=> false
            ),

Works like a charm for me. Check array structure. Here is dump:

array(6) { [0]=> int(0) [1]=> int(0) [2]=> int(86) [3]=> int(15) [4]=> int(0) [5]=> int(0) }

Also check maybe you pass string instead of int.

Upvotes: 1

Related Questions