확

그래프 만들기-gd 안쓰고

· 2010-04-28 (수) 18:06:20 · 3856

<?php
/* ================================================================
 * filename  :  gra.php
 * Creator  :  이창열, 2009. 02. 22

 * Comment :  그래프 그리기
 ==================================================================*/
 
# 그래프 출력을 위한 데이터의 최대값및 최소값 세팅
$maxVal = 50;  // 최대값 5백만
$step = 5;   // 단위 5십만


$arrVal = array(25,18, 34, 46, 10, 29, 17, 38, 26, 25, 27, 39, 44, 22, 16, 43, 39, 22, 44, 18, 14, 22, 32, 45);

function showStickGraph($maxVal, $minVal, $step, $arrVal)
{
 $bottomCommentHeight= 30;    // 하단 설명공간 높이 픽셀값
 $cntY = round($maxVal / $step);  // y축 눈금개수
 $unitHight = 30;        // 단위 높이 픽셀값
 $minVal = 0;         // 최소값
 $k= 10;
 
?>
 <table cellpadding=0 cellspacing=0 border="1" >
  <tr>
   
   <!-- y축-->
   <td >
     <table cellpadding=0 cellspacing=0 border="1" >
      
      <? for ($a= $maxVal; $a >= $minVal; $a -= $step){ ?>
      <tr>
       <td height="<?=$unitHight?>" valign="bottom" align="right">
        <font size="2"><?=$a?></font>
       </td>
      </tr>
      <?}?>
      
      <tr>
       <td height="<?=$bottomCommentHeight?>">
        <font size="2">매출<br>(단위:10만)</font></td>
      </tr>
      
     </table>
 
    </td>
   
   <!--x축-->
   <td valign="bottom"> 
    <table cellpadding=0 cellspacing=0 border="0" >
     <tr>
      <? for ($i= 0; $i < 24; $i++){ ?>
      <td align="center" valign="bottom">
          <table cellpadding=0 cellspacing=0 border="1" >
           <tr>
         <td width="20" height="<?=($arrVal[$i])/$step * $unitHight ?>" bgcolor="green" valign="top" align="center">
          <font size="2" color="white"><b><?=$arrVal[$i]?></b></font></td>
        </tr>
        
        <tr>
         <td height="<?=$bottomCommentHeight?>" valigh="top"><font size="2"><?=($i<10)?"0$i":$i?></font></td>
        </tr>
       </table>
        </td>
        <?}?>
      </tr>
     
     </table>

    </td>
  
  </tr>
 </table>
<?
}
showStickGraph($maxVal, $minVal, $step, $arrVal);
?>

[이 게시물은 관리자님에 의해 2011-10-31 16:55:28 jQuery에서 이동 됨]
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
16-07-13 조회 2,173
16-07-12 조회 2,360
16-07-12 조회 2,387
16-07-11 조회 2,194
16-06-05 조회 2,923
16-06-03 조회 3,046
16-05-26 조회 2,966
15-09-22 조회 4,992
15-06-10 조회 4,838
14-10-25 조회 6,369
14-10-22 조회 8,990
14-09-21 조회 5,795
14-09-16 조회 5,083
14-08-22 조회 1.1만
14-08-13 조회 5,917
14-08-12 조회 5,447
14-08-12 조회 6,308
14-08-11 조회 6,936
14-06-12 조회 6,219
14-06-11 조회 5,119
14-05-09 조회 5,436
14-05-09 조회 6,394
14-05-09 조회 6,423
14-05-08 조회 5,763
14-04-17 조회 4,768
14-04-16 조회 4,592
14-04-15 조회 4,594
14-04-15 조회 4,542
14-04-15 조회 4,312
14-04-14 조회 4,296
14-04-14 조회 4,269
14-04-14 조회 4,643
14-04-14 조회 4,784
14-04-14 조회 4,772
14-04-13 조회 4,674
14-04-12 조회 4,244
14-04-12 조회 4,385
14-04-12 조회 4,493
14-04-11 조회 5,015
14-04-10 조회 4,755
14-04-10 조회 4,786
14-04-09 조회 4,946
14-04-09 조회 5,316
14-04-08 조회 6,982
13-10-30 조회 7,663
13-07-11 조회 5,144
13-03-28 조회 1.1만
13-02-27 조회 6,795
13-02-14 조회 5,622
13-01-10 조회 4,524
12-12-31 조회 5,107
12-12-20 조회 6,124
12-12-12 조회 5,281
12-12-07 조회 4,513
12-11-28 조회 4,864
12-11-22 조회 5,307
12-11-12 조회 5,664
12-09-22 조회 4,523
12-09-18 조회 4,708