Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 2nd, 2005, 01:11 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default y-axis

<script Language="JavaScript">
//---------------------------------
// Variables:
// wid,hei - The size of the chart on axes x and y.
// x0, y0 - relative coordinate in which is deduced the chart.
// dat() - The initial data. Any quantity of elements.
// name1,name2,name3 - The names of lines in the table and charts.
// col() - Colours of elements of the diagram. We made 14, if it is necessary more - you add.
//bgCol_Pg - Background of page. Use for Netscape 6.
//---------Variables---------------
wid=100
hei=200
x0=(window.screen.width-wid*1.3-60)/2
y0=30
dat=new Array("10","5")
//add="1"
//top="<%=bookings%>"

var top = 10 + 5 ;
name1="Quarter:"
name2="Quantity:"
name3="Bookings made by Me:"
col =new Array("003366","ff0000","ffff00","0000ff","ff00ff" ,"00ffff","000000","00cc00","cc0000","cccc00","000 0cc","cc00cc","00cccc","cccccc","003366","ececec" )
bgCol_Pg="#f5f5f5"
//----------End Variables----------

//This and others free scripts you can find on a site: artdhtml.com
//The script works both with Internet Explorer (4-6) and with Netscape (4,6).

y0=y0+hei*1.2 // - correction

function genLayer(sName, sLeft, sTop, sWdh, sHgt, sVis, sBg, copy)
{
        document.write('<LAYER ' +((sName)?'NAME="'+sName+'"':'') + ' LEFT=' + sLeft + ' TOP=' + sTop +
        ' WIDTH=' + sWdh + ' HEIGHT=' + sHgt + ((sBg)?' bgColor='+sBg:'')+'' + ((sVis)?' VISIBILITY='+sVis:'')+ '' +
        ' z-Index=0>' +((copy)?copy:"") + '</LAYER>');
}


function recharts(j,he)
{
 if(ns)
 {
    for (i=0; i<100; i=i+1)
    {
        if ((i+0.1)/100>he){document.ilay1.document.layers["n"+j+"y"+i].visibility = "hide"}
        else{document.ilay1.document.layers["n"+j+"y"+i].visibility = "show"}
    }
 }
 if(ie4)
 {
    document.all["n"+j].style.top=0-Math.ceil(he*hei);
    document.all["n"+j].style.height=Math.ceil(he*hei);
 }
 if(ns6)
 {
    document.getElementById("nn"+j).style.height=Math. ceil(hei-he*hei);
    document.getElementById("n"+j).style.height=Math.c eil(he*hei);
    document.getElementById("n"+j).style.top=0-Math.ceil(he*hei);
 }
}

function diagram()
{
d_max=0
for (j=0; j<n_dat; j++)
{
    if(isNaN(document.fData["t"+(j+1)].value)){alert("Error! A field "+(j+1)+". Enter number.");document.fData["t"+(j+1)].value=0}
    dat[j]=document.fData["t"+(j+1)].value*1
    if(dat[j]>d_max){d_max=dat[j]}
}
for (j=0; j<n_dat; j++)
{
    recharts(j,dat[j]/d_max)
}
return false;
}

//-------End functions--------

var ns=document.layers?1:0
var ie4=document.all?1:0
var ns6=document.getElementById&&!document.all?1:0

NN=(document.layers ? true:false)
n_dat=dat.length

//-----Generation of table----

len_max=2
for (j=0; j<n_dat; j++)
{
    if(dat[j].length>len_max){len_max=dat[j].length}
}

document.write('')
for (j=0; j<n_dat; j++)
{
    document.write('')
}

document.write('<td> </td></tr><form name="fData" method="POST" action="charts.htm" onSubmit="return diagram()";>')
for (j=0; j<n_dat; j++)
{
    document.write('<td align=center><input type=hidden name="t'+(j+1)+'" size='+len_max+' value='+dat[j]+'></td>')
}
document.write('<td> </td></tr></form></table>')
document.write("<p align=center><b>"+name3+"</b></p>") // Bookings made by 'Donald MacKenzie Travel

//----------End table-------
if (ns){document.write("<ilayer name=ilay1>")}
else
document.write("<table align=center><tr><td>&nbsp;</td></tr><tr><td>"+top+"</td></tr></table>");
{document.write("<div style='position:relative; left:"+x0+";top:"+y0+";width:"+wid*1.3+";height:"+ hei*1.3+"'>")}
if (ns)
{
    genLayer("Number of Bookings", x0-2, y0, wid*1.2, 2, "show", "#000000", "document.write(top);")
    genLayer("Number of Bookings", x0-2, y0-hei*1.2, 2, hei*1.2, "show", "#000000", "document.write(top);")
}
else
{
    document.write("<div border=0 style='position:absolute; left:"+(0-2)+";top:"+(0)+";width:"+(wid*1.2)+";height:"+2+"; background:#000000'><img src=http://artdhtml.com/1x1.gif width=1 height=1></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=booking s%>")
    document.write("<div border=0 style='position:absolute; left:"+(0-2)+";top:"+(0-hei*1.2)+";width:"+2+";height:"+(hei*1.2)+";backgr ound:#000000'><img src=http://artdhtml.com/1x1.gif width=1 height=1></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=canc_bookings%> ")
}

wid=wid/n_dat
for (j=0; j<n_dat; j++)
{
    if (ns)
    {
        for (i=0; i<100; i=i+1)
        {
            genLayer("n"+j+"y"+i+"", x0+j*wid, y0-(i+1)*hei/100, wid, hei/100, "show", col[j], "<%=bookings%>")
        }
    }
    if (ie4)
    {

        document.write("<img src=http://artdhtml.com/1x1.gif id=n"+j+" border=1 style='position:absolute; left:"+(0+j*wid)+";top:"+(0-hei)+";width:"+wid+";height:"+hei+";background:#"+ col[j]+"'>")
    }
    if (ns6)
    {
        document.write("<div id=n"+j+" border=0 style='position:absolute; left:"+(0+j*wid)+";top:"+(0-hei)+";width:"+wid+";height:"+hei+";background:#"+ col[j]+"'></div>document.write(top);")
        document.write("<div id=nn"+j+" border=0 style='position:absolute; left:"+(0+j*wid)+";top:"+(0-hei)+";width:"+wid+";height:"+hei+";background:#"+ bgCol_Pg+"'></div></a>")
    }

}
if (ns){document.write("</ilayer>")}
else {document.write("</div>")}


tim=window.setTimeout("diagram()",1000)
</script>


In the JS above.

How can i have the variable 'top' document.write out at the top of the black line (y-axis). try it in your browser. copy it into dreamweaver or html kit.

i just cant get it to go to the top of the black line.

thanks

picco

__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old February 3rd, 2005, 08:50 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

no-one got any ideas?







Similar Threads
Thread Thread Starter Forum Replies Last Post
axis problem asap XSLT 3 July 31st, 2006 02:26 AM
get right axis Kabe XSLT 2 February 19th, 2004 12:03 PM
AXIS Codes Freddie969 Apache Tomcat 0 November 5th, 2003 06:37 AM
JBuilder with Axis Fyrosedreams Apache Tomcat 0 August 22nd, 2003 10:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.