2016-05-22 13:20:49 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>Chart du sexe (HOMME/FEMME)</title>
|
|
|
|
<script type='text/javascript' src='/f/js/api-min/js/lib'></script> <!-- Gestion des transactions avec le serveur -->
|
|
|
|
<script type='text/javascript' src='/f/js/_charts-min/js/lib'></script>
|
|
|
|
</head>
|
|
|
|
<body style='display: flex; flex-direction: row; justify-content: space-around; flex-wrap: wrap;'>
|
|
|
|
|
2016-05-22 17:48:44 +00:00
|
|
|
<canvas id="direction" width="400" height="400" style='margin: 2em;'></canvas>
|
|
|
|
<canvas id="type" width="400" height="400" style='margin: 2em;'></canvas>
|
|
|
|
<canvas id="sexe" width="400" height="400" style='margin: 2em;'></canvas>
|
|
|
|
<canvas id="age" width="400" height="400" style='margin: 2em;'></canvas>
|
|
|
|
<canvas id="relation" width="400" height="400" style='margin: 2em;'></canvas>
|
2016-05-22 13:20:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script type='text/javascript'>
|
|
|
|
var api = new APIClass('/api/');
|
|
|
|
|
|
|
|
var direction = document.getElementById('direction');
|
|
|
|
var type = document.getElementById('type');
|
|
|
|
var sexe = document.getElementById('sexe');
|
2016-05-22 17:48:44 +00:00
|
|
|
var age = document.getElementById('age');
|
|
|
|
var relation = document.getElementById('relation');
|
2016-05-22 13:20:49 +00:00
|
|
|
|
|
|
|
/* [0] Paramètres globaux
|
|
|
|
=========================================================*/
|
|
|
|
Chart.defaults.global.responsive = false;
|
2016-05-23 09:10:24 +00:00
|
|
|
Chart.defaults.global.onClick = function(e, c){
|
|
|
|
console.log(e); // MouseEvent
|
|
|
|
console.log(c[0]._datasetIndex, c[0]._index); // Chart data
|
|
|
|
|
|
|
|
// _datasetIndex, quel dataset (s'il y en a plusieurs)
|
|
|
|
// _index, indice de la valeur dans le dataset
|
|
|
|
}
|
2016-05-22 13:20:49 +00:00
|
|
|
|
2016-05-22 15:36:49 +00:00
|
|
|
subject = 273;
|
|
|
|
|
2016-05-22 13:20:49 +00:00
|
|
|
|
2016-05-23 09:10:24 +00:00
|
|
|
var charts = ['sexe', 'direction', 'type', 'ages', 'relation'];
|
|
|
|
|
|
|
|
|
|
|
|
/* [1] On crée les conteneurs
|
|
|
|
=========================================================*/
|
|
|
|
for( var c in charts ){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-22 13:20:49 +00:00
|
|
|
/* [1] On récupére les données SEXE
|
|
|
|
=========================================================*/
|
|
|
|
/* (1) On rédige la requête */
|
|
|
|
var request = {
|
|
|
|
path: 'chart/sexe',
|
2016-05-22 15:36:49 +00:00
|
|
|
subject: subject
|
2016-05-22 13:20:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* (2) On lance la requête */
|
|
|
|
api.send(request, function(response){
|
|
|
|
/* (3) Si erreur, on quitte */
|
|
|
|
if( response.ModuleError != 0 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* [2] On construit les données
|
|
|
|
=========================================================*/
|
|
|
|
var data = {
|
|
|
|
labels: response.labels,
|
2016-05-23 09:10:24 +00:00
|
|
|
datasets: response.datasets
|
2016-05-22 13:20:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* [3] On construit notre graphique
|
|
|
|
=========================================================*/
|
|
|
|
var myDoughnutChart = new Chart(sexe, {
|
|
|
|
type: 'doughnut',
|
|
|
|
animation: { animateScale: true },
|
|
|
|
data: data
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/* [2] On récupére les données DIRECTION
|
|
|
|
=========================================================*/
|
|
|
|
/* (1) On rédige la requête */
|
|
|
|
var request = {
|
2016-05-22 14:41:12 +00:00
|
|
|
path: 'chart/direction',
|
2016-05-22 15:36:49 +00:00
|
|
|
subject: subject
|
2016-05-22 13:20:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* (2) On lance la requête */
|
|
|
|
api.send(request, function(response){
|
|
|
|
/* (3) Si erreur, on quitte */
|
|
|
|
if( response.ModuleError != 0 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* [2] On construit les données
|
|
|
|
=========================================================*/
|
|
|
|
var data = {
|
|
|
|
labels: response.labels,
|
2016-05-23 09:10:24 +00:00
|
|
|
datasets: response.datasets
|
2016-05-22 13:20:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* [3] On construit notre graphique
|
|
|
|
=========================================================*/
|
|
|
|
var myDoughnutChart = new Chart(direction, {
|
|
|
|
type: 'doughnut',
|
|
|
|
animation: { animateScale: true },
|
|
|
|
data: data
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-05-22 15:36:49 +00:00
|
|
|
/* [3] On récupére les données TYPE
|
2016-05-22 13:20:49 +00:00
|
|
|
=========================================================*/
|
|
|
|
/* (1) On rédige la requête */
|
|
|
|
var request = {
|
2016-05-22 14:41:12 +00:00
|
|
|
path: 'chart/type',
|
2016-05-22 15:36:49 +00:00
|
|
|
subject: subject
|
2016-05-22 13:20:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* (2) On lance la requête */
|
|
|
|
api.send(request, function(response){
|
|
|
|
/* (3) Si erreur, on quitte */
|
|
|
|
if( response.ModuleError != 0 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* [2] On construit les données
|
|
|
|
=========================================================*/
|
|
|
|
var data = {
|
|
|
|
labels: response.labels,
|
2016-05-23 09:10:24 +00:00
|
|
|
datasets: response.datasets
|
2016-05-22 13:20:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* [3] On construit notre graphique
|
|
|
|
=========================================================*/
|
|
|
|
var myDoughnutChart = new Chart(type, {
|
|
|
|
type: 'doughnut',
|
|
|
|
animation: { animateScale: true },
|
|
|
|
data: data
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
2016-05-22 15:36:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* [4] On récupére les données AGES
|
|
|
|
=========================================================*/
|
|
|
|
/* (1) On rédige la requête */
|
|
|
|
var request = {
|
|
|
|
path: 'chart/ages',
|
|
|
|
subject: subject
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (2) On lance la requête */
|
|
|
|
api.send(request, function(response){
|
|
|
|
/* (3) Si erreur, on quitte */
|
|
|
|
if( response.ModuleError != 0 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* [2] On construit les données
|
|
|
|
=========================================================*/
|
|
|
|
var data = {
|
|
|
|
labels: response.labels,
|
2016-05-23 09:10:24 +00:00
|
|
|
datasets: response.datasets
|
2016-05-22 15:36:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* [3] On construit notre graphique
|
|
|
|
=========================================================*/
|
|
|
|
var myDoughnutChart = new Chart(age, {
|
|
|
|
type: 'doughnut',
|
|
|
|
animation: { animateScale: true },
|
|
|
|
data: data
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-22 17:48:44 +00:00
|
|
|
|
|
|
|
/* [5] On récupére les données RELATIONS (types)
|
|
|
|
=========================================================*/
|
|
|
|
/* (1) On rédige la requête */
|
|
|
|
var request = {
|
|
|
|
path: 'chart/relations',
|
|
|
|
subject: subject
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (2) On lance la requête */
|
|
|
|
api.send(request, function(response){
|
|
|
|
/* (3) Si erreur, on quitte */
|
|
|
|
if( response.ModuleError != 0 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* [2] On construit les données
|
|
|
|
=========================================================*/
|
|
|
|
var data = {
|
|
|
|
labels: response.labels,
|
2016-05-23 09:10:24 +00:00
|
|
|
datasets: response.datasets
|
2016-05-22 17:48:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* [3] On construit notre graphique
|
|
|
|
=========================================================*/
|
|
|
|
var myBarChart = new Chart(relation, {
|
|
|
|
type: 'bar',
|
|
|
|
animation: { animateScale: true },
|
|
|
|
data: data
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-22 13:20:49 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|