<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개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7930 | 9년 전 | 439 | ||
| 7929 | 9년 전 | 373 | ||
| 7928 | 9년 전 | 456 | ||
| 7927 | 9년 전 | 370 | ||
| 7926 | 9년 전 | 680 | ||
| 7925 | 9년 전 | 393 | ||
| 7924 | 9년 전 | 377 | ||
| 7923 | 9년 전 | 371 | ||
| 7922 | 9년 전 | 404 | ||
| 7921 | 9년 전 | 421 | ||
| 7920 | 9년 전 | 337 | ||
| 7919 | 9년 전 | 347 | ||
| 7918 | 9년 전 | 502 | ||
| 7917 | 9년 전 | 353 | ||
| 7916 | 9년 전 | 438 | ||
| 7915 | 9년 전 | 440 | ||
| 7914 | 9년 전 | 450 | ||
| 7913 | 9년 전 | 624 | ||
| 7912 | 9년 전 | 455 | ||
| 7911 | 9년 전 | 390 | ||
| 7910 | 9년 전 | 436 | ||
| 7909 | 9년 전 | 540 | ||
| 7908 | 9년 전 | 478 | ||
| 7907 | 9년 전 | 415 | ||
| 7906 | 9년 전 | 433 | ||
| 7905 | 9년 전 | 403 | ||
| 7904 | 9년 전 | 388 | ||
| 7903 | 9년 전 | 386 | ||
| 7902 | 9년 전 | 584 | ||
| 7901 |
|
9년 전 | 762 | |
| 7900 | 9년 전 | 633 | ||
| 7899 | 9년 전 | 418 | ||
| 7898 | 9년 전 | 423 | ||
| 7897 | 9년 전 | 377 | ||
| 7896 | 9년 전 | 392 | ||
| 7895 | 9년 전 | 506 | ||
| 7894 | 9년 전 | 423 | ||
| 7893 | 9년 전 | 392 | ||
| 7892 | 9년 전 | 428 | ||
| 7891 | 9년 전 | 792 | ||
| 7890 | 9년 전 | 1224 | ||
| 7889 | 9년 전 | 761 | ||
| 7888 |
limsy1987
|
9년 전 | 571 | |
| 7887 | 9년 전 | 596 | ||
| 7886 | 9년 전 | 491 | ||
| 7885 | 9년 전 | 446 | ||
| 7884 | 9년 전 | 445 | ||
| 7883 | 9년 전 | 450 | ||
| 7882 | 9년 전 | 508 | ||
| 7881 | 9년 전 | 475 | ||
| 7880 | 9년 전 | 605 | ||
| 7879 | 9년 전 | 496 | ||
| 7878 | 9년 전 | 1263 | ||
| 7877 | 9년 전 | 790 | ||
| 7876 | 9년 전 | 528 | ||
| 7875 | 9년 전 | 603 | ||
| 7874 |
|
9년 전 | 825 | |
| 7873 | 9년 전 | 540 | ||
| 7872 | 9년 전 | 705 | ||
| 7871 | 9년 전 | 521 | ||
| 7870 | 9년 전 | 642 | ||
| 7869 | 9년 전 | 456 | ||
| 7868 | 9년 전 | 487 | ||
| 7867 | 9년 전 | 483 | ||
| 7866 | 9년 전 | 539 | ||
| 7865 | 9년 전 | 482 | ||
| 7864 | 9년 전 | 548 | ||
| 7863 | 9년 전 | 546 | ||
| 7862 | 9년 전 | 499 | ||
| 7861 | 9년 전 | 678 | ||
| 7860 | 9년 전 | 655 | ||
| 7859 | 9년 전 | 436 | ||
| 7858 | 9년 전 | 738 | ||
| 7857 | 9년 전 | 1122 | ||
| 7856 | 9년 전 | 555 | ||
| 7855 | 9년 전 | 783 | ||
| 7854 | 9년 전 | 742 | ||
| 7853 | 9년 전 | 627 | ||
| 7852 | 9년 전 | 553 | ||
| 7851 | 9년 전 | 541 | ||
| 7850 | 9년 전 | 621 | ||
| 7849 | 9년 전 | 388 | ||
| 7848 | 9년 전 | 458 | ||
| 7847 | 9년 전 | 697 | ||
| 7846 | 9년 전 | 488 | ||
| 7845 | 9년 전 | 457 | ||
| 7844 | 9년 전 | 428 | ||
| 7843 | 9년 전 | 467 | ||
| 7842 | 9년 전 | 441 | ||
| 7841 | 9년 전 | 417 | ||
| 7840 | 9년 전 | 430 | ||
| 7839 | 9년 전 | 472 | ||
| 7838 | 9년 전 | 536 | ||
| 7837 | 9년 전 | 380 | ||
| 7836 | 9년 전 | 432 | ||
| 7835 | 9년 전 | 507 | ||
| 7834 |
|
9년 전 | 1218 | |
| 7833 | 10년 전 | 472 | ||
| 7832 | 10년 전 | 454 | ||
| 7831 | 10년 전 | 608 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기