<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개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 330 |
prosper
|
20년 전 | 2285 | |
| 329 |
prosper
|
20년 전 | 1914 | |
| 328 |
prosper
|
20년 전 | 1707 | |
| 327 | 20년 전 | 3774 | ||
| 326 | 20년 전 | 4860 | ||
| 325 |
hwatta
|
20년 전 | 2486 | |
| 324 |
|
20년 전 | 3148 | |
| 323 | 20년 전 | 5869 | ||
| 322 |
hwatta
|
20년 전 | 2855 | |
| 321 |
hwatta
|
20년 전 | 2326 | |
| 320 |
yesmoa
|
20년 전 | 4578 | |
| 319 | 20년 전 | 2692 | ||
| 318 | 20년 전 | 2243 | ||
| 317 |
kyodon
|
20년 전 | 2765 | |
| 316 | 20년 전 | 2587 | ||
| 315 |
|
20년 전 | 2888 | |
| 314 |
|
20년 전 | 3345 | |
| 313 |
|
20년 전 | 2651 | |
| 312 |
yesmoa
|
20년 전 | 4725 | |
| 311 | 20년 전 | 3281 | ||
| 310 |
홀로남은자
|
20년 전 | 4571 | |
| 309 | 20년 전 | 3010 | ||
| 308 | 20년 전 | 4141 | ||
| 307 | 20년 전 | 4377 | ||
| 306 | 20년 전 | 7039 | ||
| 305 | 20년 전 | 3872 | ||
| 304 | 20년 전 | 2774 | ||
| 303 |
크리스탈처럼
|
20년 전 | 4409 | |
| 302 | 20년 전 | 2210 | ||
| 301 |
|
20년 전 | 4328 | |
| 300 | 20년 전 | 3813 | ||
| 299 | 20년 전 | 2623 | ||
| 298 | 20년 전 | 4836 | ||
| 297 |
|
20년 전 | 2531 | |
| 296 | 20년 전 | 4536 | ||
| 295 | 20년 전 | 3573 | ||
| 294 | 20년 전 | 3596 | ||
| 293 | 20년 전 | 3821 | ||
| 292 | 20년 전 | 3215 | ||
| 291 |
yesmoa
|
20년 전 | 5945 | |
| 290 | 20년 전 | 2942 | ||
| 289 | 20년 전 | 5865 | ||
| 288 |
|
20년 전 | 2383 | |
| 287 |
|
20년 전 | 1814 | |
| 286 |
|
20년 전 | 2152 | |
| 285 |
|
20년 전 | 3545 | |
| 284 |
|
20년 전 | 2039 | |
| 283 |
|
20년 전 | 4405 | |
| 282 | 20년 전 | 3383 | ||
| 281 |
|
20년 전 | 2216 | |
| 280 |
|
20년 전 | 7812 | |
| 279 | 20년 전 | 5562 | ||
| 278 | 20년 전 | 2999 | ||
| 277 |
|
20년 전 | 5574 | |
| 276 | 20년 전 | 2363 | ||
| 275 | 20년 전 | 2614 | ||
| 274 | 20년 전 | 2398 | ||
| 273 | 20년 전 | 2230 | ||
| 272 | 20년 전 | 2157 | ||
| 271 | 20년 전 | 2615 | ||
| 270 | 20년 전 | 2647 | ||
| 269 | 20년 전 | 2491 | ||
| 268 | 20년 전 | 2694 | ||
| 267 | 20년 전 | 2381 | ||
| 266 | 20년 전 | 2571 | ||
| 265 | 20년 전 | 3516 | ||
| 264 |
|
20년 전 | 5376 | |
| 263 |
|
20년 전 | 3736 | |
| 262 | 20년 전 | 3197 | ||
| 261 |
허저비
|
20년 전 | 5943 | |
| 260 |
|
20년 전 | 5722 | |
| 259 | 20년 전 | 4147 | ||
| 258 | 20년 전 | 2381 | ||
| 257 | 20년 전 | 3200 | ||
| 256 | 20년 전 | 1914 | ||
| 255 | 20년 전 | 1584 | ||
| 254 | 20년 전 | 3156 | ||
| 253 | 20년 전 | 3550 | ||
| 252 | 20년 전 | 5131 | ||
| 251 | 20년 전 | 5825 | ||
| 250 | 20년 전 | 3682 | ||
| 249 | 20년 전 | 5028 | ||
| 248 | 20년 전 | 3296 | ||
| 247 | 20년 전 | 3654 | ||
| 246 |
|
20년 전 | 7965 | |
| 245 |
|
20년 전 | 5925 | |
| 244 | 20년 전 | 4498 | ||
| 243 |
|
20년 전 | 4072 | |
| 242 | 20년 전 | 2798 | ||
| 241 | 20년 전 | 2746 | ||
| 240 | 20년 전 | 2383 | ||
| 239 | 20년 전 | 1673 | ||
| 238 |
아우겐나이스
|
20년 전 | 2283 | |
| 237 |
email
|
20년 전 | 3695 | |
| 236 | 20년 전 | 4173 | ||
| 235 | 20년 전 | 10474 | ||
| 234 | 20년 전 | 5082 | ||
| 233 | 20년 전 | 3385 | ||
| 232 | 20년 전 | 3225 | ||
| 231 | 20년 전 | 3861 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기