Django-Chartit'source'必须是QuerySet,Model或Manager [英] Django-Chartit 'source' must either be a QuerySet, Model or Manager
问题描述
我正在使用 Django-Chartit 创建图表。
尝试关注这个示例。
我的问题是我想要使用不是模型
的数据,所以我试过这个代码
I am using Django-Chartit to create a chart.
Trying to follow this example.
my problem is that i want to use data not from a model
so i tried this code
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'必须是QuerySet,Model或Manager。取而代之的是[1,2,3,4,5,6,7,8,9,10]。
'source' must either be a QuerySet, Model or Manager. Got [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] of type instead.
不要以为我可以从列表中创建一个QuerySet。
任何想法?
I dont think i can create a QuerySet from a list. Any idea ?
推荐答案
看起来Django-Chartit真的是为了使图表脱离模型。注意标签行:
It looks like Django-Chartit is really meant for making charts out of models. Notice the tag line:
Create charts from your Django models effortlessly
如果有一个特定的原因,您不能使用模型,我将研究使用单独的网页图表工具如Flot 。它是纯JavaScript,所以您需要将数据发送到客户端,以便制作图表。
If there is a specific reason you can't use a model, I would look into using a separate web charts tool such as Flot. It's pure JavaScript, so you would need to send your data to the client-side in order to make charts.
这篇关于Django-Chartit'source'必须是QuerySet,Model或Manager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!