function scalePoint(p, tMin, tMax, MaxHeight, MarginTop, MaxHeight11) {
// do conversions
p -= tMin;
// divide by max - min
p /= (tMax - tMin);
// multiply by max scale
p *= MaxHeight;
// add margin
p += MarginTop;
// invert
p = (MaxHeight11) - p;
return p
}
function buildGraph(insertParent, quote) {
var rs, count, i, ly;
var tMax, tMin, cMax, cMin, pDiv;
var MarginLeft, MarginTop;
var increment, vIncrement;
var MaxWidth = document.body.clientWidth * 0.75;
var MaxHeight = document.body.clientHeight * 0.6;
var MaxHeight11 = MaxHeight * 1.1;
var MaxWidth11 = MaxWidth * 1.1;
var DateSpace = 50;
var TitleText;
// draw high low bars, as well as horizontal scale and date gradations
rs.moveFirst();
var lastLeft = -1000;
var tempDate;
var tm, td, ty;
var dateString;
var strokeWidth;
for (i=0; i<count; i++) {
// get high/low points from bo
tl = rs.fields("quotelow").value;
th = rs.fields("quotehigh").value;
// scale them to fit in the graph
tl = scalePoint(tl, tMin, tMax, MaxHeight, MarginTop, MaxHeight11);
// if there is enough space to print the date, do it, else skip to the next line
currLeft = i*increment+MarginLeft;
strokewidth = 1;
if ((lastLeft + DateSpace) < currLeft) {
strokewidth = 2;
d = document.createElement("DIV");
d.style.position = "absolute";
d.style.top = MaxHeight11+10;
d.style.left = i*increment+MarginLeft;
d.style.fontFamily = "Verdana";
d.style.fontSize = 8;
tempDate = new Date(rs.fields("quotedate").value);