5 |
5 |
<script>
|
6 |
6 |
$(function() {
|
7 |
7 |
var extra_context = $('#chart-{{cell.id}}').parents('.cell').data('extra-context');
|
8 |
|
var chart_filters_form = $('#chart-filters');
|
9 |
8 |
$(window).on('combo:refresh-graphs', function() {
|
10 |
|
qs = [];
|
11 |
|
if(chart_filters_form)
|
12 |
|
qs.push(chart_filters_form.serialize());
|
13 |
|
if(extra_context)
|
14 |
|
qs.push('ctx=' + extra_context);
|
15 |
|
if (window.location.search)
|
16 |
|
qs.push(window.location.search.slice(1));
|
17 |
9 |
$.ajax({
|
18 |
|
url : "{% url 'combo-dataviz-graph' cell=cell.id %}?" + qs.join('&'),
|
|
10 |
url : "{% url 'combo-dataviz-graph' cell=cell.id %}" + get_graph_querystring(extra_context),
|
19 |
11 |
type: 'GET',
|
20 |
12 |
success: function(data) {
|
21 |
13 |
$('#chart-{{cell.id}}').html(data);
|
... | ... | |
32 |
24 |
$(function() {
|
33 |
25 |
var last_width = 1;
|
34 |
26 |
var extra_context = $('#chart-{{cell.id}}').parents('.cell').data('extra-context');
|
35 |
|
var chart_filters_form = $('#chart-filters');
|
36 |
27 |
$(window).on('load resize gadjo:sidepage-toggled combo:resize-graphs', function() {
|
37 |
28 |
var chart_cell = $('#chart-{{cell.id}}').parent();
|
38 |
29 |
var new_width = Math.floor($(chart_cell).width());
|
39 |
30 |
var ratio = new_width / last_width;
|
40 |
|
var qs;
|
41 |
|
if (window.location.search) {
|
42 |
|
qs = window.location.search + '&';
|
43 |
|
} else {
|
44 |
|
qs = '?';
|
45 |
|
}
|
46 |
|
qs += 'width=' + new_width
|
47 |
|
if(chart_filters_form)
|
48 |
|
qs += '&' + chart_filters_form.serialize()
|
49 |
|
if(extra_context)
|
50 |
|
qs += '&ctx=' + extra_context
|
51 |
31 |
if (ratio > 1.2 || ratio < 0.8) {
|
52 |
|
$('#chart-{{cell.id}}').attr('src', "{% url 'combo-dataviz-graph' cell=cell.id %}" + qs);
|
|
32 |
$('#chart-{{cell.id}}').attr('src', "{% url 'combo-dataviz-graph' cell=cell.id %}" + get_graph_querystring(extra_context, new_width));
|
53 |
33 |
last_width = new_width;
|
54 |
34 |
}
|
55 |
35 |
}).trigger('combo:resize-graphs');
|
56 |
36 |
$(window).on('combo:refresh-graphs', function() {
|
57 |
|
var qs;
|
58 |
|
if (window.location.search) {
|
59 |
|
qs = window.location.search + '&';
|
60 |
|
} else {
|
61 |
|
qs = '?';
|
62 |
|
}
|
63 |
|
qs += 'width=' + last_width
|
64 |
|
if(chart_filters_form)
|
65 |
|
qs += '&' + chart_filters_form.serialize()
|
66 |
|
if(extra_context)
|
67 |
|
qs += '&ctx=' + extra_context
|
68 |
|
$('#chart-{{cell.id}}').attr('src', "{% url 'combo-dataviz-graph' cell=cell.id %}" + qs);
|
|
37 |
$('#chart-{{cell.id}}').attr('src', "{% url 'combo-dataviz-graph' cell=cell.id %}" + get_graph_querystring(extra_context, last_width));
|
69 |
38 |
});
|
70 |
39 |
});
|
71 |
40 |
</script>
|
72 |
|
-
|