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

标签 javascript python django highcharts

我正在使用 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/

相关文章:

python - django-admin.py startproject 不工作

javascript - 回文检查器问题

python - 使用 Python 和 PyMongo 从所有 MongoDB 文档中删除属性

python - 为什么读取整个文件占用的 RAM 多于其在磁盘上的大小?

python - 我如何创建 turtle 克隆并将它们附加到列表中?

javascript - 使用jquery ajax跨域检索json数据

javascript - 将元素放入无法删除的 ContentEditable div

javascript - JQuery 获取仅带有 # 的链接

java - 使用 Kivy 或 CLI 获取我的位置?

python - Django 中的 OneToOne、ManyToMany 和 ForeignKey 字段有什么区别?