2017-02-13 51 views
0
Array 
(
    [0] => Array 
     (
      [month] => oct 
      [value] => 10 
      [state] => MU 
     ) 

    [1] => Array 
     (
      [month] => nov 
      [value] => 29 
      [state] => MU 
     ) 

    [2] => Array 
     (
      [month] => oct 
      [value] => 88 
      [state] => DL 
     ) 

    [3] => Array 
     (
      [month] => nov 
      [value] => 67 
      [state] => DL 
     ) 

    ) 

上面是我的php mysql響應。php繪圖系列for highchart熱圖

對於highchart熱圖月是在x軸上繪圖並且狀態是在y軸上繪圖。

我對如何映射一系列熱圖的值有疑問。 看到熱圖繪製系列一樣[0,0,10],[0,1,29]等.... 見下面的鏈接

http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/heatmap/

我必須使用PHP繪製系列。

回答

0

嘗試下面的示例代碼:

<?php 
$states = ['DL','BL','MU','OU']; 
$data_array = [['month' => 'oct', 'value' => 10, 'state' => 'MU'],['month' => 'jan', 'value' => 12, 'state' => 'OU']]; 

$graph_array = []; 
foreach ($data_array as $data){ 
    $state = array_search($data['state'], $states); 
    $month = date('n',strtotime($data['month'])); 
    $graph_array[] = [$state,$month,$data['value']]; 
} 

print_r($graph_array);