<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년 전 | 415 | ||
| 7929 | 9년 전 | 333 | ||
| 7928 | 9년 전 | 421 | ||
| 7927 | 9년 전 | 339 | ||
| 7926 | 9년 전 | 669 | ||
| 7925 | 9년 전 | 356 | ||
| 7924 | 9년 전 | 337 | ||
| 7923 | 9년 전 | 347 | ||
| 7922 | 9년 전 | 383 | ||
| 7921 | 9년 전 | 400 | ||
| 7920 | 9년 전 | 322 | ||
| 7919 | 9년 전 | 334 | ||
| 7918 | 9년 전 | 491 | ||
| 7917 | 9년 전 | 334 | ||
| 7916 | 9년 전 | 410 | ||
| 7915 | 9년 전 | 407 | ||
| 7914 | 9년 전 | 419 | ||
| 7913 | 9년 전 | 580 | ||
| 7912 | 9년 전 | 423 | ||
| 7911 | 9년 전 | 369 | ||
| 7910 | 9년 전 | 415 | ||
| 7909 | 9년 전 | 510 | ||
| 7908 | 9년 전 | 431 | ||
| 7907 | 9년 전 | 373 | ||
| 7906 | 9년 전 | 397 | ||
| 7905 | 9년 전 | 376 | ||
| 7904 | 9년 전 | 356 | ||
| 7903 | 9년 전 | 349 | ||
| 7902 | 9년 전 | 564 | ||
| 7901 |
|
9년 전 | 740 | |
| 7900 | 9년 전 | 591 | ||
| 7899 | 9년 전 | 387 | ||
| 7898 | 9년 전 | 388 | ||
| 7897 | 9년 전 | 349 | ||
| 7896 | 9년 전 | 364 | ||
| 7895 | 9년 전 | 469 | ||
| 7894 | 9년 전 | 394 | ||
| 7893 | 9년 전 | 342 | ||
| 7892 | 9년 전 | 398 | ||
| 7891 | 9년 전 | 766 | ||
| 7890 | 9년 전 | 1196 | ||
| 7889 | 9년 전 | 748 | ||
| 7888 |
limsy1987
|
9년 전 | 548 | |
| 7887 | 9년 전 | 553 | ||
| 7886 | 9년 전 | 443 | ||
| 7885 | 9년 전 | 412 | ||
| 7884 | 9년 전 | 414 | ||
| 7883 | 9년 전 | 404 | ||
| 7882 | 9년 전 | 456 | ||
| 7881 | 9년 전 | 444 | ||
| 7880 | 9년 전 | 571 | ||
| 7879 | 9년 전 | 467 | ||
| 7878 | 9년 전 | 1222 | ||
| 7877 | 9년 전 | 752 | ||
| 7876 | 9년 전 | 492 | ||
| 7875 | 9년 전 | 561 | ||
| 7874 |
|
9년 전 | 811 | |
| 7873 | 9년 전 | 524 | ||
| 7872 | 9년 전 | 680 | ||
| 7871 | 9년 전 | 487 | ||
| 7870 | 9년 전 | 611 | ||
| 7869 | 9년 전 | 437 | ||
| 7868 | 9년 전 | 450 | ||
| 7867 | 9년 전 | 431 | ||
| 7866 | 9년 전 | 492 | ||
| 7865 | 9년 전 | 458 | ||
| 7864 | 9년 전 | 515 | ||
| 7863 | 9년 전 | 511 | ||
| 7862 | 9년 전 | 467 | ||
| 7861 | 9년 전 | 642 | ||
| 7860 | 9년 전 | 629 | ||
| 7859 | 9년 전 | 412 | ||
| 7858 | 9년 전 | 705 | ||
| 7857 | 9년 전 | 1080 | ||
| 7856 | 9년 전 | 527 | ||
| 7855 | 9년 전 | 756 | ||
| 7854 | 9년 전 | 732 | ||
| 7853 | 9년 전 | 582 | ||
| 7852 | 9년 전 | 509 | ||
| 7851 | 9년 전 | 510 | ||
| 7850 | 9년 전 | 586 | ||
| 7849 | 9년 전 | 357 | ||
| 7848 | 9년 전 | 412 | ||
| 7847 | 9년 전 | 656 | ||
| 7846 | 9년 전 | 460 | ||
| 7845 | 9년 전 | 421 | ||
| 7844 | 9년 전 | 393 | ||
| 7843 | 9년 전 | 420 | ||
| 7842 | 9년 전 | 401 | ||
| 7841 | 9년 전 | 385 | ||
| 7840 | 9년 전 | 406 | ||
| 7839 | 9년 전 | 437 | ||
| 7838 | 9년 전 | 519 | ||
| 7837 | 9년 전 | 358 | ||
| 7836 | 9년 전 | 399 | ||
| 7835 | 9년 전 | 475 | ||
| 7834 |
|
9년 전 | 1196 | |
| 7833 | 9년 전 | 433 | ||
| 7832 | 9년 전 | 419 | ||
| 7831 | 9년 전 | 565 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기