<style>
.g_width, .g_height {width: 100%;}
.g_width td:first-child { width: 10%}
.g_width div { background-color: blue; height: 20px}
.g_height tr:first-child td {height: 300px; vertical-align: bottom}
.g_height div { background-color: blue; width: 20px}
</style>
<table id="graph1" class="g_width">
<tr><td>국어</td><td></td></tr>
<tr><td>영어</td><td></td></tr>
<tr><td>수학</td><td></td></tr>
</table>
<table id="graph2" class="g_height">
<tr><td></td><td></td><td></td></tr>
<tr><td>국어</td><td>영어</td><td>수학</td></tr>
</table>
<script>
function Graph(label) {
this.obj = document.getElementById(label);
this.begin = []; this.end = []; this.div = []; this.vertexes = [];
}
Graph.prototype.display = function(i, way) {
var _this = this, timer= [];
timer[i] = setInterval(function () {
if (_this.begin[i] >= _this.end[i]) clearInterval(timer[i]);
if (way == 'w')
_this.div[i].style.width = _this.begin[i] + '%';
else
_this.div[i].style.height = _this.begin[i] + '%';
_this.begin[i] +=1;
}, 30);
};
Graph.prototype.draw = function(way) {
way == 'w' ? this.width() :this.height();
for (var i=0; i<this.vertexes.length; i++) {
this.begin[i] = 1;
this.end[i] = this.vertexes[i];
this.display(i, way);
}
}
Graph.prototype.width = function() {
for (var i=0; i<this.obj.rows.length; i++) {
var cell = this.obj.rows[i].cells[1];
this.div[i] = document.createElement('div');
cell.appendChild(this.div[i]);
}
}
Graph.prototype.height = function(l) {
for (var i=0; i<this.vertexes.length; i++) {
var cell = this.obj.rows[0].cells[i];
this.div[i] = document.createElement('div');
cell.appendChild(this.div[i]);
}
}
var graph1 = new Graph('graph1');
graph1.vertexes = [10, 90, 40];
graph1.draw('w');
var graph2= new Graph('graph2');
graph2.vertexes = [50, 20, 80];
graph2.draw('h');
</script>
게시글 목록
| 번호 | 제목 |
|---|---|
| 12463 |
JavaScript
이미지 좌우로 이동 갤러리 입니다.
|
| 12462 | |
| 12461 |
JavaScript
쉬운 replaceAll 입니다.
|
| 12460 | |
| 12459 | |
| 12458 | |
| 12457 | |
| 12456 |
JavaScript
콤보스타일 메뉴 입니다.
|
| 12455 |
JavaScript
쿠키를 이용한 레이어 공지창 입니다.
|
| 12454 |
JavaScript
효과있는 텍스트 틱커 입니다.
|
| 12453 | |
| 12452 |
PHP
HTTP 인증 하기 입니다.
|
| 12451 |
JavaScript
외부 문서 불러오기 입니다.
|
| 12450 |
JavaScript
지정한 날짜까지 New 이미지를 띄워주기 입니다.
|
| 12449 | |
| 12448 |
JavaScript
메일 주소 검사하기 체크박스 입니다.
|
| 12447 |
JavaScript
무단링크 금지하기 입니다.
|
| 12446 | |
| 12445 |
MySQL
DB백업 및 복원
|
| 12444 |
JavaScript
페이지가 다른 사이트의 프레임에 갇히는 것을 막기 입니다.
|
| 12443 | |
| 12442 | |
| 12441 |
jQuery
input text 대문자만 받는 Jquery
|
| 12440 | |
| 12439 |
JavaScript
이미지 업로드와 미리보기 입니다.
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기