Farebeny stlpcovy graf (2)

ID
Nazov / Name:
Popis / Description:
Dlzka / Length:
Testovane pod / Tested under:

 

142
p142.html / p142.zip
Na zaklade zadanych udajov zostavi stlpcovy graf
7184b
NN 4.04, IE 4.0

UKAZKA / CLICK HERE

Zdrojovy tvar / Source code:

<html> <head> <title> JavaScript DESTINATION - P142 </title> <script language="JavaScript"> <!-- Starting_at = new Date(1997, 9, 1,12,0,0); zahl = new Array('10 20 12','20 40 14','30 60 16','40 80 18','10 20 12','20 40 14','30 60 16','40 90.5 18 12','10 20 12','20 40 14','10 20 12','20 40 14','30 60 16','40 80 18','10 20 12','20 40 14','30 60 16','40 80 18','10 20 12','20 40 14','10 20 12','20 40 14','30 60 16','40 80 18','10 20 12','20 40 14','30 60 16','40 80 18','10 20 12','20 40 14','10 20 12','20 40 14','30 60 16','40 80 18','10 20 12','20 40 14','30 60 16','40 90.5 18 12','10 20 12','20 40 14','10 20 12','20 40 14','30 60 16','40 80 18','10 20 12','20 40 14','30 60 16','40 80 18','10 20 12','20 40 14','10 20 12','20 40 14','30 60 16','40 80 18','10 20 12','20 40 14','30 60 16','40 80 18','10 20 12','20 40 14') bar_maxheight=300; bar_width=10; bar_border=1; month_border=4; scale_min_div=2; oneday=60000*60*24; max=0; for (var i in zahl) { max=Math.max(max,maxrow(zahl[i])); } function maxrow(row) { var sum = 0; var number=row.split(' '); for (var j in number) { sum += eval(number[j]); }; return sum; } function main() { Datum=new Date(); Datum.setTime(Starting_at.getTime()); zahlpos=0; var r='<html><head></head><body BGCOLOR="#C0C0C0">' + '<TABLE BORDER=0><TR>'; while (zahlpos<zahl.length){ r += display_month(); } return r + '</TR></TABLE></body></html>'; } function display_month() { var thismonth = Datum.getMonth() var thisweek = new Array() var rm = "<TD><TABLE BORDER="+ month_border +" CELLPADDING=0 CELLSPACING=0><TR><TH COLSPAN=6>" + eval(Datum.getMonth()+1) + '/' + Datum.getYear() + "<TH></TR><TR>" + scale_build(); while ((zahlpos<zahl.length)&&(thismonth == Datum.getMonth())) { thisweek[thisweek.length]=Datum.getDate(); rm += display_week(thismonth); }; rm += "</TR><TR>"; if (scale_min_div > 0 ) { rm += "<TD></TD>" } for ( var firstday in thisweek) { rm += '<TD ALIGN=LEFT>' + thisweek[firstday] + "</TD>"; }; return rm + "</TR></TABLE></TD>"; } function display_week(thismonth) { var rw = "<TD VALIGN=BOTTOM>" + "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0><TR>" + display_day(); while ( ( (zahlpos<zahl.length) &&(Datum.getDay() != 1) && (thismonth == Datum.getMonth()) ) ) { rw += display_day(); } return rw + "</TR></TABLE></TD>"; } function display_day(){ var sum=0; var j=0; var br=''; var j=61; var s=''; var number=zahl[zahlpos].split(' '); var rd = '<TD VALIGN=BOTTOM>' + '<A HREF="Javascript:parent.main()" onMouseOver="parent.elts(' + zahlpos + ")" + '">'; var baseH=0; for (var i in number) { rd += br; br = "<BR>"; rd += bar(eval(number[i]),bar_width,bar_border,baseH,unescape("%" + j++) + '.gif'); } Datum.setTime(Datum.getTime() + oneday); zahlpos++ return rd + "</A></TD><TD></TD>"; } function elts(i) { self.head.document.form.Values.value=maxrow(zahl[i]) + " = " + zahl[i].split(' ').join('+'); Datum.setTime(Starting_at.getTime() + i*oneday); var s=Datum.toGMTString().split(' '); self.head.document.form.Wday.value=s[0]; self.head.document.form.Mday.value=s[1]; self.head.document.form.Month.value=s[2]; self.head.document.form.Year.value=s[3]; return true } function scale_build () { if (scale_min_div <= 0) { return "" }; var Teil=0; var distance = new Array(2,1,0.5,0.2,0.1); var expo=Math.pow(10,Math.floor(Math.log(max)/Math.log(10))); var maxRel=max/expo; for (var i in distance) { Teil=distance[i]; if (maxRel/Teil > scale_min_div) { break }; }; Teil=Teil*expo; var Rest=max - Teil*Math.floor(max / Teil); var baseH=0; var rs = "<TD><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>" + scale_row(Rest,8,1,baseH,'grey.gif',max); for(i=(Teil*Math.floor(max / Teil)); i>0; i=i-Teil){ rs += scale_row(Teil,8,1,baseH,'grey.gif',i); }; return rs + "</TABLE></TD>"; } function scale_row(height,width,border,baseH,src,value) { return "<TR><TD AlIGN=RIGHT VALIGN=TOP>" + value + "</TD><TD VALIGN=BOTTOM>" + bar (height,width,border,baseH,src) + "</TD></TR>"; } function bar(height,width,border,baseH,src) { var pixheight = Math.floor(bar_maxheight*height/max + 0.5) - baseH; if ((pixheight >= 2*border ) && (width >= 2*border)){ return "<IMG HEIGHT=" + eval(pixheight-2*border) + ' WIDTH=' + eval(width-2*border)+ ' BORDER='+ border + ' SRC="images/graf/' + src + '">'; baseH += pixheight; } else { return "" } } function newParameters(){ bar_maxheight=parseInt(self.newpa.document.para.barh.value); bar_width=parseInt(self.newpa.document.para.barw.value); bar_border=parseInt(self.newpa.document.para.barb.value); month_border=parseInt(self.newpa.document.para.monthb.value); scale_min_div=parseInt(self.newpa.document.para.scaled.value); self.text.location = "javascript:parent.main()"; } function wert(){ return '<HTML><HEAD></HEAD><BODY><FORM NAME="form">' + '<INPUT TYPE="text" NAME="Values" VALUE="" SIZE=60>' + '<INPUT TYPE="text" NAME="Wday" VALUE="" SIZE=3>' + '<INPUT TYPE="text" NAME="Mday" VALUE="" SIZE=2>' + '<INPUT TYPE="text" NAME="Month" VALUE="" SIZE=3>' + '<INPUT TYPE="text" NAME="Year" VALUE="" SIZE=4>' + ' </FORM></BODY></HTML>' } function newparams () { return '<HTML><HEAD></HEAD><BODY>' +'<FORM NAME="para">' + '<TABLE BORDER=1> <TR>' + '<TD ALIGN="RIGHT"> vyska stlpcov (v bodoch) </TD>' +'<TD ALIGN="RIGHT"> sirka stlpcov </TD>' +'<TD ALIGN="RIGHT"> okraj stlpcov </TD>' +'<TD ALIGN="RIGHT"> okraj mesiacov </TD>' +'<TD ALIGN="RIGHT"> min. rozdelenie rozsahu </TD>' +'</TR><TR>' +'<TD> <INPUT TYPE="text" NAME="barh" SIZE=5> </TD>' +'<TD> <INPUT TYPE="text" NAME="barw" SIZE=2> </TD>' +'<TD> <INPUT TYPE="text" NAME="barb" SIZE=2> </TD>' +'<TD> <INPUT TYPE="text" NAME="monthb" SIZE=2> </TD>' +'<TD> <INPUT TYPE="text" NAME="scaled" SIZE=2> </TD>' +'</TR> </TABLE>' + '<INPUT TYPE="button" VALUE="Pouzi nove parametre" onClick="parent.newParameters()">' +'</FORM>'+ '</BODY></HTML>' } function initialize () { self.head.location = "javascript:parent.wert()"; self.newpa.location = "javascript:parent.newparams()"; self.text.location = "javascript:parent.main()"; self.newpa.document.para.barh.value=bar_maxheight; self.newpa.document.para.barw.value=bar_width; self.newpa.document.para.barb.value=bar_border; self.newpa.document.para.monthb.value=month_border; self.newpa.document.para.scaled.value=scale_min_div; } // --> </script> </head> <frameset rows="*,48,120" onLoad="initialize()"> <frame name="text" src="javascript:parent.emptyFrame" marginwidth=1 marginheight=1 scrolling="yes"> <frame name="head" src="javascript:parent.emptyFrame" marginwidth=1 marginheight=1 scrolling="no" > <frame name="newpa" src="javascript:parent.emptyFrame" marginwidth=1 marginheight=1 scrolling="yes"> </frameset> <hr> </HTML> /td>
[ Navrat / BACK ]