Class graph
Defined in: Graph.js.
Constructor Attributes | Constructor Name and Description |
---|---|
graph(xlow/xhigh, ylow/yhigh, points, functions, counter, points, functions)
A class representing a 2-axis graph
|
Method Attributes | Method Name and Description |
---|---|
addPoint(newpoint)
Adds a point to the array of points to be interpolated.
|
|
changeInterpolation(value)
|
|
changeX(rangestring)
Read and parse input of x-range and updates the x-range.
|
|
changeY(rangestring)
Read and parse input of y-range and updates the y-range.
|
|
clear()
Clears all points and functions from the graph
|
|
drawAxes()
Draws the axes of the graph along with the gridlines within
|
|
drawFunction(interpolated)
Draws a function on the graph by drawing lines between calculated points.
|
|
Draw the latest function added
|
|
Draws all points currently in array onto graph
|
|
<inner> |
lsq(points)
|
plotAndConnectPoints(points)
Draws a curve defined by points
|
|
pointToPixel(point)
Convert units to pixels
|
|
<inner> |
qsq(points)
|
redraw()
Draws the backdrop of the graph
|
|
Removes all functions from the graph
|
|
Removes all points from the graph
|
|
Removes the chosen function from the graph
|
|
removePoint(p)
Removes the chosen point from the graph
|
|
{double}
|
xpu()
Calulates the X pixels per unit ratio
|
xrange()
Provide graphs current x-range
|
|
{double}
|
ypu()
Calulates the Y pixels per unit ratio
|
yrange()
Provide graphs current y-range
|
Class Detail
graph(xlow/xhigh, ylow/yhigh, points, functions, counter, points, functions)
A class representing a 2-axis graph
- Parameters:
- {double} xlow/xhigh
- The high and low values of the x-range.
- {double} ylow/yhigh
- The high and low values of the y-range.
- {double} points
- The array of points added.
- {double} functions
- The array of functions added/formed.
- counter
- points
- functions
Method Detail
addPoint(newpoint)
Adds a point to the array of points to be interpolated.
It also checks if the point is outside the current viewing window and
adjusts if necessary.
- Parameters:
- {Point} newpoint
- The newpoint to be drawn
changeInterpolation(value)
- Parameters:
- value
changeX(rangestring)
Read and parse input of x-range and updates the x-range.
- Parameters:
- {string} rangestring
- The values for xhigh and xlow as a string
changeY(rangestring)
Read and parse input of y-range and updates the y-range.
- Parameters:
- {string} rangestring
- The values for yhigh and ylow as a string
clear()
Clears all points and functions from the graph
drawAxes()
Draws the axes of the graph along with the gridlines within
drawFunction(interpolated)
Draws a function on the graph by drawing lines between calculated points.
- Parameters:
- {Polynomial|Term} interpolated
- The interpolated function
drawLatest()
Draw the latest function added
drawPoints()
Draws all points currently in array onto graph
<inner>
lsq(points)
- Parameters:
- points
plotAndConnectPoints(points)
Draws a curve defined by points
- Parameters:
- {Point[]} points
- The points to be plotted and connected;
pointToPixel(point)
Convert units to pixels
- Parameters:
- point
<inner>
qsq(points)
- Parameters:
- points
redraw()
Draws the backdrop of the graph
removeAllFunctions()
Removes all functions from the graph
removeAllPoints()
Removes all points from the graph
removeFunction(f)
Removes the chosen function from the graph
- Parameters:
- {String} f
- The function to be removed
removePoint(p)
Removes the chosen point from the graph
- Parameters:
- {String} p
- The point to be removed
{double}
xpu()
Calulates the X pixels per unit ratio
- Returns:
- {double} xpu Returns the xpu value
xrange()
Provide graphs current x-range
{double}
ypu()
Calulates the Y pixels per unit ratio
- Returns:
- {double} ypu Returns the ypu value
yrange()
Provide graphs current y-range