我在使用 PHP( fetch_assoc
) 获取的 MySQL 数据库中有多个时间序列。
每个系列的 X 轴相同,但 Y 轴不同。
X 轴:日期时间(POSIX 值)。
Y轴:
air_temperature
dew_point_temperature
sea_level_pressure
wind_direction
wind_speed_rate
sky_condition_total_coverage_code
liquid_precipitation_depth_dimension_one_hr
liquid_precipitation_depth_dimension_six_hr
我需要以特定的 JSON 结构输出这些数据。这是正确最终结果的示例:
{ "firstRow" : { "beginTime" : "2012-10-09 00:00:01",
"endTime" : "2012-10-10 00:00:00",
"tMax" : "56.0",
"tMean" : "52.5",
"tMin" : "49.0"
},
"interval" : "daily",
"lastRow" : { "beginTime" : "2012-10-15 00:00:01",
"endTime" : "2012-10-16 00:00:00",
"tMax" : "72.0",
"tMean" : "64.0",
"tMin" : "56.0"
},
"series" : [ { "color" : "#FFAE28",
"data" : [ [ 1349740801000,
56
],
[ 1349827201000,
60
],
[ 1349913601000,
69
],
[ 1350000001000,
61
],
[ 1350086401000,
57
],
[ 1350172801000,
56
],
[ 1350259201000,
72
]
],
"name" : "Maximum Temperature (ºF)",
"type" : "spline",
"yAxis" : 0,
"zIndex" : 100
},
{ "color" : "#4bf827",
"data" : [ [ 1349740801000,
52.5
],
[ 1349827201000,
56
],
[ 1349913601000,
59
],
[ 1350000001000,
55.5
],
[ 1350086401000,
49.5
],
[ 1350172801000,
49.5
],
[ 1350259201000,
64
]
],
"name" : "Mean Temperature (ºF)",
"type" : "spline",
"yAxis" : 0,
"zIndex" : 100
},
{ "color" : "#2dc1f0",
"data" : [ [ 1349740801000,
49
],
[ 1349827201000,
52
],
[ 1349913601000,
49
],
[ 1350000001000,
50
],
[ 1350086401000,
42
],
[ 1350172801000,
43
],
[ 1350259201000,
56
]
],
"name" : "Minimum Temperature (ºF)",
"type" : "spline",
"yAxis" : 0,
"zIndex" : 100
}
],
"title" : "New York Laguardia Arpt: Daily Temperature",
"xAxis" : { "max" : 1350259201000,
"maxZoom" : 604800000,
"min" : 1349740801000
},
"yAxis" : { "endOnTick" : false,
"gridLineColor" : "#777",
"gridLineWidth" : 1,
"labels" : { "enabled" : true,
"style" : { "color" : "#eee" }
},
"lineWidth" : 0,
"max" : null,
"maxPadding" : 0,
"min" : null,
"opposite" : false,
"startOnTick" : true,
"tickInterval" : null,
"title" : { "style" : { "color" : "#eee" },
"text" : "Degrees (Fahrenheit)"
}
}
}
对此的一些帮助将不胜感激!