You can use the following methods:
- var D = new Diagram() //Constructor
- D.SetFrame(theLeft, theTop, theRight, theBottom) //Screen
- D.SetBorder(theLeftX, theRightX, theBottomY, theTopY) //World
- D.SetText(theScaleX, theScaleY, theTitle) //Labels (optional)
- D.ScreenX(theRealX) //Coordinate transformation world->screen
- D.ScreenY(theRealY) //Coordinate transformation world->screen
- D.RealX(theScreenX) //Coordinate transformation screen->world
- D.RealY(theScreenY) //Coordinate transformation screen->world
- D.GetXGrid() //returns array, which contains min, delta and max of the X grid
- D.GetYGrid() //returns array, which contains min, delta and max of the Y grid
- D.SetGridColor(theGridColor[, theSubGridColor]) //Colors of X and Y grid lines
- D.SetXGridColor(theGridColor[, theSubGridColor]) //Colors of X grid lines
- D.SetYGridColor(theGridColor[, theSubGridColor]) //Colors of Y grid lines
- D.Draw(theDrawColor, theTextColor, isScaleText[, theTooltipText[, theOnClickAction
[, theOnMouseoverAction[, theOnMouseoutAction]]]]) //Display,
theDrawColor can be an image
- D.SetVisibility(isVisible) //Show or Hide
- D.SetTitle(theTitle) //TooltipText
- D.Delete() //Delete DIV object of D from the document
- delete D //Destructor
Before drawing, you can set the following properties:
- D.XScale // 0 = no scale; 1 = numeric (default); 2, 3, ... = date/time; string = numeric+unit
"function FunctionName" = FunctionName(ScaleValue)
- D.YScale // 0 = no scale; 1 = numeric (default); 2, 3, ... = date/time; string = numeric+unit
"function FunctionName" = FunctionName(ScaleValue)
- D.XScalePosition // "bottom" (default), "botom-left", "bottom-right", "top", "top-left", "top-right"
- D.YScalePosition // "left" (default), "left-top", "left-bottom", "right", "right-top", "right-bottom"
- D.XGridDelta //Grid interval in X-direction, if it is 0 (default) it will be detected automatically
- D.YGridDelta //Grid interval in Y-direction, if it is 0 (default) it will be detected automatically
- D.XSubGrids //Number of Sub-Grid intervals within one Grid interval in X-direction, if it is 0 (default) it will be detected automatically, if it is -1 then a logarithmic Sub-Grid will be drawn
- D.YSubGrids //Number of Sub-Grid intervals within one Grid interval in Y-direction, if it is 0 (default) it will be detected automatically, if it is -1 then a logarithmic Sub-Grid will be drawn
- D.Font //Text style, default = "font-family:Verdana;font-weight:normal;font-size:10pt;line-height:13pt;"
After calling D.GetXGrid() / D.GetYGrid() you can read:
- D.XGrid[0], D.XGrid[1] and D.XGrid[2] // min, delta and max of the X grid
- D.YGrid[0], D.YGrid[1] and D.YGrid[2] // min, delta and max of the Y grid
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>