简体   繁体   English

如何使用SQL查询中的JSON数据在PHP中创建图表

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

I have a sql query which creates a pivot table. 我有一个SQL查询,它创建一个数据透视表。 Now I've have executed this query in PHP using 'multiquery' and have converted it into JSON using 'json_encode'. 现在,我已经在PHP中使用“ multiquery”执行了此查询,并已使用“ json_encode”将其转换为JSON。 The JSON data is consists of around 25million records and the format of each record is JSON数据由大约2500万条记录组成,每条记录的格式为

{
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. 我应该如何将JSON数据转换为动态数组以创建图表。 I'm using dygraphs library. 我正在使用dygraphs库。

To convert your json to array you can use json_decode with "true" in second parameters: json_decode($json, true); 要将json转换为数组,可以在第二个参数中使用带“ true”的json_decode:json_decode($ json,true);

php doc PHP文档

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

$newArray = json_decode($json_string, TRUE);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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