@@ -153,10 +153,10 @@ const createCharts = async () => {
153153 const topCreators = await articleStore .getTopCreateur ();
154154
155155 const formattedCreators = topCreators .slice (0 , 10 ).map ((creator ) => {
156- const firstNames = ( creator .firstName || []). filter ( Boolean ). join ( ' ' ) ;
157- const lastNames = ( creator .lastName || []). filter ( Boolean ). join ( ' ' ) ;
156+ const firstName = creator .firstName || ' ' ;
157+ const lastName = creator .lastName || ' ' ;
158158 const count = creator .count ;
159- return ` ${firstNames } ${lastNames } ${count } ` ;
159+ return ` ${firstName } ${lastName } ( ${count } articles créés) ` ;
160160 });
161161
162162 console .log (formattedCreators );
@@ -165,10 +165,13 @@ const createCharts = async () => {
165165 new ChartJS (ctx3 , {
166166 type: ' doughnut' ,
167167 data: {
168- labels: formattedCreators .map ((creator ) => creator . split ( ' ' )[ 0 ]) , // Premiers prénoms
168+ labels: formattedCreators .map ((creator ) => creator ) , // Noms complets
169169 datasets: [
170170 {
171- data: formattedCreators .map ((creator ) => creator .split (' ' )[2 ]), // Count
171+ data: formattedCreators .map ((creator ) => {
172+ const countIndex = creator .lastIndexOf (' (' ) + 1 ;
173+ return parseInt (creator .substring (countIndex , creator .length - 14 ));
174+ }), // Count
172175 backgroundColor: [
173176 ' rgba(75, 192, 192, 0.6)' ,
174177 ' rgba(192, 75, 75, 0.6)' ,
@@ -201,6 +204,7 @@ const createCharts = async () => {
201204 },
202205 },
203206 });
207+
204208 const topParticipants = await articleStore .getTopParticipant ();
205209 const formattedParticipants = topParticipants .slice (0 , 10 ).map ((participant ) => {
206210 const firstName = participant .firstName || ' ' ;
0 commit comments