简体   繁体   中英

How to create a chart in PHP using JSON data from SQL query

I have a sql query which creates a pivot table. Now I've have executed this query in PHP using 'multiquery' and have converted it into JSON using 'json_encode'. The JSON data is consists of around 25million records and the format of each record is

{
timestamp: .....;
value 1: .....;
value 2: .....;
value 3: .....;
value 4: .....;
..
..
..
value n: .....;
}

Now I need to create a chart from this. How should I convert the JSON data into dynamic array so as to create a chart. I'm using dygraphs library.

To convert your json to array you can use json_decode with "true" in second parameters: json_decode($json, true);

php doc

您可以使用json_decode()函数将JSON字符串转换为数组

$newArray = json_decode($json_string, TRUE);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM