Jump to content

Bar Chart And Percentage


inktherapy

Recommended Posts

Hi,Kindly see my codes below, I made a bar chart creator that displays the chart and its percentage, but I have 2 problems:1. I want to sum all the data entered to 100% only, my formula would be like adding all entered datas and set its fraction but I don't know where to place it?2. How can I save the final output as an HTML so I can copy/paste it or transfer for viewing purposes?

 <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>Chart/Bar Graph</title><script type="text/javascript">var x = new Array();var a = new Array();var y = 1;function enData() {	for (i=0; i<y; i++) {		x[i] = parseInt(prompt("Enter number data"));		a[i] = Math.round(Math.random()*99);		z = confirm("Enter another number?");			if (z == true) {				y++;				} else { 						for (i in x) {						document.write("<div style='height:15px; width:" + x[i] + "px; background-color:#85CA" + a[i] + ";'>" + x[i] + "%</div>" + "<br />");						}		}	}}window.onload = enData();</script></head><body></body></html>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...