<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>
댓글 1개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8030 | 9년 전 | 357 | ||
| 8029 | 9년 전 | 296 | ||
| 8028 | 9년 전 | 258 | ||
| 8027 | 9년 전 | 273 | ||
| 8026 | 9년 전 | 326 | ||
| 8025 | 9년 전 | 375 | ||
| 8024 | 9년 전 | 337 | ||
| 8023 | 9년 전 | 386 | ||
| 8022 | 9년 전 | 314 | ||
| 8021 | 9년 전 | 325 | ||
| 8020 | 9년 전 | 312 | ||
| 8019 | 9년 전 | 337 | ||
| 8018 | 9년 전 | 441 | ||
| 8017 | 9년 전 | 534 | ||
| 8016 | 9년 전 | 322 | ||
| 8015 | 9년 전 | 383 | ||
| 8014 | 9년 전 | 319 | ||
| 8013 | 9년 전 | 231 | ||
| 8012 | 9년 전 | 239 | ||
| 8011 | 9년 전 | 442 | ||
| 8010 | 9년 전 | 295 | ||
| 8009 | 9년 전 | 276 | ||
| 8008 | 9년 전 | 282 | ||
| 8007 | 9년 전 | 423 | ||
| 8006 | 9년 전 | 459 | ||
| 8005 |
|
9년 전 | 965 | |
| 8004 | 9년 전 | 349 | ||
| 8003 | 9년 전 | 414 | ||
| 8002 | 9년 전 | 321 | ||
| 8001 |
|
9년 전 | 663 | |
| 8000 | 9년 전 | 411 | ||
| 7999 | 9년 전 | 370 | ||
| 7998 | 9년 전 | 423 | ||
| 7997 | 9년 전 | 306 | ||
| 7996 | 9년 전 | 530 | ||
| 7995 | 9년 전 | 453 | ||
| 7994 | 9년 전 | 321 | ||
| 7993 | 9년 전 | 380 | ||
| 7992 | 9년 전 | 502 | ||
| 7991 | 9년 전 | 246 | ||
| 7990 | 9년 전 | 270 | ||
| 7989 | 9년 전 | 297 | ||
| 7988 | 9년 전 | 720 | ||
| 7987 | 9년 전 | 417 | ||
| 7986 | 9년 전 | 407 | ||
| 7985 | 9년 전 | 506 | ||
| 7984 | 9년 전 | 425 | ||
| 7983 | 9년 전 | 655 | ||
| 7982 | 9년 전 | 508 | ||
| 7981 | 9년 전 | 460 | ||
| 7980 | 9년 전 | 488 | ||
| 7979 | 9년 전 | 460 | ||
| 7978 | 9년 전 | 443 | ||
| 7977 | 9년 전 | 382 | ||
| 7976 | 9년 전 | 845 | ||
| 7975 | 9년 전 | 357 | ||
| 7974 | 9년 전 | 387 | ||
| 7973 | 9년 전 | 591 | ||
| 7972 | 9년 전 | 375 | ||
| 7971 | 9년 전 | 454 | ||
| 7970 | 9년 전 | 290 | ||
| 7969 | 9년 전 | 537 | ||
| 7968 | 9년 전 | 378 | ||
| 7967 | 9년 전 | 363 | ||
| 7966 | 9년 전 | 366 | ||
| 7965 |
|
9년 전 | 1008 | |
| 7964 | 9년 전 | 395 | ||
| 7963 | 9년 전 | 388 | ||
| 7962 | 9년 전 | 368 | ||
| 7961 |
전갈자리남자
|
9년 전 | 502 | |
| 7960 | 9년 전 | 958 | ||
| 7959 | 9년 전 | 548 | ||
| 7958 | 9년 전 | 403 | ||
| 7957 | 9년 전 | 363 | ||
| 7956 | 9년 전 | 365 | ||
| 7955 | 9년 전 | 445 | ||
| 7954 | 9년 전 | 370 | ||
| 7953 | 9년 전 | 421 | ||
| 7952 | 9년 전 | 351 | ||
| 7951 | 9년 전 | 499 | ||
| 7950 | 9년 전 | 382 | ||
| 7949 | 9년 전 | 383 | ||
| 7948 | 9년 전 | 321 | ||
| 7947 | 9년 전 | 927 | ||
| 7946 | 9년 전 | 423 | ||
| 7945 | 9년 전 | 391 | ||
| 7944 | 9년 전 | 415 | ||
| 7943 | 9년 전 | 369 | ||
| 7942 | 9년 전 | 401 | ||
| 7941 | 9년 전 | 384 | ||
| 7940 | 9년 전 | 877 | ||
| 7939 | 9년 전 | 348 | ||
| 7938 | 9년 전 | 378 | ||
| 7937 | 9년 전 | 273 | ||
| 7936 | 9년 전 | 879 | ||
| 7935 | 9년 전 | 441 | ||
| 7934 | 9년 전 | 410 | ||
| 7933 | 9년 전 | 502 | ||
| 7932 | 9년 전 | 472 | ||
| 7931 | 9년 전 | 525 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기