확

그래프 만들기-gd 안쓰고

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

<?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,187건
+
제목 글쓴이 날짜 조회
07-07-16 조회 3,128
07-07-06 조회 3,020
07-07-06 조회 3,453
07-06-23 조회 3,279
07-06-16 조회 2,784
07-05-20 조회 4,305
07-05-09 조회 3,475
07-05-09 조회 6,119
07-05-04 조회 2,713
07-04-30 조회 9,848
07-04-27 조회 4,345
07-04-26 조회 3,463
07-04-25 조회 5,312
07-04-18 조회 7,805
07-04-13 조회 3,142
07-04-12 조회 6,648
07-04-12 조회 5,067
07-04-12 조회 3,380
07-04-11 조회 5,734
07-04-05 조회 6,377
07-03-24 조회 4,437
07-03-20 조회 3,757
07-03-18 조회 4,001
07-03-18 조회 4,745
07-03-17 조회 4,247
07-03-16 조회 4,147
07-03-15 조회 5,311
07-03-13 조회 5,414
07-03-13 조회 3,594
07-03-08 조회 4,513
07-03-08 조회 4,003
07-03-08 조회 3,310
07-03-08 조회 4,201
07-03-05 조회 4,456
07-03-04 조회 2,925
07-03-01 조회 5,958
07-02-28 조회 3,243
07-02-27 조회 4,424
07-02-26 조회 3,346
07-02-26 조회 3,055
07-02-23 조회 3,686
07-02-23 조회 3,650
07-02-22 조회 4,034
07-02-22 조회 3,854
07-02-19 조회 3,860
07-02-17 조회 4,883
07-02-14 조회 8,193
07-02-12 조회 3,956
07-02-10 조회 3,590
07-02-02 조회 3,825
07-01-31 조회 3,504
07-01-29 조회 3,366
07-01-25 조회 5,132
07-01-21 조회 3,280
07-01-19 조회 3,071
06-12-15 조회 4,084
06-12-15 조회 4,483
06-12-15 조회 2,973
06-12-15 조회 4,523
06-12-15 조회 3,406
06-12-15 조회 4,107
06-12-15 조회 3,067
06-12-15 조회 2,786
06-12-15 조회 4,643
06-12-15 조회 3,196
06-12-15 조회 3,296
06-12-07 조회 4,747
06-12-07 조회 4,030
06-12-04 조회 4,681
06-11-27 조회 3,721
06-11-21 조회 4,025
06-11-15 조회 3,463
06-11-04 조회 3,357
06-10-29 조회 4,007
06-10-13 조회 3,875
06-10-13 조회 4,237
06-10-13 조회 4,189
06-10-12 조회 5,384
06-10-12 조회 4,303
06-10-04 조회 3,799
06-10-02 조회 4,575
06-09-29 조회 3,059
06-09-26 조회 3,409
06-09-26 조회 3,671
06-09-26 조회 3,309
06-09-26 조회 3,460
06-09-26 조회 4,372
06-09-25 조회 4,664
06-09-22 조회 5,007
06-09-22 조회 3,572
06-09-21 조회 4,350
06-09-21 조회 4,355
06-09-21 조회 3,558
06-09-21 조회 5,209
06-09-21 조회 3,735
06-09-21 조회 3,467
06-09-20 조회 3,056
06-09-15 조회 3,178
06-09-13 조회 3,490
06-09-11 조회 3,294