
{% for table in visualization %}
    <h2>{{ table.table_title }}</h2>

	<a href="#" target="none" class="button bijoe-png-button">PNG</a>
        <div class="graph">
          <canvas id="canvas-{{ forloop.counter }}"></canvas>
        </div>
	<script>
	  $(function () {
         {{ table.javascript }}
         setTimeout(function () {
             var canvas = $('#canvas-{{ forloop.counter }}')[0];
             if (measure.name == "percent") {
               draw_piechart(canvas, drilldown, [measure], measure.name, data);
             } else {
               draw_barchart(canvas, drilldown, [measure], measure.name, data);
               /* Allow getting a PNG without using 'Save image as' */
               $(".bijoe-png-button").on('click', function() {
                  this.href = toDataURL($(this).next("canvas")[0], "graph.png");
               })
            }
         }, 500 * {{ forloop.counter }});
	  });
	</script>
{% endfor %}
