|
|
|
ต้องการจะแสดง ทศนิยม 2 ตำแหน่ง แต่มีปัญหา แก้ไม่ตกสักที รบกวนชี้แนะแนวทางด้วยคับ มือใหม่ |
|
|
|
|
|
|
|
Code
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts</title>
<script src="scripts/jquery-1.9.1.js" type="text/javascript"></script>
<script src="scripts/highcharts.js"></script>
<script src="scripts/exporting.js"></script>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
<?
include 'conn.php';
$id = $_REQUEST['id'];
$course_id = substr($id,-13,7);
$term = substr($id,-6,6);
$sql_course ="SELECT * FROM course WHERE course_id ='$course_id' AND term ='$term';";
$result_course = mysql_query($sql_course);
$array_course = mysql_fetch_array($result_course);
?>
text: 'แสดงผลประเมินความพึ่งพอใจ รายวิชา<? echo $array_course['course_name']; ?>'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage}%</b>',
percentageDecimals: 1
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
}
}
}
},
series: [{
type: 'pie',
name: 'คิดเป็นร้อยละ ',
data: [
<?
$sql_evaluation = "SELECT * FROM evaluation WHERE course_id ='$course_id' AND term = '$term';";
$result_evaluation = mysql_query($sql_evaluation);
$row_evaluation = mysql_num_rows($result_evaluation);
$a = 0;
$b = 0;
$c = 0;
$d = 0;
$e = 0;
while ($array_evaluation = mysql_fetch_array($result_evaluation)){
//--------------------------------------------------------------------------------------
if($array_evaluation['ev_1'] == 5){
$a++;
}else if($array_evaluation['ev_1'] == 4){
$b++;
}else if($array_evaluation['ev_1'] == 3){
$c++;
}else if($array_evaluation['ev_1'] == 2){
$d++;
}else{
$e++;
}
//--------------------------------------------------------------------------------------
if($array_evaluation['ev_2'] == 5){
$a++;
}else if($array_evaluation['ev_2'] == 4){
$b++;
}else if($array_evaluation['ev_2'] == 3){
$c++;
}else if($array_evaluation['ev_2'] == 2){
$d++;
}else{
$e++;
}
//--------------------------------------------------------------------------------------
if($array_evaluation['ev_3'] == 5){
$a++;
}else if($array_evaluation['ev_3'] == 4){
$b++;
}else if($array_evaluation['ev_3'] == 3){
$c++;
}else if($array_evaluation['ev_3'] == 2){
$d++;
}else{
$e++;
}
//--------------------------------------------------------------------------------------
if($array_evaluation['ev_4'] == 5){
$a++;
}else if($array_evaluation['ev_4'] == 4){
$b++;
}else if($array_evaluation['ev_4'] == 3){
$c++;
}else if($array_evaluation['ev_4'] == 2){
$d++;
}else{
$e++;
}
//--------------------------------------------------------------------------------------
if($array_evaluation['ev_5'] == 5){
$a++;
}else if($array_evaluation['ev_5'] == 4){
$b++;
}else if($array_evaluation['ev_5'] == 3){
$c++;
}else if($array_evaluation['ev_5'] == 2){
$d++;
}else{
$e++;
}
//--------------------------------------------------------------------------------------
if($array_evaluation['ev_6'] == 5){
$a++;
}else if($array_evaluation['ev_6'] == 4){
$b++;
}else if($array_evaluation['ev_6'] == 3){
$c++;
}else if($array_evaluation['ev_6'] == 2){
$d++;
}else{
$e++;
}
//--------------------------------------------------------------------------------------
if($array_evaluation['ev_7'] == 5){
$a++;
}else if($array_evaluation['ev_7'] == 4){
$b++;
}else if($array_evaluation['ev_7'] == 3){
$c++;
}else if($array_evaluation['ev_7'] == 2){
$d++;
}else{
$e++;
}
//--------------------------------------------------------------------------------------
if($array_evaluation['ev_8'] == 5){
$a++;
}else if($array_evaluation['ev_8'] == 4){
$b++;
}else if($array_evaluation['ev_8'] == 3){
$c++;
}else if($array_evaluation['ev_8'] == 2){
$d++;
}else{
$e++;
}
//--------------------------------------------------------------------------------------
if($array_evaluation['ev_9'] == 5){
$a++;
}else if($array_evaluation['ev_9'] == 4){
$b++;
}else if($array_evaluation['ev_9'] == 3){
$c++;
}else if($array_evaluation['ev_9'] == 2){
$d++;
}else{
$e++;
}
//--------------------------------------------------------------------------------------
if($array_evaluation['ev_10'] == 5){
$a++;
}else if($array_evaluation['ev_10'] == 4){
$b++;
}else if($array_evaluation['ev_10'] == 3){
$c++;
}else if($array_evaluation['ev_10'] == 2){
$d++;
}else{
$e++;
}
//--------------------------------------------------------------------------------------
}
$most = ((($a * 100)/$row_evaluation)/10);
$vary = ((($b * 100)/$row_evaluation)/10);
$moderate = ((($c * 100)/$row_evaluation)/10);
$low = ((($d * 100)/$row_evaluation)/10);
$least = ((($e * 100)/$row_evaluation)/10);
?>
['มากที่สุด',<?=round($most,2);?>],
['มาก',<?=round($vary,2); ?>],
['ปานกลาง',<?=round($moderate,2); ?>],
['น้อย',<?=round($low,2); ?>],
['น้อยที่สุด',<?=round($least,2); ?>]
]
}]
});
});
</script>
</head>
<body>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html>
Tag : PHP, JavaScript, JAVA
|
|
|
|
|
|
Date :
2013-07-13 11:11:32 |
By :
auppawong |
View :
1513 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลอง number_format($percent, 2, '.', ','); ดูครับ
|
|
|
|
|
Date :
2013-12-20 11:47:20 |
By :
ตี๋ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|