Fixed call forward chart not showing up (#6547)

Fixed a bug where the chart doesn't show up when all the values are equal to 0.
This commit is contained in:
Alex 2023-02-09 13:38:48 -07:00 committed by GitHub
parent a727c4c38a
commit d35c7577bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 68 additions and 63 deletions

View File

@ -92,69 +92,74 @@
//begin widget //begin widget
echo "<div class='hud_box'>\n"; echo "<div class='hud_box'>\n";
//doughnut chart //set defaults
if ($show_stat) { if ($stats['dnd'] == null) { $stats['dnd'] = 0; }
echo "<div style='display: flex; flex-wrap: wrap; justify-content: center; padding-bottom: 20px;' onclick=\"$('#hud_call_forward_details').slideToggle('fast');\">\n"; if ($stats['follow_me'] == null) { $stats['follow_me'] = 0; }
echo " <div style='width: 250px; height: 175px;'><canvas id='call_forward_chart'></canvas></div>\n"; if ($stats['call_forward'] == null) { $stats['call_forward'] = 0; }
echo "</div>\n"; if ($stats['active'] == null) { $stats['active'] = 0; }
echo "<script>\n"; //doughnut chart
echo " const call_forward_chart = new Chart(\n"; echo "<div style='display: flex; flex-wrap: wrap; justify-content: center; padding-bottom: 20px;' onclick=\"$('#hud_call_forward_details').slideToggle('fast');\">\n";
echo " document.getElementById('call_forward_chart').getContext('2d'),\n"; echo " <div style='width: 275px; height: 175px;'><canvas id='call_forward_chart'></canvas></div>\n";
echo " {\n"; echo "</div>\n";
echo " type: 'doughnut',\n";
echo " data: {\n"; echo "<script>\n";
echo " labels: [\n"; echo " const call_forward_chart = new Chart(\n";
echo " '".$text['label-dnd'].": ".$stats['dnd']."',\n"; echo " document.getElementById('call_forward_chart').getContext('2d'),\n";
echo " '".$text['label-follow_me'].": ".$stats['follow_me']."',\n"; echo " {\n";
echo " '".$text['label-call_forward'].": ".$stats['call_forward']."',\n"; echo " type: 'doughnut',\n";
echo " '".$text['label-active'].": ".$stats['active']."',\n"; echo " data: {\n";
echo " ],\n"; echo " labels: [\n";
echo " datasets: [{\n"; echo " '".$text['label-dnd'].": ".$stats['dnd']."',\n";
echo " data: [\n"; echo " '".$text['label-follow_me'].": ".$stats['follow_me']."',\n";
echo " '".$stats['dnd']."',\n"; echo " '".$text['label-call_forward'].": ".$stats['call_forward']."',\n";
echo " '".$stats['follow_me']."',\n"; echo " '".$text['label-active'].": ".$stats['active']."',\n";
echo " '".$stats['call_forward']."',\n"; echo " ],\n";
echo " '".$stats['active']."',\n"; echo " datasets: [{\n";
echo " ],\n"; echo " data: [\n";
echo " backgroundColor: [\n"; echo " '".$stats['dnd']."',\n";
echo " '".$_SESSION['dashboard']['call_forward_chart_color_do_not_disturb']['text']."',\n"; echo " '".$stats['follow_me']."',\n";
echo " '".$_SESSION['dashboard']['call_forward_chart_color_follow_me']['text']."',\n"; echo " '".$stats['call_forward']."',\n";
echo " '".$_SESSION['dashboard']['call_forward_chart_color_call_forward']['text']."',\n"; echo " '".$stats['active']."',\n";
echo " '".$_SESSION['dashboard']['call_forward_chart_color_active']['text']."',\n"; echo " 0.00001,\n";
echo " '#000',\n"; echo " ],\n";
echo " ],\n"; echo " backgroundColor: [\n";
echo " borderColor: '".$_SESSION['dashboard']['call_forward_chart_border_color']['text']."',\n"; echo " '".$_SESSION['dashboard']['call_forward_chart_color_do_not_disturb']['text']."',\n";
echo " borderWidth: '".$_SESSION['dashboard']['call_forward_chart_border_width']['text']."',\n"; echo " '".$_SESSION['dashboard']['call_forward_chart_color_follow_me']['text']."',\n";
echo " cutout: chart_cutout\n"; echo " '".$_SESSION['dashboard']['call_forward_chart_color_call_forward']['text']."',\n";
echo " }]\n"; echo " '".$_SESSION['dashboard']['call_forward_chart_color_active']['text']."',\n";
echo " },\n"; echo " '".$_SESSION['dashboard']['call_forward_chart_color_active']['text']."',\n";
echo " options: {\n"; echo " ],\n";
echo " responsive: true,\n"; echo " borderColor: '".$_SESSION['dashboard']['call_forward_chart_border_color']['text']."',\n";
echo " maintainAspectRatio: false,\n"; echo " borderWidth: '".$_SESSION['dashboard']['call_forward_chart_border_width']['text']."',\n";
echo " plugins: {\n"; echo " cutout: chart_cutout,\n";
echo " chart_counter: {\n"; echo " }]\n";
echo " chart_text: '".$stats['call_forward']."'\n"; echo " },\n";
echo " },\n"; echo " options: {\n";
echo " legend: {\n"; echo " responsive: true,\n";
echo " position: 'right',\n"; echo " maintainAspectRatio: false,\n";
echo " reverse: true,\n"; echo " plugins: {\n";
echo " labels: {\n"; echo " chart_counter: {\n";
echo " usePointStyle: true,\n"; echo " chart_text: '".$stats['call_forward']."'\n";
echo " pointStyle: 'rect'\n"; echo " },\n";
echo " }\n"; echo " legend: {\n";
echo " },\n"; echo " position: 'right',\n";
echo " title: {\n"; echo " reverse: true,\n";
echo " display: true,\n"; echo " labels: {\n";
echo " text: '".$text['header-call_forward']."'\n"; echo " usePointStyle: true,\n";
echo " }\n"; echo " pointStyle: 'rect'\n";
echo " }\n"; echo " }\n";
echo " },\n"; echo " },\n";
echo " plugins: [chart_counter],\n"; echo " title: {\n";
echo " }\n"; echo " display: true,\n";
echo " );\n"; echo " text: '".$text['header-call_forward']."'\n";
echo "</script>\n"; echo " }\n";
} echo " }\n";
echo " },\n";
echo " plugins: [chart_counter],\n";
echo " }\n";
echo " );\n";
echo "</script>\n";
//details //details
echo "<div class='hud_details hud_box' id='hud_call_forward_details'>"; echo "<div class='hud_details hud_box' id='hud_call_forward_details'>";
@ -212,4 +217,4 @@
echo "<span class='hud_expander' onclick=\"$('#hud_call_forward_details').slideToggle('fast');\"><span class='fas fa-ellipsis-h'></span></span>\n"; echo "<span class='hud_expander' onclick=\"$('#hud_call_forward_details').slideToggle('fast');\"><span class='fas fa-ellipsis-h'></span></span>\n";
echo "</div>\n"; echo "</div>\n";
?> ?>