JS百分比图和柱状图 </p> <p> v\:* {behavior=url(#default#VML)} </p> <p> </p> <p>a:hover {color:maroon} </p> <p>h2 {color:#006600; </p> <p> margin-top: 0pt; </p> <p> margin-bottom: 0pt} </p> <p>h3 {color:#006600; </p> <p> margin-top: 6pt; </p> <p> margin-bottom: 3pt} </p> <p>h4 {color:#006600; </p> <p> font-family: Arial; </p> <p> font-size: 10pt; </p> <p> margin-top: 3pt; </p> <p> margin-bottom: 0pt} </p> <p>h5 {color:#006600; </p> <p> margin-top: 0pt; </p> <p> margin-bottom: 0pt} </p> <p>p {margin-top: 0pt; </p> <p> margin-bottom: 12pt} </p> <p> </p> <p> p.Chart {font-size:8pt; font-family:"Times"; color:black; text-align:right; } Sample Piechart Random numbers drawn as a simple pie One: 30 Two: 18 Three: 13 Four: 9 Five: 5 </p> <p>function displayTitle( title ) </p> <p>{ </p> <p> document.write("<center><i>" + title + "</i></center><br>"); </p> <p>} </p> <p> </p> <p>function generateRandomNumber(num) { </p> <p> return Math.round( Math.random() * (num - 1) ) + 1; </p> <p>} </p> <p> </p> <p>function plottablehead( val ) </p> <p>{ </p> <p> document.writeln("<table border = 0 bgcolor = black width = 10 height = 10 cellpadding = 0 cellspacing = 0>"); </p> <p> document.write("<tr> <i>" + val + "</i>"); </p> <p>} </p> <p> </p> <p>function plottabletail() </p> <p>{ </p> <p> document.write("</tr></table><br>"); </p> <p>} </p> <p> </p> <p>function plotcolor(d, clr) </p> <p>{ </p> <p> for(i=1;i<=d;i++){ </p><p> document.write("<td bgcolor = " + clr + "> </td>"); </p> <p> } </p> <p>} </p> <p> </p> <p>function setColor(foreground,background) </p> <p>{ </p> <p> document.fgColor=foreground; </p> <p> document.bgColor=background; </p> <p>} </p> <p> </p> <p>setColor("orange","black"); </p> <p>a=generateRandomNumber(50); </p> <p>plottablehead( a ); </p> <p>plotcolor(a, "red"); </p> <p>plottabletail(); </p> <p>a=generateRandomNumber(50); </p> <p>plottablehead( a ); </p> <p>plotcolor(a, "blue"); </p> <p>plottabletail(); </p> <p>a=generateRandomNumber(50); </p> <p>plottablehead( a ); </p> <p>plotcolor(a, "green"); </p> <p>plottabletail(); </p> <p>a=generateRandomNumber(50); </p> <p>plottablehead( a ); </p> <p>plotcolor(a, "yellow"); </p> <p>plottabletail(); </p> <p>a=generateRandomNumber(50); </p> <p>plottablehead( a ); </p> <p>plotcolor(a, "gray"); </p> <p>plottabletail(); </p> <p>a=generateRandomNumber(50); </p> <p>plottablehead( a ); </p> <p>plotcolor(a, "midnightblue"); </p> <p>plottabletail(); </p> <p>//--> </p> <p>