Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 2nd, 2005, 01:11 PM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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
Reply With Quote
  #2 (permalink)  
Old February 3rd, 2005, 08:50 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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?


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:43 PM.


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