combo/combo/apps/dataviz/templates/combo/chartngcell.html

27 lines
843 B
HTML

{% load i18n %}
{% if cell.title %}<h2>{{cell.title}}</h2>{% endif %}
{% if not cell.cached_json %}
<div class="warningnotice">{% trans "Unavailable data." %}</div>
{% elif cell.chart_type == "table" %}
{{table|safe}}
{% else %}
<div style="min-height: {{cell.height}}px">
<embed id="chart-{{cell.id}}" type="image/svg+xml" style="width: 100%"/>
</div>
<script>
$(function() {
var last_width = 1;
$(window).on('load resize gadjo:sidepage-toggled', function() {
var chart_cell = $('#chart-{{cell.id}}').parent();
var new_width = Math.floor($(chart_cell).width());
var ratio = new_width / last_width;
if (ratio > 1.2 || ratio < 0.8) {
$('#chart-{{cell.id}}').attr('src',
"{% url 'combo-dataviz-graph' cell=cell.id %}?width=" + new_width);
last_width = new_width;
}
});
});
</script>
{% endif %}