@@ -820,107 +819,75 @@ function graphique_sinistre() {
`);
$.ajax({
- url: $("#racineWeb").val() + "Ajaxgraphiquesinistres/",
- type: 'post',
- success: function(data, textStatus, jqXHR) {
- let contentType = jqXHR.getResponseHeader("Content-Type");
+ url: $("#racineWeb").val() + "Ajaxgraphiquesinistres/?api=1",
+ type: 'get',
+ dataType: 'json',
+ success: function(data) {
+ $("#div_graphique").empty();
- if (contentType && contentType.indexOf("application/json") !== -1) {
- // --- Mode JSON ---
- $("#div_graphique").empty();
-
- // Layout responsive Bootstrap
- $("#div_graphique").append(`
-
-
-
-
-
Répartition des sinistres
-
-
-
-
-
-
-
-
Évolution mensuelle
-
-
-
-
-
-
-
-
Ratio de sinistralité
-
-
-
-
-
- `);
-
- // Graphique 1 : répartition
- new Chart(document.getElementById('claimsChart'), {
- type: 'bar',
- data: {
- labels: data.claims.claimsLabels,
- datasets: [{
- label: 'Nombre de sinistres',
- data: data.claims.claimsValues,
- backgroundColor: 'rgba(54, 162, 235, 0.6)'
- }]
- }
- });
-
- // Graphique 2 : évolution mensuelle
- new Chart(document.getElementById('claimsMonthChart'), {
- type: 'line',
- data: {
- labels: data.claimsMonth.months,
- datasets: [
- {
- label: 'Sinistres mensuels',
- data: data.claimsMonth.monthlyClaims,
- borderColor: 'rgba(255, 99, 132, 0.8)',
- fill: false
- },
- {
- label: 'Sinistres uniques',
- data: data.claimsMonth.singleClaims,
- borderColor: 'rgba(75, 192, 192, 0.8)',
- fill: false
- }
- ]
- }
- });
-
- // Graphique 3 : ratio
- new Chart(document.getElementById('lossRatioChart'), {
- type: 'line',
- data: {
- labels: data.lossRatio.lossRatioLabels,
- datasets: [{
- label: 'Ratio de sinistralité',
- data: data.lossRatio.lossRatioValues,
- borderColor: 'rgba(255, 206, 86, 0.8)',
- fill: false
- }]
- }
- });
-
- } else {
- // --- Mode Vue HTML ---
- $("#div_graphique").html(data);
- }
- },
- error: function(err) {
- console.error("Erreur AJAX:", err);
- $("#div_graphique").html(`
-
- Impossible de charger les graphiques.
+ // Construis ton layout HTML ici
+ $("#div_graphique").append(`
+
`);
+
+
+ // Initialise les graphiques avec Chart.js
+ // Graphique 1 : répartition des sinistres
+ new Chart(document.getElementById('claimsChart'), {
+ type: 'bar',
+ data: {
+ labels: data.claims.claimsLabels,
+ datasets: [{
+ label: 'Nombre de sinistres',
+ data: data.claims.claimsValues,
+ backgroundColor: 'rgba(54, 162, 235, 0.6)'
+ }]
+ }
+ });
+
+ // Graphique 2 : évolution mensuelle
+ new Chart(document.getElementById('claimsMonthChart'), {
+ type: 'line',
+ data: {
+ labels: data.claimsMonth.months,
+ datasets: [
+ {
+ label: 'Sinistres mensuels',
+ data: data.claimsMonth.monthlyClaims,
+ borderColor: 'rgba(255, 99, 132, 0.8)',
+ fill: false
+ },
+ {
+ label: 'Sinistres uniques',
+ data: data.claimsMonth.singleClaims,
+ borderColor: 'rgba(75, 192, 192, 0.8)',
+ fill: false
+ }
+ ]
+ }
+ });
+
+ // Graphique 3 : ratio de sinistralité
+ new Chart(document.getElementById('lossRatioChart'), {
+ type: 'line',
+ data: {
+ labels: data.lossRatio.lossRatioLabels,
+ datasets: [{
+ label: 'Ratio de sinistralité',
+ data: data.lossRatio.lossRatioValues,
+ borderColor: 'rgba(255, 206, 86, 0.8)',
+ fill: false
+ }]
+ }
+ });
+
+ },
+ error: function(err) {
+ $("#div_graphique").html(`
Impossible de charger les graphiques.
`);
}
});
-}
-
+}
\ No newline at end of file
diff --git a/Vue/gabarit.php b/Vue/gabarit.php
index 547f889..e0f3c60 100755
--- a/Vue/gabarit.php
+++ b/Vue/gabarit.php
@@ -599,7 +599,7 @@ $activeChildId = $menuData['child'];
-
+