Chartjs-Can't get data into my Javascript function using Django

0๐Ÿ‘

โœ…

Hi in your javascript code there was a misspelling.

{% for key, value in data.itmes %} must be
{% for key, value in data.items %}

$(document).ready(function() {
    {% for key, value in data.items %}
        {% if "DHT" in key %}
            buildDHTChart('#chart_{{ key }}',
                  [{{ time|join:"\",\""}}],
                  [{{ value.humidity.values|join:"," }}],
                  [{{ value.temperature.values|join:"," }}]);
        {% elif "ds18b20" in key %}
            buildds18b20Chart('#chart_{{ key }}',
                  ["{{ time|join:"\",\""}}"],
                  [{{ value.temperature.values|join:"," }}]);
        {% endif %}

    {% endfor %}
});

Leave a comment