View Full Version : سوال: نمایش نظر سنجی
student91
دوشنبه 11 اردیبهشت 1391, 10:00 صبح
سلام.
می خوام درصد های یک نظر سنجی رو بدم به یک تابع و اون برام نمودارشو رسم کنه!می تونید کمکم کنید؟
Hamid.RDN
دوشنبه 11 اردیبهشت 1391, 12:30 عصر
خوب دوست عزیز
اینم تابع و مثالش
function drawBar($percent = 0, $color= '')
{
if($color == '')
{
$color = '#'.dechex(mt_rand(0, 0xFFFFFF));
}
echo '<div style="width:'.$percent.'%; height:16px; background-color: '.$color.'; margin:10px;">'.$percent.'%</div>';
}
drawBar(20);
drawBar(83);
drawBar(10);
drawBar(91);
drawBar(56);
drawBar(49);
student91
دوشنبه 11 اردیبهشت 1391, 13:13 عصر
ممنون ولی من میخوام به صورت میله ای یعنی عمودی نمایش داده بشه!
Hamid.RDN
دوشنبه 11 اردیبهشت 1391, 14:01 عصر
اینم کد میله ای
<?php
function drawBar($percent = 0, $color= '')
{
if($color == '')
{
$color = '#'.dechex(mt_rand(0, 0xFFFFFF));
}
echo '<td valign="bottom"><div style="width:16px; height:'.$percent.'%; background-color: '.$color.'; margin:10px;">'.$percent.'%</div></td>';
}
echo '<table style="height:500px;"><tr>';
drawBar(20);
drawBar(83);
drawBar(10);
drawBar(91);
drawBar(56);
drawBar(49);
echo '</tr></table>';
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.