gpt4 book ai didi

javascript - 使用 Django-chartit 更改 Highcharts 标签和排序 x 轴

转载 作者:行者123 更新时间:2023-11-28 16:34:08 25 4
gpt4 key购买 nike

我在使用 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}})

输出是这样的: enter image description here

那么,我该如何更改标签(圈出)?并对 x 轴进行排序。我通过查询尝试了但没有成功。

最佳答案

排序:DataForecast.objects.all().order_by('id')使用 .latest().order_by('-date') 或按日期字段(您打印到图表的日期字段)而不是 id 对查询进行排序。

关于javascript - 使用 Django-chartit 更改 Highcharts 标签和排序 x 轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28854118/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com