Ce tutoriel vous explique comment modifier l'affichage des résultats d'un sondage pour obtenir un graphique rond ou en barres. Ce tutoriel nécessite d'être fondateur du forum, une modification des templates étant nécessaire.
Voici comment sont affichés actuellement les résultats d'un sondage :
Voici comment ils seront affichés après la mise en œuvre de ce tutoriel :
ou
Affichage sous forme de diagramme circulairePanneau d'administration Affichage Templates - Général
Version phpBB2Éditez le template viewtopic_poll_result et remplacez l'intégralité de son contenu par ceci :
- Code:
<tr> <td class="row2" colspan="2"><br clear="all" /> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <style> svg > g > g:last-child { pointer-events: none } </style> <script> google.charts.load("current", {packages:["corechart"]}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Answer', 'Value'], <!-- BEGIN poll_option --> ["{poll_option.POLL_OPTION_CAPTION}", {poll_option.POLL_OPTION_RESULT} ], <!-- END poll_option --> ]); var options = { title: "{POLL_QUESTION}", sliceVisibilityThreshold:0, backgroundColor: 'transparent', is3D: true, }; var chart = new google.visualization.PieChart(document.getElementById('piechart_3d')); chart.draw(data, options); } </script> <span style="float:right; margin-left:-24px;">{CLOSE_POLL}</span> <div id="piechart_3d" style="width: 450px; height: 210px; margin:auto;"></div> <div class="gen" align="center"> {L_TOTAL_VOTES} : <strong>{TOTAL_VOTES}</strong> <!-- BEGIN cancel_vote --> - <a href="{U_CANCEL_VOTE}">{L_CANCEL_VOTE}</a> <!-- END cancel_vote --> </div> <br /> </td> </tr>
Version phpBB3Éditez le template viewtopic_poll_result et remplacez l'intégralité de son contenu par ceci :
- Code:
<div class="panel"> <div class="inner"> <div class="content"> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <style> svg > g > g:last-child { pointer-events: none } </style> <script> google.charts.load("current", {packages:["corechart"]}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Answer', 'Value'], <!-- BEGIN poll_option --> ["{poll_option.POLL_OPTION_CAPTION}", {poll_option.POLL_OPTION_RESULT} ], <!-- END poll_option --> ]); var options = { title: "{POLL_QUESTION}", sliceVisibilityThreshold:0, backgroundColor: 'transparent', is3D: true, }; var chart = new google.visualization.PieChart(document.getElementById('piechart_3d')); chart.draw(data, options); } </script> <span style="float:right; margin-left:-24px;">{CLOSE_POLL}</span> <div id="piechart_3d" style="width: 450px; height: 210px; margin:auto;"></div> <div class="gen" align="center"> {L_TOTAL_VOTES} : <strong>{TOTAL_VOTES}</strong> <!-- BEGIN cancel_vote --> - <a href="{U_CANCEL_VOTE}">{L_CANCEL_VOTE}</a> <!-- END cancel_vote --> </div> <br /> </div> </div> </div>
Version PunBBÉditez le template viewtopic_poll_result et remplacez l'intégralité de son contenu par ceci :
- Code:
<div class="main-content frm"> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <style> svg > g > g:last-child { pointer-events: none } </style> <script> google.charts.load("current", {packages:["corechart"]}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Answer', 'Value'], <!-- BEGIN poll_option --> ["{poll_option.POLL_OPTION_CAPTION}", {poll_option.POLL_OPTION_RESULT} ], <!-- END poll_option --> ]); var options = { title: "{POLL_QUESTION}", sliceVisibilityThreshold:0, backgroundColor: 'transparent', is3D: true, }; var chart = new google.visualization.PieChart(document.getElementById('piechart_3d')); chart.draw(data, options); } </script> <span style="float:right; margin-left:-24px;">{CLOSE_POLL}</span> <div id="piechart_3d" style="width: 450px; height: 210px; margin:auto;"></div> <div class="gen" align="center"> {L_TOTAL_VOTES} : <strong>{TOTAL_VOTES}</strong> <!-- BEGIN cancel_vote --> - <a href="{U_CANCEL_VOTE}">{L_CANCEL_VOTE}</a> <!-- END cancel_vote --> </div> <br /> </div>
Version InvisionÉditez le template viewtopic_poll_result et remplacez l'intégralité de son contenu par ceci :
- Code:
<div class="main"> <div class="box-content row1"> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <style> svg > g > g:last-child { pointer-events: none } </style> <script> google.charts.load("current", {packages:["corechart"]}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Answer', 'Value'], <!-- BEGIN poll_option --> ["{poll_option.POLL_OPTION_CAPTION}", {poll_option.POLL_OPTION_RESULT} ], <!-- END poll_option --> ]); var options = { title: "{POLL_QUESTION}", sliceVisibilityThreshold:0, backgroundColor: 'transparent', is3D: true, }; var chart = new google.visualization.PieChart(document.getElementById('piechart_3d')); chart.draw(data, options); } </script> <span style="float:right; margin-left:-24px;">{CLOSE_POLL}</span> <div id="piechart_3d" style="width: 450px; height: 210px; margin:auto;"></div> <div class="gen" align="center"> {L_TOTAL_VOTES} : <strong>{TOTAL_VOTES}</strong> <!-- BEGIN cancel_vote --> - <a href="{U_CANCEL_VOTE}">{L_CANCEL_VOTE}</a> <!-- END cancel_vote --> </div> <br /> </div> </div>
Version ModernBBÉditez le template viewtopic_poll_result et remplacez l'intégralité de son contenu par ceci :
- Code:
<div class="panel"> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <style> svg > g > g:last-child { pointer-events: none } </style> <script> google.charts.load("current", {packages:["corechart"]}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Answer', 'Value'], <!-- BEGIN poll_option --> ["{poll_option.POLL_OPTION_CAPTION}", {poll_option.POLL_OPTION_RESULT} ], <!-- END poll_option --> ]); var options = { title: "{POLL_QUESTION}", sliceVisibilityThreshold:0, backgroundColor: 'transparent', is3D: true, }; var chart = new google.visualization.PieChart(document.getElementById('piechart_3d')); chart.draw(data, options); } </script> <span style="float:right; margin-left:-24px;">{CLOSE_POLL}</span> <div id="piechart_3d" style="width: 450px; height: 210px; margin:auto;"></div> <div class="gen" align="center"> {L_TOTAL_VOTES} : <strong>{TOTAL_VOTES}</strong> <!-- BEGIN cancel_vote --> - <a href="{U_CANCEL_VOTE}">{L_CANCEL_VOTE}</a> <!-- END cancel_vote --> </div> <br /> </div>
Affichage sous forme de diagramme en barresVersion phpBB2Éditez le template viewtopic_poll_result et remplacez l'intégralité de son contenu par ceci :
- Code:
<tr> <td class="row2" colspan="2"><br clear="all" /> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['bar']}); google.charts.setOnLoadCallback(drawStuff); function drawStuff() { var data = google.visualization.arrayToDataTable([ ['Réponse', 'Valeur'], <!-- BEGIN poll_option --> ["{poll_option.POLL_OPTION_CAPTION}", parseInt('{poll_option.POLL_OPTION_PERCENT}'.replace('%','')) ], <!-- END poll_option --> ]);
var options = { legend: { position: 'none' }, backgroundColor: 'transparent', vAxis: { format: '#\'%\'', }, hAxis: { title: ' ', }, chartArea: { backgroundColor: 'transparent', }, chart: { title: "{POLL_QUESTION}", }, bar: { groupWidth: "90%" } };
var chart = new google.charts.Bar(document.getElementById('top_x_div')); chart.draw(data, google.charts.Bar.convertOptions(options)); }; </script> <span style="float:right; margin-left:-24px;">{CLOSE_POLL}</span> <div id="top_x_div" style="width: 450px; height: 210px; margin:auto; padding-top: 20px;"></div> <div class="gen" align="center"> {L_TOTAL_VOTES} : <strong>{TOTAL_VOTES}</strong> <!-- BEGIN cancel_vote --> - <a href="{U_CANCEL_VOTE}">{L_CANCEL_VOTE}</a> <!-- END cancel_vote --> </div> <br /> </td> </tr>
Version phpBB3Éditez le template viewtopic_poll_result et remplacez l'intégralité de son contenu par ceci :
- Code:
<div class="panel"> <div class="inner"> <div class="content"> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['bar']}); google.charts.setOnLoadCallback(drawStuff); function drawStuff() { var data = google.visualization.arrayToDataTable([ ['Réponse', 'Valeur'], <!-- BEGIN poll_option --> ["{poll_option.POLL_OPTION_CAPTION}", parseInt('{poll_option.POLL_OPTION_PERCENT}'.replace('%','')) ], <!-- END poll_option --> ]); var options = { legend: { position: 'none' }, backgroundColor: 'transparent', vAxis: { format: '#\'%\'', }, hAxis: { title: ' ', }, chartArea: { backgroundColor: 'transparent', }, chart: { title: "{POLL_QUESTION}", }, bar: { groupWidth: "90%" } }; var chart = new google.charts.Bar(document.getElementById('top_x_div')); chart.draw(data, google.charts.Bar.convertOptions(options)); }; </script> <span style="float:right; margin-left:-24px;">{CLOSE_POLL}</span> <div id="top_x_div" style="width: 450px; height: 210px; margin:auto; padding-top: 20px;"></div> <div class="gen" align="center"> {L_TOTAL_VOTES} : <strong>{TOTAL_VOTES}</strong> <!-- BEGIN cancel_vote --> - <a href="{U_CANCEL_VOTE}">{L_CANCEL_VOTE}</a> <!-- END cancel_vote --> </div> <br /> </div> </div> </div>
Version PunBBÉditez le template viewtopic_poll_result et remplacez l'intégralité de son contenu par ceci :
- Code:
<div class="main-content frm"> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['bar']}); google.charts.setOnLoadCallback(drawStuff); function drawStuff() { var data = google.visualization.arrayToDataTable([ ['Réponse', 'Valeur'], <!-- BEGIN poll_option --> ["{poll_option.POLL_OPTION_CAPTION}", parseInt('{poll_option.POLL_OPTION_PERCENT}'.replace('%','')) ], <!-- END poll_option --> ]);
var options = { legend: { position: 'none' }, backgroundColor: 'transparent', vAxis: { format: '#\'%\'', }, hAxis: { title: ' ', }, chartArea: { backgroundColor: 'transparent', }, chart: { title: "{POLL_QUESTION}", }, bar: { groupWidth: "90%" } };
var chart = new google.charts.Bar(document.getElementById('top_x_div')); chart.draw(data, google.charts.Bar.convertOptions(options)); }; </script> <span style="float:right; margin-left:-24px;">{CLOSE_POLL}</span> <div id="top_x_div" style="width: 450px; height: 210px; margin:auto; padding-top: 20px;"></div> <div class="gen" align="center"> {L_TOTAL_VOTES} : <strong>{TOTAL_VOTES}</strong> <!-- BEGIN cancel_vote --> - <a href="{U_CANCEL_VOTE}">{L_CANCEL_VOTE}</a> <!-- END cancel_vote --> </div> <br /> </div>
Version InvisionÉditez le template viewtopic_poll_result et remplacez l'intégralité de son contenu par ceci :
- Code:
<div class="main"> <div class="box-content row1"> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['bar']}); google.charts.setOnLoadCallback(drawStuff); function drawStuff() { var data = google.visualization.arrayToDataTable([ ['Réponse', 'Valeur'], <!-- BEGIN poll_option --> ["{poll_option.POLL_OPTION_CAPTION}", parseInt('{poll_option.POLL_OPTION_PERCENT}'.replace('%','')) ], <!-- END poll_option --> ]); var options = { legend: { position: 'none' }, backgroundColor: 'transparent', vAxis: { format: '#\'%\'', }, hAxis: { title: ' ', }, chartArea: { backgroundColor: 'transparent', }, chart: { title: "{POLL_QUESTION}", }, bar: { groupWidth: "90%" } }; var chart = new google.charts.Bar(document.getElementById('top_x_div')); chart.draw(data, google.charts.Bar.convertOptions(options)); }; </script> <span style="float:right; margin-left:-24px;">{CLOSE_POLL}</span> <div id="top_x_div" style="width: 450px; height: 210px; margin:auto; padding-top: 20px;"></div> <div class="gen" align="center"> {L_TOTAL_VOTES} : <strong>{TOTAL_VOTES}</strong> <!-- BEGIN cancel_vote --> - <a href="{U_CANCEL_VOTE}">{L_CANCEL_VOTE}</a> <!-- END cancel_vote --> </div> <br /> </div> </div>
Version ModernBBÉditez le template viewtopic_poll_result et remplacez l'intégralité de son contenu par ceci :
- Code:
<div class="panel"> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['bar']}); google.charts.setOnLoadCallback(drawStuff); function drawStuff() { var data = google.visualization.arrayToDataTable([ ['Réponse', 'Valeur'], <!-- BEGIN poll_option --> ["{poll_option.POLL_OPTION_CAPTION}", parseInt('{poll_option.POLL_OPTION_PERCENT}'.replace('%','')) ], <!-- END poll_option --> ]); var options = { legend: { position: 'none' }, backgroundColor: 'transparent', vAxis: { format: '#\'%\'', }, hAxis: { title: ' ', }, chartArea: { backgroundColor: 'transparent', }, chart: { title: "{POLL_QUESTION}", }, bar: { groupWidth: "90%" } }; var chart = new google.charts.Bar(document.getElementById('top_x_div')); chart.draw(data, google.charts.Bar.convertOptions(options)); }; </script> <span style="float:right; margin-left:-24px;">{CLOSE_POLL}</span> <div id="top_x_div" style="width: 450px; height: 210px; margin:auto; padding-top: 20px;"></div> <div class="gen" align="center"> {L_TOTAL_VOTES} : <strong>{TOTAL_VOTES}</strong> <!-- BEGIN cancel_vote --> - <a href="{U_CANCEL_VOTE}">{L_CANCEL_VOTE}</a> <!-- END cancel_vote --> </div> <br /> </div>
RemarqueCe tutoriel utilise l'outil Google Charts, ce qui signifie que des connaissances en javascript vous permettront de modifier les codes proposés ci-dessus afin de personnaliser encore plus l'affichage de vos sondages.
|