If Labels.length>0, then Data labels are ignored.
return: | plot number, the index into GR.List[ ] for this plot.
In addition, if f_of_x is used, then Data[ ] is filled with x,y pairs.
|
---|
view function
GRinit()
initializes the divgraph.js package
|
actions: | resets all arrays and variables to their default values. Reuses all variables and structures. Recommended to be called whenever previous graphs are not being saved or displayed.
|
---|
return: | null
|
---|
view function
GRopengraphframe(frame)
Open a new graph document in the specified frame
|
parameter | default | description
|
---|
frame | REQUIRED | frame for which the document is to be opened
|
actions: | GR.win is set the new frame, and GR.doc is set to the frame document, which is opened.
This initiates an overwriting of any document currently that frame.
|
---|
return: | frame.document
|
---|
view function
GRopengraphwindow(w,h,t,l)
Opens a new window and its associated document for a new graph.
|
parameter | default | description
|
---|
w | 300 | window width
|
h | 300 | window height
|
t | 50 | window top
|
l | 50 | window left
|
actions: |
Creates a new window with options based on the GR.winoptions template. Sets GR.win and GR.doc.
|
---|
return: | new graph window
|
---|
view function
GRreplot(ngraph,xoff,yoff,doc2,w,h,t,l)
replotting of data for printing with Netscape Navigator
or for redisplaying the data in a new window
|
parameter | default | description
|
---|
ngraph | GR.thisgraph | plot number (index into GR.List[ ] , returned by GRdrawgraph()
|
xoff | 0 | x-offset from original
|
yoff | 0 | y-offset from original
|
doc2 | new | graph document
|
w | most recent | window width
|
h | most recent | window height
|
t | most recent | window top
|
l | most recent | window left
|
actions: | if doc2 is not specified, the new graph document is closed,
and the old window is closed. GR.win and GR.doc point to the new graph.
|
---|
return: | new graph window if creation was necessary, or null if it was not.
|
---|
view function
GRsetgraphwindow(w)
Sets the window and its currently open document to be the current graphing window and document. Assumes an open document already.
|
parameter | default | description
|
---|
w | window | window or frame to be used (defaults to main window)
|
actions: | GR.win is set the specified window, and GR.doc is set to the window's document.
However, no document is opened.
This allows writing into the main document or into a frame that has an already-opened document currently being written to.
Use this function instead of GRopengraphwindow() or GRopengraphframe() to open a graph in a document
that is currently being written.
|
---|
return: | w.document
|
---|
Math Interface Functions
|
These seven functions allow the user to specify common-use math functions instead of JavaScript math. They are the
only functions in the package that do not begin with "GR" and probably are only of use if the user is expected to specify the
math function to be plotted. They are not called by any GR functions and may be overwritten, complemented, or discarded.
|
function sin(x){return Math.sin(x)}
function cos(x){return Math.cos(x)}
function tan(x){return Math.sin(x)/Math.cos(x)}
function log(x){return Math.LOG10E*Math.log(x)}
function ln(x){return Math.log(x)}
function sqrt(x){return Math.pow(x,0.5)}
function sqr(x){return Math.pow(x,0.5)}
|
Secondary Interface Functions
|
These 13 functions might be of general use, but are primarily used from within the divgraph.js package.
|
view function
GRalert(a,b,c,d,...)
shows an alert in the graphing document
|
parameter | default | description
|
---|
any | REQUIRED | any number of parameters may be displayed. Each separate parameter is
displayed on a separate line of the message box.
|
actions: | This also serves to bring
a graph window to the foreground when necessary. Standard alerts will bring the
calling page to the foreground, probably hiding the graph.
|
---|
return: | null
|
---|
view function
GRdebugwrite(a,b,c,d,...)
shows a message in a new window
|
parameter | default | description
|
---|
any | REQUIRED | any number of parameters may be displayed. Each separate parameter is
displayed on a separate line of the new window.
|
actions: | opens a new window displaying the specified string.
|
---|
return: | null
|
---|
view function
GRdiv(i,doc)
|
parameter | default | description
|
---|
i | REQUIRED | refering to div "G"+i
|
doc | REQUIRED | any document with divs of this form
|
actions: | this is a browser-blind call to get a div handle.
|
---|
return: | (GR.isnn4?doc.layers["G"+i]:eval("doc.all.G"+i))
|
---|
view function
GRdivinfo(i,doc)
this function allows a determination of the contents of div "#G"+i in document doc
|
parameter | default | description
|
---|
i | REQUIRED | refering to div "G"+i
|
doc | REQUIRED | graphing document
|
actions: | this is a browser-blind call to get a div HTML contents. Since NN4 does
not proved the innerHTML property, this is provided by an array GR.innerHTML, which is
set up as divs are written.
|
---|
return:D, an array with elements D.innerHTML, D.offsetLeft, and D.offsetTop
|
---|
view function
GRdivmove(i,x,y,xytype,ngraph)
move the specided div "G"+i to the specified location
|
parameter | default | description
|
---|
i | REQUIRED | refering to div "G"+i
|
x | REQUIRED | x-coordinate
|
y | REQUIRED | y-coordinate
|
xytype | GRUSER | GRUSER indicates coordinates are user-based
GRDOC indicates coordinates are document-based, with 0,0 at the top left corner of
the plotting surface (as specified by Info.graphleft and Info.graphtop, not the window)
with y running DOWN from the top.
GRANCHOR indicates coordinates based on a graph anchor element such as an image or "a" tag (indicated by setting Info.anchor to
|
ngraph | GR.thisgraph | the graph number associated with this point, starting with 1
|
actions: | repositions the div; automatically shows it if hidden
|
---|
return: | null
|
---|
view function
GRdivshow(i,TF,ngraph)
shows or hides the specified div
|
parameter | default | description
|
---|
i | REQUIRED | refering to div "G"+i
|
TF | true | whether to show the div; true or false
|
ngraph | GR.thisgraph | the graph number associated with this point, starting with 1
|
actions: | shows/hides the div;
|
---|
return: | null
|
---|
view function
GRdivwrite(i,s,x,y,xytype,ngraph)
writes HTML to a specified div of id "G"+i, moving it, if that too is specified
|
parameter | default | description
|
---|
i | REQUIRED | refering to div "G"+i
|
s | REQUIRED | HTML to write
|
x | OPTIONAL | x-coordinate
|
y | OPTIONAL | y-coordinate
|
xytype | GRNONE | GRUSER indicates coordinates are user-based
GRDOC indicates coordinates are document-based, with 0,0 at the top left corner of
the plotting surface (as specified by Info.graphleft and Info.graphtop, not the window)
with y running DOWN from the top.
GRANCHOR indicates coordinates based on a graph anchor element such as an image or "a" tag (indicated by setting Info.anchor to
GRNONE or no parameter present indicates write only, without a move.
|
ngraph | GR.thisgraph | the graph number associated with this point, starting with 1
|
actions: | write to and optionally repositions the div; automatically shows the div if hidden
|
---|
return: | null
|
---|
view function
GRfixpower(s,format)
convert standard user form a^b to Math.pow(a,b)
|
parameter | default | description
|
---|
s | REQUIRED | the string to search for a^b in
|
format | "Math.pow(%1,%2)" | the format
|
actions: | All occurances of a^b are replaced in a format, where a is %1 and b is %2. Preceding and subsequent
string information is recognized and left unchanged. Parentheses are recognized. For example, 3*(5+3)^7+1 becomes 3*Math.pow((5+3),7)+1.
|
---|
return: | format replaced as specified
|
---|
view function
GRgetleastsquares(Data,L)
calculates a least squares fit on x,y pairs in Data
|
parameter | default | description
|
---|
Data[ ] | REQUIRED | data in the form of x,y pairs
|
L[ ] | REQUIRED | return array
|
actions: | calculates least squares fit
|
---|
return: | L.m (slope), L.b (intercept), L.r2 (r2)
|
---|
view function
GRgetoffset(s)
get the absolute x,y position of a page element.
|
parameter | default | description
|
---|
s | REQUIRED | the name of the element, as indicated in a "name=" parameter of an HTML tag.
|
actions: | The x,y coordinates of the element are determined. This function is used for finding a specified anchor's page position initially and upon page resizing.
|
---|
return: | an array, where array.left=x and array.top=y
|
---|
view function
GRgraph(x,y)
find the graph associated with a specific absolute document x,y position.
|
parameter | default | description
|
---|
x,y | REQUIRED | document-based x and y coordinates.
|
actions: | Generally, this function is used to associate a user's mouse clicks with a specific graph.
|
---|
return: | the graph number of the graph whose plotting surface contains these x,y coordinates.
|
---|
view function
GRmouseevent(e,x,y,scmd)
responds to user clicks and moves of the mouse
|
parameter | default | description
|
---|
e | event | event structure from Netscape Navigator only
|
x,y | event x and y | x,y coordinates (only for testing)
|
scmd | null | the function name to which to pass structure information (only for testing)
|
actions: | responds to mouse events
|
---|
return: | passes on the event structure (from the browser) along
with a structure indicating the button that was pressed (in the case of mousedown and mouseup)
as well as the graph number for the graph that was clicked on and the x,y coordinates in document,
anchor, and user systems. See examplec.htm for more information.
|
---|
view function
GRgetnewwindow(s,opt)
|
parameter | default | description
|
---|
s | REQUIRED | URL of page to open, or "" for blank window
|
opt | REQUIRED | option string indicating size, menu, scrolling, and other options
|
actions: | A new window with a unique name and its associated document are created
|
---|
return: | handle to new window
|
---|
view function
GRinitdivs()
|
actions: | checks for browser compatibility; sets GR.isnn4 and GR.isie4
|
---|
return: | true if successful, false if unsuccessful
|
---|
view function
GRprompt(q,a)
generates a user prompt in the graph window
|
parameter | default | description
|
---|
s | REQUIRED | prompt question string
|
a | REQUIRED | prompt default answer string
|
actions: | brings the graph window
forward and produces a prompt in it. In contrast, a simple prompt() will
generally hide a visible graph window behind the main page.
|
---|
return: | prompt result string or null (canceled)
|
---|
view function
GRrect(x1,y1,x2,y2,c,xytype,ngraph)
,y,label,c,xytype,ngraph)
create a string representing a rectangle
|
parameter | default | description
|
---|
x1,y1 | REQUIRED | upper left coordinates
|
x2,y2 | REQUIRED | lower right coordinates
|
c | GR.colorlast | c.gif must be a valid GIF file.
|
xytype | GRUSER | GRUSER indicates coordinates are user-based
GRDOC indicates coordinates are document-based, with 0,0 at the top left corner of
the plotting surface (as specified by Info.graphleft and Info.graphtop, not the window)
with y running DOWN from the top.
GRANCHOR indicates coordinates based on a graph anchor element such as an image or "a" tag (indicated by setting Info.anchor to
the name of the element).
|
ngraph | GR.thisgraph | the graph number associated with this point, starting with 1
|
return: |
|
---|
actions: |
creates a string corresponding to a box with upper left corner x1,y1 and lower right corner x2,y2.
|
---|
return: | <img>HTML tag for use in GRdivwrite()
|
---|
view function
GRresize()
moves the graph to the correct anchored position if the web page is resized
|
actions: | This function is called when the page is resized if an anchor is indicated for a graph. For proper function under Internet Explorer, the <body> tag must contain "onresize=GRresize()" or else a reference to a function that itself calls GRresize().
|
---|
return: | 1
|
---|
view function
GRroundoff(x,ndec)
rounds off a number to a specified number of digits
|
parameter | default | description
|
---|
x | REQUIRED | number to be rounded
|
ndec | depends | number of digits to round:
ndec<0 for floating (scientific notation)
ndec>0 for fixed notation
absent: do "reasonable" roundoff
|
actions: | If ndec is omitted, then it is determined by:
|x|>=9999 -2
|x|<0.01 -2
|x|>=10 0
|x|>=1 1
|x|>=0.1 2
|x|>=0.01 3
|
---|
return: | rounded number as a string
|
---|
view function
GRsetgraph(ngraph,tolist)
set current graph to be ngraph
|
parameter | default | description
|
---|
ngraph | REQUIRED | the number of the graph to make the default graph
|
tolist | false | true:transfers save current graph information to this graph number (not recommended);false:load this graph information (from GR.List[ngraph]) into the current information (in GR)
|
actions: |
this function needs to be called only if you have multiple graphs
and are using GRxof() or GRyof() and
no other calls have been made, such as to GRdivmove() or GRdivwrite(),
to set the graph. Critical elements in GR.List are transferred to GR so that
proper positioning can occur. After calling GRsetgraph(), the "ngraph" parameter may be
left off in all other functions requiring it.
|
---|
return: | null
|
---|
view function
GRshow(obj,objName,signore,sonly)
displays all elements of an object
|
parameter | default | description
|
---|
obj | REQUIRED | object to be enumerated
|
objName | "obj" | name to supply for the object
|
signore | null | ignore all elements containing this text in their name
|
sonly | null | include only elements containing this in their name
|
actions: | enumerates the object for debugging purposes. Use with GRalert() or GRdebugwrite(). For example,
GRalert(GRshow(document.anchors,"document.anchors")) or
GRdebugwrite(GRshow(document.anchors,"document.anchors"))
|
---|
return: | string of all of the object's elements and their definitions
|
---|
view function
GRxof(x)
converts user x-coordinate to document coordinates
|
parameter | default | description
|
---|
x | REQUIRED | user x-coordinate
|
return: | Math.round(GR.left+(x-GR.xmin)*GR.xfactor)
|
---|
view function
GRyof(y)
converts user y-coordinate to document coordinates
|
parameter | default | description
|
---|
y | REQUIRED | user y-coordinate
|
return: | Math.round(GR.top+GR.height-(y-GR.ymin)*GR.yfactor)
|
---|