JavaScript Diagram Builder - The Diagram object

The Diagram object provides the possibility, to draw a diagram at a defined position with a defined size on the window document. The appropriate scale will be drawn automatically, corresponding to the specified xmin, xmax, ymin and ymax values. The diagram provides - also when not drawn - some useful functions which can be used to transform screen positions into real world positions and vice versa.
This diagram was generated by
<SCRIPT Language="JavaScript">
document.open();
var D=new Diagram();
D.SetFrame(80, 160, 420, 360);
D.SetBorder(10, 50, 0, 4);
D.SetText("X-Label","Y-Label","Title");
D.SetGridColor("#44CC44");
D.Draw("#80FF80","#0000FF",true,"Click on me !","DiagramClick()");
document.close();
function DiagramClick()
{ alert("Use your own function here."); }
</SCRIPT>
You can use the following methods: Before drawing, you can set the following properties: After calling D.GetXGrid() / D.GetYGrid() you can read: Because of a bug in Netscape 4.x you must add the following code in the web page
before using the diagram objects:
<DIV STYLE="position:absolute; top:0px"></DIV>
Also for Netscape 4.x the file transparent.gif must be in the directory of the web page.

If you want to draw the diagram into another window, you can specify the target window:
_DiagramTarget=theTargetWindow;
_DiagramTarget is a global variable, which is valid within the entire document.
The default _DiagramTarget is the window object of the current document.
The Diagram in the new window was generated by:

<SCRIPT Language="JavaScript">
function MyXScale(nn)
{ var tt=new Array("left", "center", "right");
  return("<b>"+tt[nn]+"</b>");
}
function NewWindow()
{ _DiagramTarget=window.open("","",
  "width=460,height=300,menubar=no,locationbar=no,resizable=yes,status=no,scrollbars=no");
  with (_DiagramTarget.document)
  { open();
    writeln("<HTML><HEAD><TITLE>Diagram in a new window</TITLE></HEAD><BODY>");
    var D2=new Diagram();
    D2.SetFrame(60, 40, 400, 240);
    D2.SetBorder(0, 3, 0, 4);
    D2.XGridDelta=1;
    D2.XScale="function MyXScale";
    D2.XScalePosition="top-right";
    D2.YSubGrids=1;
    D2.Font="font-family:Verdana;font-weight:normal;font-size:8pt;line-height:13pt;";
    D2.SetText("","", "Diagram with small font and function-scale");
    D2.SetGridColor("#cccccc", "#eeddcc");
    D2.Draw("#FFEECC", "#336699", false, "Click on me !", "opener.DiagramClick()");
    writeln("</BODY></HTML>");
    close();
  }
}
</SCRIPT>


« Introduction The Bar object »