<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년 전 | 2257 | |
| 329 |
prosper
|
20년 전 | 1871 | |
| 328 |
prosper
|
20년 전 | 1682 | |
| 327 | 20년 전 | 3751 | ||
| 326 | 20년 전 | 4838 | ||
| 325 |
hwatta
|
20년 전 | 2462 | |
| 324 |
|
20년 전 | 3132 | |
| 323 | 20년 전 | 5844 | ||
| 322 |
hwatta
|
20년 전 | 2831 | |
| 321 |
hwatta
|
20년 전 | 2307 | |
| 320 |
yesmoa
|
20년 전 | 4561 | |
| 319 | 20년 전 | 2671 | ||
| 318 | 20년 전 | 2231 | ||
| 317 |
kyodon
|
20년 전 | 2755 | |
| 316 | 20년 전 | 2568 | ||
| 315 |
|
20년 전 | 2876 | |
| 314 |
|
20년 전 | 3325 | |
| 313 |
|
20년 전 | 2633 | |
| 312 |
yesmoa
|
20년 전 | 4704 | |
| 311 | 20년 전 | 3258 | ||
| 310 |
홀로남은자
|
20년 전 | 4551 | |
| 309 | 20년 전 | 3002 | ||
| 308 | 20년 전 | 4117 | ||
| 307 | 20년 전 | 4354 | ||
| 306 | 20년 전 | 7024 | ||
| 305 | 20년 전 | 3863 | ||
| 304 | 20년 전 | 2757 | ||
| 303 |
크리스탈처럼
|
20년 전 | 4386 | |
| 302 | 20년 전 | 2198 | ||
| 301 |
|
20년 전 | 4314 | |
| 300 | 20년 전 | 3787 | ||
| 299 | 20년 전 | 2592 | ||
| 298 | 20년 전 | 4816 | ||
| 297 |
|
20년 전 | 2520 | |
| 296 | 20년 전 | 4516 | ||
| 295 | 20년 전 | 3561 | ||
| 294 | 20년 전 | 3584 | ||
| 293 | 20년 전 | 3812 | ||
| 292 | 20년 전 | 3198 | ||
| 291 |
yesmoa
|
20년 전 | 5931 | |
| 290 | 20년 전 | 2931 | ||
| 289 | 20년 전 | 5841 | ||
| 288 |
|
20년 전 | 2369 | |
| 287 |
|
20년 전 | 1783 | |
| 286 |
|
20년 전 | 2139 | |
| 285 |
|
20년 전 | 3529 | |
| 284 |
|
20년 전 | 2028 | |
| 283 |
|
20년 전 | 4397 | |
| 282 | 20년 전 | 3380 | ||
| 281 |
|
20년 전 | 2203 | |
| 280 |
|
20년 전 | 7795 | |
| 279 | 20년 전 | 5541 | ||
| 278 | 20년 전 | 2983 | ||
| 277 |
|
20년 전 | 5567 | |
| 276 | 20년 전 | 2351 | ||
| 275 | 20년 전 | 2598 | ||
| 274 | 20년 전 | 2373 | ||
| 273 | 20년 전 | 2208 | ||
| 272 | 20년 전 | 2142 | ||
| 271 | 20년 전 | 2597 | ||
| 270 | 20년 전 | 2615 | ||
| 269 | 20년 전 | 2476 | ||
| 268 | 20년 전 | 2673 | ||
| 267 | 20년 전 | 2357 | ||
| 266 | 20년 전 | 2559 | ||
| 265 | 20년 전 | 3496 | ||
| 264 |
|
20년 전 | 5354 | |
| 263 |
|
20년 전 | 3720 | |
| 262 | 20년 전 | 3169 | ||
| 261 |
허저비
|
20년 전 | 5918 | |
| 260 |
|
20년 전 | 5709 | |
| 259 | 20년 전 | 4133 | ||
| 258 | 20년 전 | 2374 | ||
| 257 | 20년 전 | 3182 | ||
| 256 | 20년 전 | 1895 | ||
| 255 | 20년 전 | 1560 | ||
| 254 | 20년 전 | 3136 | ||
| 253 | 20년 전 | 3542 | ||
| 252 | 20년 전 | 5116 | ||
| 251 | 20년 전 | 5802 | ||
| 250 | 20년 전 | 3670 | ||
| 249 | 20년 전 | 5011 | ||
| 248 | 20년 전 | 3278 | ||
| 247 | 20년 전 | 3631 | ||
| 246 |
|
20년 전 | 7944 | |
| 245 |
|
20년 전 | 5897 | |
| 244 | 20년 전 | 4483 | ||
| 243 |
|
20년 전 | 4045 | |
| 242 | 20년 전 | 2779 | ||
| 241 | 20년 전 | 2719 | ||
| 240 | 20년 전 | 2357 | ||
| 239 | 20년 전 | 1652 | ||
| 238 |
아우겐나이스
|
20년 전 | 2259 | |
| 237 |
email
|
20년 전 | 3683 | |
| 236 | 20년 전 | 4145 | ||
| 235 | 20년 전 | 10458 | ||
| 234 | 20년 전 | 5061 | ||
| 233 | 20년 전 | 3362 | ||
| 232 | 20년 전 | 3196 | ||
| 231 | 20년 전 | 3833 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기