I am currently working on integrating Google Charts and populating it with data from an external JSON file that I have generated using PHP's json_encode() function.
After some effort, I managed to get Google Charts to display data successfully, but for now, I have hardcoded random values for demonstration purposes:
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Time', 'Temperature', 'Humidty'],
['2018-03-09 13:28:49', 1000, 400],
['2018-03-09 13:28:59', 1170, 460],
['2018-03-09 14:28:49', 660, 1120],
['2018-03-09 17:28:49', 1030, 540],
['2018-03-09 13:28:49', 1030, 540]
]);
My ultimate goal is to replace this static data with entries from my JSON file structured like this:
[{"id":"1","temp":"24.40","hum":"28.30","insert_date":"2018-03-09 13:28:49"},{"id":"2","temp":"24.50","hum":"28.60","insert_date":"2018-03-09 13:29:59"}]
The specific fields I want to extract are temperature, humidity, and insertion date. The challenge lies in parsing this data effectively.
I've been grappling with this issue for quite some time without success. Any guidance or suggestions would be greatly appreciated.
Thank you