projects_stats.html 2.78 KB
{% extends "base_page.html" %}
{% block more_heads %}
<link href="{{ url_for('main.static', filename='css/charges.css', version=config.VERSION) }}" rel="stylesheet"
  type="text/css" />
{% endblock %}

{% block content %}

<!-- Invisible span to definte wich ul and a in the navbar are actived -->
<span id="nav_actived" style="display: none">project,projects_stats</span>

<h3 class="sub-header">Charge pour tous les projets</h3>
<div class="charge_chart" id="projects_stats_chart"></div>

{% for c in categories %}
<h3 class="sub-header">Charge pour la catégorie {{ c.name }}</h3>
<div class="charge_chart" id="labels_stats_chart_{{ c.id }}"></div>
{% endfor %}

{% endblock %}

{% block more_scripts %}
{% include 'hg-includes.html' %}
{#  {% include 'd3js-includes.html' %}#}
{% include 'charges-includes.html' %}

<script>
  document.addEventListener("DOMContentLoaded", function () {
    //def rest_projects_stats(any_format='csv'):
    var url = "{{url_for('main.rest_projects_stats', any_format='json_hs')}}";
    $.getJSON(url, function (data) {
      var options = {
        chart: {
          renderTo: 'projects_stats_chart',
          type: 'streamgraph'
        },
        title: {
          text: 'Charge pour tous les projets'
        },
        subtitle: {
          text: '{{ categories.name }}'
        },
        xAxis: {
          title: {
            text: 'Semestre'
          },
          type: 'category',
        },
        yAxis: {
          title: {
            text: 'Charge (ETP)'
          }
        },
        tooltip: {
          pointFormat: '{series.name}: <b>{point.y} ETP </b>'
        },
        series: [],
        plotOptions: {
          column: {
            stacking: 'normal'
          }
        }
      };

      options.series = data;
      var chart = new Highcharts.Chart(options);
    });

    {% for c in categories %}

    var url = "{{url_for('main.rest_labels_stats', category_id=c.id, any_format='json_hs')}}";
    $.getJSON(url, function (data) {

      var options = {
        chart: {
          renderTo: 'labels_stats_chart_{{c.id}}',
          type: 'streamgraph'
        },
        title: {
          text: 'Charge pour la catégorie {{c.name}}'
        },
        subtitle: {
          text: '{{ c.name }}'
        },
        xAxis: {
          title: {
            text: 'Semestre'
          },
          type: 'category',
        },
        yAxis: {
          title: {
            text: 'Charge (ETP)'
          }
        },
        tooltip: {
          pointFormat: '{series.name}: <b>{point.y} ETP </b>'
        },
        series: [],
        plotOptions: {
          column: {
            stacking: 'normal'
          }
        }
      };

      options.series = data;
      var chart = new Highcharts.Chart(options);
    });

    {% endfor %}


  });



</script>
{% endblock %}