Bonjour à tous,

Je me permets venir ici pour faire un titre dynamique de graphique.

Je me permets également de vous soulignez que cela a une fin pédagogique car ceci est pour un projet informatique de ma formation.

J'ai écris ce code pour faire un graphique (qui fonctionne) :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<html>
 
<head>
 
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
 
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
 
</head>
<body>
 
 
 
<?php
    include './../../../connexion.php';
 
    echo "Choisissez une année :";
    echo "<form action='' method='post'>";
 
    $resultat = $connexion -> query("SELECT distinct I.id_info, I.type_info as annee
                                    FROM OMACAP2_INFOS_GENERAL I, OMACAP2_EVALUER E, OMACAP2_BSE B
                                    WHERE B.no_fiche=E.no_fiche
                                    AND I.id_info=E.id_info
                                    AND libelle_info like 'annee'");
 
    echo"<p>";
    echo"<select id='annee' name='annee'>";
    $i =1 ;
    while($ligne = $resultat -> fetch())
    {
        echo "<option value='".$ligne[0]."' selected >"."20".$ligne[1]."</option>";
    }
 
 
    echo "</select>";
    echo"<p>";
    echo"<p><input type='submit' value='Charger' /></p>";
    echo"</p>";
    echo "</form>";
 
 
    if(!empty($_POST['annee']))
    {
 
 
        $reqtitre=$connexion->query("SELECT type_info FROM OMACAP2_INFOS_GENERAL WHERE ID_INFO=".$_POST['annee']);
        $lignetitre=$reqtitre->fetch();
 
        $requetev1=$connexion->query("create or replace view v1 (ID_APPAREIL, LIBELLE_APPAREIL, nb) AS
                                  SELECT AP.ID_APPAREIL, AP.LIBELLE_APPAREIL,0
                                  FROM OMACAP2_APPAREIL AP
                                  WHERE AP.ID_APPAREIL NOT IN(SELECT A.ID_APPAREIL
                                                            FROM OMACAP2_APPAREIL A, OMACAP2_INFOS_GENERAL I, OMACAP2_BSE B, OMACAP2_EVALUER E, OMACAP2_MALADIE M
                                                            WHERE M.ID_APPAREIL=A.ID_APPAREIL
                                                            AND M.NO_FICHE=B.NO_FICHE
                                                            AND E.NO_FICHE=B.NO_FICHE
                                                            AND I.ID_INFO=E.ID_INFO
                                                            AND LIBELLE_INFO='annee'
                                                            AND I.ID_INFO=".$_POST['annee'].
                                                            " GROUP BY A.ID_APPAREIL)
                                  ORDER BY AP.ID_APPAREIL");
 
      $requetev2=$connexion->query("create or replace view v2 AS
                                    SELECT A.id_appareil, A.LIBELLE_APPAREIL, count(A.id_appareil) as nb
                                    FROM OMACAP2_APPAREIL A, OMACAP2_INFOS_GENERAL I, OMACAP2_BSE B, OMACAP2_EVALUER E, OMACAP2_MALADIE M
                                    WHERE M.ID_APPAREIL=A.ID_APPAREIL
                                    AND M.NO_FICHE=B.NO_FICHE
                                    AND E.NO_FICHE=B.NO_FICHE
                                    AND I.ID_INFO=E.ID_INFO
                                    AND LIBELLE_INFO='annee'
                                    AND I.ID_INFO=".$_POST['annee'].
                                    " GROUP BY A.ID_APPAREIL");
 
      $jointure=$connexion->query("SELECT * FROM v1 UNION SELECT * FROM v2 ORDER BY id_appareil");
 
      $i=0;
      while ($ligne=$jointure->fetch())
      {
 
        $tabid[$i]=$ligne[0];
        $tablibel[$i]=$ligne[1];
        $tabnb[$i]=$ligne[2];
 
        $i++;
      }
    }
 
    $connexion=null;
    echo"</p>";
 
 
?>
 
<style>
.highcharts-figure, .highcharts-data-table table {
    min-width: 320px; 
    max-width: 660px;
    margin: 1em auto;
}
 
.highcharts-data-table table {
	font-family: Verdana, sans-serif;
	border-collapse: collapse;
	border: 1px solid #EBEBEB;
	margin: 10px auto;
	text-align: center;
	width: 100%;
	max-width: 500px;
}
.highcharts-data-table caption {
    padding: 1em 0;
    font-size: 1.2em;
    color: #555;
}
.highcharts-data-table th {
	font-weight: 600;
    padding: 0.5em;
}
.highcharts-data-table td, .highcharts-data-table th, .highcharts-data-table caption {
    padding: 0.5em;
}
.highcharts-data-table thead tr, .highcharts-data-table tr:nth-child(even) {
    background: #f8f8f8;
}
.highcharts-data-table tr:hover {
    background: #f1f7ff;
}
 
</style>
<script>
// Make monochrome colors
var pieColors = (function () {
    var colors = [],
        base = Highcharts.getOptions().colors[0],
        i;
 
    for (i = 0; i < 10; i += 1) {
        // Start out with a darkened base color (negative brighten), and end
        // up with a much brighter color
        colors.push(Highcharts.color(base).brighten((i - 3) / 7).get());
    }
    return colors;
}());
 
// Build the chart
Highcharts.chart('graphiqueseconde', {
    chart: {
        plotBackgroundColor: null,
        plotBorderWidth: null,
        plotShadow: false,
        type: 'pie'
    },
    title: {
        text: 'Appareils les plus touchés pour une année donnée' 
    },
    tooltip: {
        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
    },
    accessibility: {
        point: {
            valueSuffix: '%'
        }
    },
    plotOptions: {
        pie: {
            allowPointSelect: true,
            cursor: 'pointer',
            colors: pieColors,
            dataLabels: {
                enabled: true,
                format: '<b>{point.name}</b><br>{point.percentage:.1f} %',
                distance: -50,
                filter: {
                    property: 'percentage',
                    operator: '>',
                    value: 4
                }
            }
        }
    },
    series: [{
        name: 'Pourcentage',
        data: [
            { name: 'Digestif', y: <?php echo $tabnb[0];?> },
            { name: 'Respiratoire', y: <?php echo $tabnb[1];?> },
            { name: 'Nerveux', y: <?php echo $tabnb[2];?> },
            { name: 'Locomoteur', y: <?php echo $tabnb[3];?> },
            { name: 'Cutane', y: <?php echo $tabnb[4];?> },
            { name: 'Reproducteur', y: <?php echo $tabnb[5];?> },
			{ name: 'Mammaire', y: <?php echo $tabnb[6];?> },
			{ name: 'Autre', y: <?php echo $tabnb[7];?> }
        ]
    }]
});
</script>
 
 
</body>
</html>
L'idée c'est de rendre le titre du graphique dynamique en fonction de l'année sélectionné dans la liste déroulante.

Savez vous comment faire pour rendre le titre dynamique ?

Par la même occasion lorsque je clique sur le bouton valider, la liste déroulante ne s'affiche plus.

Seriez-vous où placer la liste déroulante pour qu'elle reste toujours visible ?

En vous remerciant par avance de votre aide précieuse.