<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개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 930 | 19년 전 | 3542 | ||
| 929 |
|
19년 전 | 2703 | |
| 928 |
|
19년 전 | 3455 | |
| 927 |
|
19년 전 | 3442 | |
| 926 |
|
19년 전 | 3147 | |
| 925 | 19년 전 | 5432 | ||
| 924 |
|
19년 전 | 2167 | |
| 923 |
|
19년 전 | 2218 | |
| 922 |
|
19년 전 | 2314 | |
| 921 |
|
19년 전 | 3406 | |
| 920 | 19년 전 | 3705 | ||
| 919 |
|
19년 전 | 3746 | |
| 918 |
|
19년 전 | 2361 | |
| 917 |
|
19년 전 | 2397 | |
| 916 |
|
19년 전 | 2700 | |
| 915 | 19년 전 | 3043 | ||
| 914 | 19년 전 | 2457 | ||
| 913 | 19년 전 | 2625 | ||
| 912 | 19년 전 | 2458 | ||
| 911 | 19년 전 | 2213 | ||
| 910 | 19년 전 | 3243 | ||
| 909 | 19년 전 | 3298 | ||
| 908 | 19년 전 | 3033 | ||
| 907 |
|
19년 전 | 4872 | |
| 906 |
|
19년 전 | 2712 | |
| 905 |
|
19년 전 | 3316 | |
| 904 |
|
19년 전 | 3143 | |
| 903 |
|
19년 전 | 1993 | |
| 902 |
|
19년 전 | 3136 | |
| 901 |
|
19년 전 | 1875 | |
| 900 |
|
19년 전 | 2333 | |
| 899 |
|
19년 전 | 2402 | |
| 898 |
|
19년 전 | 3984 | |
| 897 |
|
19년 전 | 3186 | |
| 896 |
|
19년 전 | 3099 | |
| 895 |
|
19년 전 | 2536 | |
| 894 |
|
19년 전 | 2013 | |
| 893 |
|
19년 전 | 1643 | |
| 892 |
|
19년 전 | 2411 | |
| 891 |
|
19년 전 | 2330 | |
| 890 |
|
19년 전 | 1814 | |
| 889 |
|
19년 전 | 1810 | |
| 888 |
|
19년 전 | 2608 | |
| 887 |
|
19년 전 | 2580 | |
| 886 |
|
19년 전 | 1874 | |
| 885 |
|
19년 전 | 2111 | |
| 884 |
|
19년 전 | 3300 | |
| 883 |
|
19년 전 | 1951 | |
| 882 |
|
19년 전 | 2498 | |
| 881 |
|
19년 전 | 2579 | |
| 880 |
|
19년 전 | 2661 | |
| 879 |
|
19년 전 | 2939 | |
| 878 |
|
19년 전 | 2559 | |
| 877 |
|
19년 전 | 2983 | |
| 876 |
|
19년 전 | 2761 | |
| 875 |
|
19년 전 | 3522 | |
| 874 | 19년 전 | 1870 | ||
| 873 | 19년 전 | 2734 | ||
| 872 |
|
19년 전 | 2372 | |
| 871 |
|
19년 전 | 2016 | |
| 870 |
|
19년 전 | 2427 | |
| 869 |
|
19년 전 | 1871 | |
| 868 |
|
19년 전 | 5438 | |
| 867 |
|
19년 전 | 2258 | |
| 866 |
|
19년 전 | 4259 | |
| 865 |
|
19년 전 | 2302 | |
| 864 | 19년 전 | 1846 | ||
| 863 | 19년 전 | 2602 | ||
| 862 | 19년 전 | 2331 | ||
| 861 | 19년 전 | 2533 | ||
| 860 | 19년 전 | 2159 | ||
| 859 | 19년 전 | 3922 | ||
| 858 | 19년 전 | 3416 | ||
| 857 | 19년 전 | 2198 | ||
| 856 |
Power
|
19년 전 | 2106 | |
| 855 | 19년 전 | 1971 | ||
| 854 | 19년 전 | 1999 | ||
| 853 |
pearly
|
19년 전 | 4384 | |
| 852 |
pearly
|
19년 전 | 3356 | |
| 851 | 19년 전 | 2773 | ||
| 850 |
pearly
|
19년 전 | 3353 | |
| 849 |
pearly
|
19년 전 | 3013 | |
| 848 |
pearly
|
19년 전 | 2841 | |
| 847 | 19년 전 | 2358 | ||
| 846 |
|
19년 전 | 2169 | |
| 845 |
pearly
|
19년 전 | 2490 | |
| 844 | 19년 전 | 3098 | ||
| 843 | 19년 전 | 2130 | ||
| 842 |
pearly
|
19년 전 | 3122 | |
| 841 |
pearly
|
19년 전 | 3244 | |
| 840 | 19년 전 | 2925 | ||
| 839 |
|
19년 전 | 1940 | |
| 838 |
|
19년 전 | 1704 | |
| 837 |
|
19년 전 | 2324 | |
| 836 |
|
19년 전 | 2266 | |
| 835 |
|
19년 전 | 1642 | |
| 834 |
|
19년 전 | 1666 | |
| 833 |
|
19년 전 | 1570 | |
| 832 |
|
19년 전 | 2067 | |
| 831 |
|
19년 전 | 1616 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기