为什么Chartkick说加载而不显示数据?

时间:2019-03-02 12:59:02

标签: django django-templates django-views chartkick

我正在尝试使用{em> chartkick 通过遵循this来可视化模板上的数据。但是,它显示“正在加载”,并且不会显示。问题的原因是什么?我有想念吗?请查看下面的代码。

view.py

def analyticView(request):
    template = 'survivors/analysis.html'

    exchange = {'2001-01-31': 1.064, '2002-01-31': 1.1305,
                '2003-01-31': 0.9417, '2004-01-31': 0.7937,
                '2005-01-31': 0.7609, '2006-01-31': 0.827,
                '2007-01-31': 0.7692, '2008-01-31': 0.6801,
                '2009-01-31': 0.7491, '2010-01-31': 0.7002,
                '2011-01-31': 0.7489, '2012-01-31': 0.7755,
                '2013-01-31': 0.7531,
                }

    browser_stats = [['Chrome', 52.9], ['Firefox', 27.7], ['Opera', 1.6],
                     ['Internet Explorer', 12.6], ['Safari', 4]]

    sizes = [['X-Small', 5], ['Small', 27], ['Medium', 10],
             ['Large', 14], ['X-Large', 10]]

    areas = {'2013-07-27 07:08:00 UTC': 4, '2013-07-27 07:09:00 UTC': 3,
             '2013-07-27 07:10:00 UTC': 2, '2013-07-27 07:04:00 UTC': 2,
             '2013-07-27 07:02:00 UTC': 3, '2013-07-27 07:00:00 UTC': 2,
             '2013-07-27 07:06:00 UTC': 1, '2013-07-27 07:01:00 UTC': 5,
             '2013-07-27 07:05:00 UTC': 5, '2013-07-27 07:03:00 UTC': 3,
             '2013-07-27 07:07:00 UTC': 3}
    return render(request, template, locals())

analytic.html

{% extends 'survivors/base.html' %}
{% load chartkick %}

    {% block content %}
        {% line_chart exchange with min=0.4 id='rates' %}
        {% pie_chart browser_stats with library={"title":"Browser Statistics, May 2013"} %}
        {% column_chart browser_stats %}

        {% bar_chart sizes with id='sizes' %}
        {% area_chart areas with id='areas' %}
    {% endblock %}

base.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
        <script src="http://www.google.com/jsapi"></script>
        <script src="https://www.chartkick.com/chartkick.js"></script>

</head>
<body>
    {% block content %}

    {% endblock content %}
</body>
</html>

0 个答案:

没有答案