我使用django-charit使用Highcharts时遇到问题。 到目前为止,这是我的代码:
#creating chart
ds = DataPool(
series=
[{'options': {
'source': DataForecast.objects.all().order_by('id')},
'terms': [
'date_time',
'wl_observed_m',
'wl_forecasted_m']}
])
cht = Chart(
datasource=ds,
series_options=
[{'options': {
'type': 'line',
'stacking': False},
'terms': {
'date_time': [
'wl_observed_m',
'wl_forecasted_m']
}}],
chart_options=
{'title': {
'text': 'Forecast for January 19, 2014 2:00 PM'},
'xAxis': {
'title': {
'text': 'Date & Time'}},
'yAxis': {
'title': {
'text': 'Water Level, m.'}},
'credits': {
'enabled': False}})
输出是这样的:
那么,我该如何更改标签(环绕)?并对x轴进行排序。我通过查询尝试了它但没有成功。
答案 0 :(得分:3)
排序:
DataForecast.objects.all().order_by('id')
使用.latest()
或.order_by('-date')
或日期字段(您打印到图表的那个)而不是ID进行排序查询。