2013-06-06 33 views
0

我正在經歷這種奇怪的事情。我正在使用HighCharts測試Yii中一個非常簡單的圖表的一些數據。但我似乎無法讓圖表正確顯示。

這裏是插件

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') 
    ) 
) 

));

如果我使用此代碼,則圖表顯示正常。然後,如果我使用$ stat ['total_item_views']和$ stat ['offers']來代替系列數據方面的硬編碼數組,那麼該圖不會顯示任何內容。我已經在頂部測試了變量具有我期望的值,並且它們回聲良好,我還用其他變量(total_item_views &優惠)替換了窗口小部件中的$ stat ['title'],並且它們顯示還好。但是在'數據'數組中,我什麼也得不到。

不知道爲什麼,想知道是否有人可能能夠幫助

感謝

強尼

+0

你能否提供更多細節,例如任何螢火蟲錯誤?控制檯日誌等 – sakhunzai

回答

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

作品對我來說就像魅力。檢查數組結構。這裏是轉儲:

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

另外檢查也許你傳遞字符串,而不是int。

+0

我必須鍵入$ stat ['offers']作爲一個整數,它似乎工作。感謝您的幫助和時間。 – Jonnny