Formatting multidimensional arrays in PHP for charting -


i beginner @ php , struggling graph data filemaker database. because filemaker not support sql has own php api, cannot use sql language group , subtotal data etc.

i trying graph aggregate numbers on sales peoples activities on dashboard in realtime, using possibly highchart or similar. main problem not sure how should data php suitable format charting package.

i want make sorted stacked bar chart out of this, showing total number of activities each user. want make dynamic can poll database , handle number of sales people , number of different activities.

i have built , populated php array looking (multidimensional array usernames , activity names , count):

array ( [fremin] => array ( [sent letter/email] => 2 [booked meeting] => 0 [call] => 0 [call na/lv] => 0 [walkby] => 0 ) [heleli] => array ( [sent letter/email] => 4 [booked meeting] => 1 [call] => 7 [call na/lv] => 13 [walkby] => 2 ) )

and json_encode gives this: "fremin":{"sent letter/email":2,"booked meeting":0,"call":0,"call na/lv":0,"walkby":0},"heleli":{"sent letter/email":4,"booked meeting":1,"call":7,"call na/lv":13,"walkby":2}}

but need highcharts: {name: "sent letter/email", data: [2, 4]}, {name: "booked meeting", data: [0,1]}, {name: "call", data: [0, 7]}, {name: "call na/lv", data: [0,13]}, {name: "walkby", data: [0,2]}

how can rearrange data in php?


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -