$(document).ready(function(){ // Déclaration des variables //sélecteurs var $selection_rp = $('#selection_rp'), $selection_ws = $('#selection_ws'), $selection_periode = $('#periode'), $graph=$('#graphiques'), $selection_date = $('#date'), //définition des variables récupérant les valeurs des input et select periode=''; // Paramétrage du cache en false $.ajaxSetup({cache: false}); $selection_date.hide(); //Fonction pour supprimer les doublons dans un array function removeDuplicates(num) { let x; const len=num.length; const out=[]; const obj={}; for (x=0; x'+jour+''); // Ajoute les options à la liste "date" }); // Création de la liste des RP en fonction de la date $selection_date.on('change',function(){ $graph.empty(); $selection_rp.empty(); $selection_rp.append(''); $selection_ws.empty(); $selection_ws.append(''); date_value=$('#date option:selected').text(); $.each(rp_stats[date_value],function(reverse_proxy){ // console.log(reverse_prowy); $selection_rp.append(''); }); // console.log(date_value); }); //Création de la liste des webservices en fonction du RP $selection_rp.on('change',function(){ $graph.empty(); $selection_ws.empty(); $selection_ws.append(''); rp_value=$('#selection_rp option:selected').text(); $.each(rp_stats[date_value][rp_value],function (webservices){ // console.log(webservices); $selection_ws.append(''); console }); }); $selection_ws.on('change',function (){ var labels_ws=[], data_ws =[], colors=['#01DF01','#DF0101','#BF00FF','#08088A','#000000','#F4FA58']; ws_value=$('#selection_ws option:selected').text(); $graph.empty(); if (date_value != "All"){ $graph.append('
'); $.each(rp_stats[date_value][rp_value][ws_value],function(code_apache){ labels_ws.push(code_apache); data_ws.push(rp_stats[date_value][rp_value][ws_value][code_apache]); ctx= $('#'+ws_value); new Chart(ctx,{ type:'pie', data:{ labels:labels_ws, datasets: [{ data:data_ws, backgroundColor: colors }], }, options:{ responsive: true, maintainAspectRatio: false, title:{ display: true, text: ws_value } } }); }); } else { console.log(date_value); }; }); }); } else { $selection_date.hide(); $selection_rp.empty(); $.getJSON("statistiques_RP.json", function(rp_stats){ var name_rp=[], rp_value='', ws_value='', date_value=[]; tmp_rp=[]; $.each(rp_stats, function (jour){ date_value.push(jour); $.each(rp_stats[jour],function(reverse_proxy){ tmp_rp.push(reverse_proxy); name_rp=removeDuplicates(tmp_rp); }); // console.log(name_rp); }); // console.log(name_rp); // console.log(date_value); for (var i=0; i'+name_rp[i]+''); }; $selection_rp.on('change',function(){ var tmp_ws=[], name_ws=[]; $selection_ws.empty(); $selection_ws.append(''); rp_value=$('#selection_rp option:selected').text(); // console.log(date_value.length); for (var j=0; j'+name_ws[i]+''); }; // Création du graphique général $selection_ws.on('change',function(){ var tmp_ca=[], code_label=[], data_value=[], dataset_value=[], colors_choice=['#01DF01','#DF0101','#BF00FF','#08088A','#000000','#F4FA58']; $graph.empty(); ws_value=$('#selection_ws option:selected').text(); for ( var i=0;i