modified MultipleChartViews to instantiate only one chart.

added chart on index view
This commit is contained in:
artus40
2017-08-19 18:00:49 +02:00
parent 6d2ce7d7bc
commit 0bf2d9ff79
9 changed files with 319 additions and 301 deletions

View File

@@ -3,5 +3,6 @@
<h4>Période</h4>
<form action="" method="get">
{% bootstrap_form form layout="inline" %}
<input type="hidden" name="graph" value="{{active}}" />
{% bootstrap_button "Ok" button_type="submit" %}
</form>

View File

@@ -1,2 +1,4 @@
<div class="text-center">
<div id="{{ chart.get_html_id }}" style="width: {{ chart.width }}px; height: {{ chart.height }}px;"></div>
<a class="btn btn-sm btn-default" href="#" id="image-{{ chart.get_html_id }}"><span class="glyphicon glyphicon-save-file"></span> Télécharger l'image</a>
</div>

View File

@@ -6,6 +6,7 @@
{% block sidebar %}
{{ block.super }}
<hr />
<div class="panel panel-primary">
<div class="panel-body text-right">
{% include "statistiques/filter_form.html" %}
@@ -19,22 +20,5 @@
{% endblock %}
{% block page_content %}
<div class="col-lg-8 text-right">
<h3 class="page-header">Données générales</h3>
<table class="table table-bordered">
<tr><th>...</th><th>Maraudes</th><th>Nombre de rencontres <span class="badge">moyenne par maraude</span></th><th>Personnes</th></tr>
<tr><th>Total</th><td>{{nbr_maraudes}}</td><td>{{nbr_rencontres}} <span class="badge">{{nbr_rencontres_moyenne }}</span></td><td>{{nbr_sujets}}</td></tr>
<tr><th>Soirée</th><td>{{nbr_maraudes_nuit}}</td><td>{{nbr_rencontres_nuit}} <span class="badge">{{nbr_rencontres_nuit_moyenne }}</span></td><td>{{nbr_sujets_nuit}}</td></tr>
<tr><th>Journée</th><td>{{nbr_maraudes_jour}}</td><td>{{nbr_rencontres_jour}} <span class="badge">{{nbr_rencontres_jour_moyenne }}</span></td><td>{{nbr_sujets_jour}}</td></tr>
</table>
</div>
<div class="col-lg-4">
<div class="alert alert-info">
<p>Voici les données permettant une analyse statistiques des maraudes.</p>
<p>Vous pouvez sélectionner une période particulière ou l'ensemble des données</p>
<p>Les données sont réparties en trois catégories, accessibles par le menu sur la gauche</p>
</div>
</div>
{{ chart.as_html }}
{% endblock %}

View File

@@ -1,19 +1,18 @@
{% load navbar %}
<ul class="nav nav-pills nav-stacked text-right">
<li role="presentation" {% active namespace="statistiques" viewname="index" %}>
<a href="{% url "statistiques:index" %}?year={{year|default:0}}{% if month %}&month={{month}}{% endif %}">Maraudes&nbsp;
<a href="{% url "statistiques:index" %}?period={{year|default:0}}">Maraudes&nbsp;
<span class="glyphicon glyphicon-road"></span>
</a>
</li>
<li role="presentation" {% active namespace="statistiques" viewname="pies" %}>
<a href="{% url "statistiques:pies" %}?year={{year|default:0}}{% if month %}&month={{month}}{% endif %}">Typologie&nbsp;
<li role="presentation" {% active namespace="statistiques" viewname="typologie" %}>
<a href="{% url "statistiques:typologie" %}?period={{year|default:0}}">Typologie&nbsp;
<span class="glyphicon glyphicon-user"></span>
</a>
</li>
<li role="presentation" {% active namespace="statistiques" viewname="frequentation" %}>
<a href="{% url "statistiques:frequentation" %}?year={{year|default:0}}{% if month %}&month={{month}}{% endif %}">Fréquentation&nbsp;
<a href="{% url "statistiques:frequentation" %}?period={{year|default:0}}">Fréquentation&nbsp;
<span class="glyphicon glyphicon-stats"></span>
</a>
</li>
</ul>
<hr />

View File

@@ -2,42 +2,37 @@
{% block title %}{{block.super}} {{page_title}}{% endblock %}
{% block breadcrumbs %}{{block.super}}<li>{{page_title}}</li>{% endblock %}
{% block breadcrumbs %}
{{block.super}}
<li>{{page_title}}</li>
{% if active %}<li>{{active}}</li>{% endif %}
{% endblock %}
{% block sidebar %}
{{ block.super }}
{% if chart %}
<hr />
<div class="panel panel-primary">
<div class="panel-body text-right">
{% include "statistiques/filter_form.html" %}
{% include "statistiques/filter_form.html" with active=active %}
<hr />
<p>Échantillon : {{ queryset_count }} objets</p>
</div>
</div>
{% endif %}
{% endblock %}
{% block page_content %}
<script type="text/javascript">
function hideAll() {
{% for _, graph in graphs %}{% with graph.get_html_id as id %}
$("#tab-{{id}}").attr("class", "");
$("#wrapper-{{id}}").hide();
{% endwith %}{% endfor %}
}
function showGraph(id) {
hideAll();
$("#tab-" + id).attr("class", "active");
$("#wrapper-" + id).show();
}
</script>
<ul class="nav nav-tabs">
{% for title, graph in graphs %}<li role="presentation" id="tab-{{graph.get_html_id}}"><a href="#" onclick="showGraph('{{graph.get_html_id}}');">{{ title }}</a></li>{% endfor %}
<ul class="nav nav-pills nav-justified">
{% for name in chart_list %}
<li role="presentation" {%if name == active%} class="active" {%endif%}>
<a href="?graph={{name}}&period={{year}}">{{ name }}</a>
</li>
{% endfor %}
</ul>
{% for title, graph in graphs %}
<div class="row text-center" id="wrapper-{{ graph.get_html_id}}">
{{ graph.as_html }}
</div>
{% endfor %}
{% if chart %}
{{ chart.as_html }}
{% endif %}
{% endblock %}