Editing: poll_vote_chart.php
Kembali
<?php $vote = $_REQUEST['vote']; //get content of textfile $filename = "poll_result.txt"; $content = file($filename); //put content in array $array = explode("||", $content[0]); $c1 = $array[0]; $c2 = $array[1]; $c3 = $array[2]; $c4 = $array[3]; $c5 = $array[4]; $c6 = $array[5]; $c7 = $array[6]; $c8 = $array[7]; $c9 = $array[8]; $c10 = $array[9]; $c11 = $array[10]; $c12 = $array[11]; $c13 = $array[12]; $c14 = $array[13]; $c15 = $array[14]; $c16 = $array[15]; $c17 = $array[16]; $c18 = $array[17]; $c19 = $array[18]; $c20 = $array[19]; $c21 = $array[20]; $c22 = $array[21]; $c23 = $array[22]; $c24 = $array[23]; //insert votes to txt file $insertvote = $c1."||".$c2."||".$c3."||".$c4."||".$c5."||".$c6."||".$c7."||".$c8."||".$c9."||".$c10."||".$c11."||".$c12."||".$c13."||".$c14."||".$c15."||".$c16."||".$c17."||".$c18."||".$c19."||".$c20."||".$c21."||".$c22."||".$c23."||".$c24; $fp = fopen($filename,"w"); fputs($fp,$insertvote); fclose($fp); ?> <h2> <input type="reset" name="back" id="back" onclick="window.location.replace('.');" value="X" title="Taka Janela" /> </h2> <?php $t1=(100*round($c1/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t2=(100*round($c2/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t3=(100*round($c3/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t4=(100*round($c4/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t5=(100*round($c5/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t6=(100*round($c6/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t7=(100*round($c7/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t8=(100*round($c8/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t9=(100*round($c9/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t10=(100*round($c10/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t11=(100*round($c11/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t12=(100*round($c12/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t13=(100*round($c13/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t14=(100*round($c14/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t15=(100*round($c15/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t16=(100*round($c16/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t17=(100*round($c17/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t18=(100*round($c18/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t19=(100*round($c19/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t20=(100*round($c20/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t21=(100*round($c21/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t22=(100*round($c22/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t23=(100*round($c23/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $t24=(100*round($c24/($c24+$c23+$c22+$c21+$c20+$c19+$c18+$c17+$c16+$c15+$c14+$c13+$c12+$c11+$c10+$c9+$c8+$c7+$c6+$c5+$c4+$c3+$c2+$c1),2)); $dataPoints = array( array("y" => $t1, "label" => "PMD"), array("y" => $t2, "label" => "PLPA"), array("y" => $t3, "label" => "PDRT"), array("y" => $t4, "label" => "APMT"), array("y" => $t5, "label" => "KHUNTO"), array("y" => $t6, "label" => "PST"), array("y" => $t7, "label" => "PDP"), array("y" => $t8, "label" => "CNRT"), array("y" => $t9, "label" => "PR"), array("y" => $t10, "label" => "UDT"), array("y" => $t11, "label" => "PDC"), array("y" => $t12, "label" => "MLPM"), array("y" => $t13, "label" => "PLP"), array("y" => $t14, "label" => "PD"), array("y" => $t15, "label" => "UNDERTIM"), array("y" => $t16, "label" => "PUDD"), array("y" => $t17, "label" => "PTD"), array("y" => $t18, "label" => "FM"), array("y" => $t19, "label" => "PSD"), array("y" => $t20, "label" => "CASDTL"), array("y" => $t21, "label" => "PDN"), array("y" => $t22, "label" => "FRETILIN"), array("y" => $t23, "label" => "PV"), array("y" => $t24, "label" => "PDS"), ); ?> <script> window.onload = function () { var chart = new CanvasJS.Chart("chartContainer", { animationEnabled: true, exportEnabled: true, theme: "light2", // "light1", "light2", "dark1", "dark2" title: { text: "Partido Nebe Sei Hetan Votus Barak Liu?" }, subtitles: [{ text: "Survey simples 2023" }], data: [{ type: "pie", showInLegend: "true", legendText: "{label}", indexLabelFontSize: 16, indexLabel: "{label} - #percent%", yValueFormatString: "฿#,##0", dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?> }] }); chart.render(); } </script> <div id="chartContainer" style="height: 85%; width: 100%;"></div> <script src="canvasjs.min.js"></script>
SIMPAN PERUBAHAN