サーバーから JSON オブジェクトの正しい配列を取得し、それをシリーズに割り当てています。chart_cfd.series もデバッガーで正しいオブジェクトを表示しますが、チャートのプロットは行われません。
ここで何が問題になる可能性がありますか? 配列メンバーのタイプを変更する必要がありますか?
注: javascript でローカルに系列データを提供すると、グラフは完全に入力されます (単純な列タイプ)
Javascript:( ハイチャート フレームワークを使用しています)
//series = [] チャート オブジェクト内
function requestCFDStatusData(){
$.post(
'ajax/cfdUtil/cfd_status.php',
function(response){
chart_cfd.series = response;
});
}
PHPコード
<?php
header("Content-type: text/json");
$cfdData = array(
array(
'name' => 'A',
'data' => array(49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4,22,34,23,11)),
array(
'name' => 'B',
'data' => array(83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3,22,50,34,11)),
array(
'name' => 'C',
'data' => array(48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,100,25,45,42)),
array(
'name' => 'D',
'data' => array(42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1,32,33,46,54)),
array(
'name' => 'E',
'data' => array(48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,12,12,44,50)),
array(
'name' => 'F',
'data' => array(48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,12,12,44,50)),
array(
'name' => 'G',
'data' => array(48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,12,12,44,50)),
array(
'name' => 'H',
'data' => array(48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,12,12,44,50)),
array(
'name' => 'I',
'data' => array(48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,12,12,44,50)),
array(
'name' => 'J',
'data' => array(48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,12,12,44,50)),
array(
'name' => 'K',
'data' => array(48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,12,12,44,50))
);
$jsonEncoded = json_encode($cfdData);
echo $jsonEncoded;
?>
注:JavaScriptでローカルに提供すると、次のデータは正常に機能します
series: [{
name: 'A',
data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4,22,34,23,11]
}, {
name: 'B',
data: [83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3,22,50,34,11]
}, {
name: 'C',
data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,100,25,45,42]
}, {
name: 'D',
data: [42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1,32,33,46,54]
},{
name: 'E',
data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,12,12,44,50]
},{
name: 'F',
data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,12,12,44,50]
},{
name: 'G',
data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,12,12,44,50]
},{
name: 'H',
data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,12,12,44,50]
},{
name: 'I',
data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,12,12,44,50]
},{
name: 'J',
data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,12,12,44,50]
},{
name: 'K',
data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2,12,12,44,50]
}]