<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년 전 | 2258 | |
| 329 |
prosper
|
20년 전 | 1877 | |
| 328 |
prosper
|
20년 전 | 1685 | |
| 327 | 20년 전 | 3751 | ||
| 326 | 20년 전 | 4841 | ||
| 325 |
hwatta
|
20년 전 | 2466 | |
| 324 |
|
20년 전 | 3136 | |
| 323 | 20년 전 | 5845 | ||
| 322 |
hwatta
|
20년 전 | 2833 | |
| 321 |
hwatta
|
20년 전 | 2308 | |
| 320 |
yesmoa
|
20년 전 | 4563 | |
| 319 | 20년 전 | 2676 | ||
| 318 | 20년 전 | 2233 | ||
| 317 |
kyodon
|
20년 전 | 2756 | |
| 316 | 20년 전 | 2570 | ||
| 315 |
|
20년 전 | 2876 | |
| 314 |
|
20년 전 | 3329 | |
| 313 |
|
20년 전 | 2633 | |
| 312 |
yesmoa
|
20년 전 | 4706 | |
| 311 | 20년 전 | 3260 | ||
| 310 |
홀로남은자
|
20년 전 | 4554 | |
| 309 | 20년 전 | 3002 | ||
| 308 | 20년 전 | 4119 | ||
| 307 | 20년 전 | 4360 | ||
| 306 | 20년 전 | 7026 | ||
| 305 | 20년 전 | 3864 | ||
| 304 | 20년 전 | 2759 | ||
| 303 |
크리스탈처럼
|
20년 전 | 4389 | |
| 302 | 20년 전 | 2199 | ||
| 301 |
|
20년 전 | 4314 | |
| 300 | 20년 전 | 3793 | ||
| 299 | 20년 전 | 2596 | ||
| 298 | 20년 전 | 4817 | ||
| 297 |
|
20년 전 | 2521 | |
| 296 | 20년 전 | 4521 | ||
| 295 | 20년 전 | 3564 | ||
| 294 | 20년 전 | 3587 | ||
| 293 | 20년 전 | 3813 | ||
| 292 | 20년 전 | 3199 | ||
| 291 |
yesmoa
|
20년 전 | 5933 | |
| 290 | 20년 전 | 2931 | ||
| 289 | 20년 전 | 5843 | ||
| 288 |
|
20년 전 | 2372 | |
| 287 |
|
20년 전 | 1791 | |
| 286 |
|
20년 전 | 2139 | |
| 285 |
|
20년 전 | 3529 | |
| 284 |
|
20년 전 | 2028 | |
| 283 |
|
20년 전 | 4399 | |
| 282 | 20년 전 | 3380 | ||
| 281 |
|
20년 전 | 2204 | |
| 280 |
|
20년 전 | 7796 | |
| 279 | 20년 전 | 5543 | ||
| 278 | 20년 전 | 2986 | ||
| 277 |
|
20년 전 | 5568 | |
| 276 | 20년 전 | 2354 | ||
| 275 | 20년 전 | 2599 | ||
| 274 | 20년 전 | 2375 | ||
| 273 | 20년 전 | 2209 | ||
| 272 | 20년 전 | 2146 | ||
| 271 | 20년 전 | 2597 | ||
| 270 | 20년 전 | 2619 | ||
| 269 | 20년 전 | 2477 | ||
| 268 | 20년 전 | 2676 | ||
| 267 | 20년 전 | 2360 | ||
| 266 | 20년 전 | 2560 | ||
| 265 | 20년 전 | 3498 | ||
| 264 |
|
20년 전 | 5358 | |
| 263 |
|
20년 전 | 3721 | |
| 262 | 20년 전 | 3172 | ||
| 261 |
허저비
|
20년 전 | 5922 | |
| 260 |
|
20년 전 | 5710 | |
| 259 | 20년 전 | 4135 | ||
| 258 | 20년 전 | 2375 | ||
| 257 | 20년 전 | 3185 | ||
| 256 | 20년 전 | 1895 | ||
| 255 | 20년 전 | 1563 | ||
| 254 | 20년 전 | 3140 | ||
| 253 | 20년 전 | 3542 | ||
| 252 | 20년 전 | 5117 | ||
| 251 | 20년 전 | 5804 | ||
| 250 | 20년 전 | 3671 | ||
| 249 | 20년 전 | 5012 | ||
| 248 | 20년 전 | 3279 | ||
| 247 | 20년 전 | 3633 | ||
| 246 |
|
20년 전 | 7946 | |
| 245 |
|
20년 전 | 5903 | |
| 244 | 20년 전 | 4485 | ||
| 243 |
|
20년 전 | 4047 | |
| 242 | 20년 전 | 2782 | ||
| 241 | 20년 전 | 2722 | ||
| 240 | 20년 전 | 2360 | ||
| 239 | 20년 전 | 1655 | ||
| 238 |
아우겐나이스
|
20년 전 | 2262 | |
| 237 |
email
|
20년 전 | 3685 | |
| 236 | 20년 전 | 4148 | ||
| 235 | 20년 전 | 10461 | ||
| 234 | 20년 전 | 5065 | ||
| 233 | 20년 전 | 3366 | ||
| 232 | 20년 전 | 3199 | ||
| 231 | 20년 전 | 3838 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기