使用php mysql动态生成Highcharts中的分组类别

时间:2013-08-23 13:14:24

标签: php multidimensional-array

我真的坚持了这个从1周开始,任何人都可以帮我创建一个数组,用数据库动态创建一个分组类别在Highcharts中动态使用php.Here是一个表的例子

<pre><code>
   +-------+---------------+---------------------------+
   |BATCH  |   CATEGORY    |         GENDER            |
   +-------+---------------+---------------------------+
   | 2012  |    General    |   Male                    |
   | 2012  |    Test       |   Female                  |
   | 2013  |    General    |   Female                  |
   | 2013  |    Test       |   Male                    |
   +-------+---------------+---------------------------+
   </code></pre>

我希望这个表格的结构如下

 <pre><code>
   Array ( [0] => 
            Array ( [name] => 2012 
                    [categories] => 
                    Array ( [0] => Array ( [name] => General 
                                           [categories] => Array ([0] => Male )) 
                            [1] => Array ( [name] => Test 
                                           [categories] => Array ([0] => Female )))) 
        [1] => 
            Array ( [name] => 2013 
                    [categories] => 
                    Array ( [0] => Array ( [name] => General 
                                           [categories] => Array ([0] => Female )) 
                            [1] => Array ( [name] => Test 
                                           [categories] => Array ([0] => Male )))) 
        )
   </code></pre>

请帮助我.......

1 个答案:

答案 0 :(得分:1)

为highcharts添加grouped categories插件,然后为图表创建一个javascript助手。