グラフ
ラーメン
冷麺
そば

グラフを作成します


<HTML>
<HEAD>

<SCRIPT language="JavaScript">
<!--
function CloseWin(){
window.close();
}
// -->
</SCRIPT>

<script>
var graphimage="bar.gif"
amount=new Array();
function showGraph(){
amount[0]=["ラーメン",document.form1.n1.value];
amount[1]=["冷麺",document.form1.n2.value];
amount[2]=["そば",document.form1.n3.value];
drawGraph(amount,400);
}
function drawGraph(g,gwidth){
document.write("<h2>数と割合</h2>")
total=0
for(i=0;i<g.length;i++) total+=parseInt(g[i][1]);
output="<table>";
for (i=0;i<g.length;i++){
percentage=Math.round(g[i][1]*100/total);
calwidth=Math.round(gwidth*(percentage/100));
output+="<tr><td>"+g[i][0]+"</td>";
output+="<td><img src='"+graphimage+"' width='"+calwidth+"' height='10'> ";
output+=g[i][1]+"("+percentage+"%)</td></tr>";
}
output+="</table>";
document.write(output+"<BR>合計: <B>"+total+"</B>")
document.close();
}
</script>
</head>
<BODY bgcolor="#ffff00" background="htm2.files/148.gif">
<form name="form1">
<CENTER>
<STRONG>
<font size=+3 color=#ff0000>グラフ</font></STRONG>
<HR>
<TABLE>

<tr>
<td><STRONG>ラーメン</STRONG></td>
<td><STRONG><input type="text" name="n1">杯</STRONG></td>
</tr>
<tr>
<td><STRONG>冷麺</STRONG></td>
<td><STRONG><input type="text" name="n2">杯</STRONG></td>
</tr>
<tr>
<td><STRONG>そば</STRONG></td>
<td><STRONG><input type="text" name="n3">杯</STRONG></td>
</tr>

</TABLE>
<P><STRONG><input type="button" value="グラフ表示" onClick="showGraph()"></STRONG></P>
</CENTER>
</form>
<p><font color=#db7093>グラフを作成します</font></p>
<hr>

</BODY>
</html>