I'm using highchart to create chart, the chart take this as argument and to see the full tuple is here: highcharts jsonp
?([
[Date.UTC(2013,5,2),0.7695],
[Date.UTC(2013,5,3),0.7648],
[Date.UTC(2013,5,4),0.7645],
[Date.UTC(2015,5,24),0.8924],
[Date.UTC(2015,5,25),0.8925],
[Date.UTC(2015,5,26),0.8955],
[Date.UTC(2015,5,28),0.9113],
[Date.UTC(2015,5,29),0.8900],
[Date.UTC(2015,5,30),0.8950]
]);
From my PostgreSQL
database using python
I get this result.
([
[datetime.date(2016, 5, 9), 345],
[datetime.date(2016, 5, 8), 453],
[datetime.date(2016, 5, 7), 467],
[datetime.date(2016, 5, 6), 938],
[datetime.date(2016, 5, 5), 393],
[datetime.date(2016, 5, 4), 498],
[datetime.date(2016, 5, 3), 334],
[datetime.date(2016, 5, 2), 849]
])
How to format the results to match the the highcharts argument by converting the datetime.date
to Date.UTC
You should calculate javascript timestamps (time in milliseconds since 01.01.1970) in Python from the dates - server-side.
or
send only dates (eg as strings) and parse it into required JS timestamps in JS - client-side.
Do not send functions - send string (date) or a number (timestamp).
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.