gpt4 book ai didi

javascript - Django-Chartit 'source' 必须是查询集、模型或管理器

转载 作者:太空狗 更新时间:2023-10-30 02:48:58 25 4
gpt4 key购买 nike

我正在使用 Django-Chartit创建图表。
试图关注this例子。
我的问题是我想使用不是来自模型的数据所以我尝试了这段代码

data = \
DataPool(
series=
[{'options': {
'source': [1,2,3,4,5,6,7,8,9,10]},
'terms': [
'month',
'houston_temp',
'boston_temp']}
])
chart = Chart(
datasource = data,
series_options =
[{'options':{
'type': 'line',
'stacking': False},
'terms':{
'month': [
'boston_temp',
'houston_temp']
}}],
chart_options =
{'title': {'text': 'Weather Data of Boston and Houston'},
'xAxis': {'title': {'text': 'Month number'}
}})

我收到一条错误消息

'source' must either be a QuerySet, Model or Manager. Got [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] of type instead.

我认为我无法从列表中创建查询集。任何的想法 ?

最佳答案

看起来 Django-Chartit 真的是用来用模型制作图表的。注意标记行:

Create charts from your Django models effortlessly

如果有特定原因您不能使用模型,我会考虑使用单独的网络图表工具 such as Flot .它是纯 JavaScript,因此您需要将数据发送到客户端才能制作图表。

关于javascript - Django-Chartit 'source' 必须是查询集、模型或管理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10471465/

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