<div class="box-widget {{ widget.classes }}">
  {% if widget.name %}<h2 class="box-widget-name">{{ widget.name }}</h2>{% endif %}
  <div class="box-widget-content" id="{{ widget.html_id }}"></div>
  {% with chart_url='admin:'|add:widget.url_name %}
    <script>
      $(function () {
        var chart, container = $('#{{ widget.html_id }}');
        $.getJSON("{% url chart_url %}", function(initial_data) {
          container.highcharts(initial_data);
          chart = container.highcharts();
          setInterval(function() {
            $.getJSON("{% url chart_url %}", function(refreshed_data) {
              chart.series.forEach(function(v, i) {
                v.setData(refreshed_data.series[i].data, false);
              });
              chart.redraw();
            });
          }, {{ widget.time_interval }});
        });
      });
    </script>
  {% endwith %}
</div>
