Libraries.Robots.Spike.Linegraph Documentation
The Linegraph library is used to graph and display linegraphs in the SPIKE App. The linegraph is graphed by plotting points using x and y coordinates, and different lines are differntiated by color.
Example Code
use Libraries.Robots.Spike.Linegraph
Linegraph lg
Color color
lg:Plot(color:RED, 0, 0)
lg:Plot(color:RED, 2, 4)
lg:Show(true)
Inherits from: Libraries.Language.Object
Actions Documentation
Clear(integer color)
Clears the line for the corresponding color
Parameters
- integer color: The color constant whose line will be cleared (see Color)
Example
use Libraries.Robots.Spike.Linegraph
Linegraph lg
Color color
lg:Plot(color:RED, 0, 0)
lg:Plot(color:RED, 2, 4)
lg:Clear(color:RED)
ClearAll()
Clears all of the lines in the linegraph
Example
use Libraries.Robots.Spike.Linegraph
Linegraph lg
Color color
lg:Plot(color:RED, 0, 0)
lg:Plot(color:RED, 2, 4)
lg:Plot(color:BLACK, 0, 0)
lg:Plot(color:BLACK, 2, 1)
lg:ClearAll()
Compare(Libraries.Language.Object object)
This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.
Parameters
- Libraries.Language.Object: The object to compare to.
Return
integer: The Compare result, Smaller, Equal, or Larger.
Example
Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Parameters
- Libraries.Language.Object: The to be compared.
Return
boolean: True if the hash codes are equal and false if they are not equal.
Example
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
GetAverage(integer color)
Gets the average of the plotted values in the linegraph
Parameters
- integer color: The color constant whose average will be calculated (see Color)
Return
number: The average of the plotted values in the linegraph
Example
use Libraries.Robots.Spike.Linegraph
Linegraph lg
Color color
Hub hb
lg:Plot(color:RED, 0, 0)
lg:Plot(color:RED, 2, 4)
lg:Plot(color:RED, 4, 4)
lg:Plot(color:RED, 6, 5)
hb:Sleep(1000)
number averageValue = lg:GetAverage(color:RED)
GetHashCode()
This action gets the hash code for an object.
Return
integer: The integer hash code of the object.
Example
Object o
integer hash = o:GetHashCode()
GetLast(integer color)
Gets the last of the plotted values in the linegraph
Parameters
- integer color: The color constant whose last value will be determined (see Color)
Return
number: The last of the plotted values in the linegraph
Example
use Libraries.Robots.Spike.Linegraph
Linegraph lg
Color color
Hub hb
lg:Plot(color:RED, 0, -1)
lg:Plot(color:RED, 2, 4)
lg:Plot(color:RED, 4, 4)
lg:Plot(color:RED, 6, 5)
lg:Plot(color:RED, 8, 4)
hb:Sleep(1000)
number lastValue = lg:GetLast(color:RED)
GetMax(integer color)
Gets the maximum of the plotted values in the linegraph
Parameters
- integer color: The color constant whose maximum will be calculated (see Color)
Return
number: The maximum of the plotted values in the linegraph
Example
use Libraries.Robots.Spike.Linegraph
Linegraph lg
Color color
Hub hb
lg:Plot(color:RED, 0, 0)
lg:Plot(color:RED, 2, 4)
lg:Plot(color:RED, 4, 4)
lg:Plot(color:RED, 6, 5)
lg:Plot(color:RED, 8, 4)
hb:Sleep(1000)
number maxValue = lg:GetMax(color:RED)
GetMin(integer color)
Gets the minimum of the plotted values in the linegraph
Parameters
- integer color: The color constant whose minimum will be calculated (see Color)
Return
number: The minimum of the plotted values in the linegraph
Example
use Libraries.Robots.Spike.Linegraph
Linegraph lg
Color color
Hub hb
lg:Plot(color:RED, 0, -1)
lg:Plot(color:RED, 2, 4)
lg:Plot(color:RED, 4, 4)
lg:Plot(color:RED, 6, 5)
lg:Plot(color:RED, 8, 4)
hb:Sleep(1000)
number minValue = lg:GetMin(color:RED)
Hide()
Hides the currently displayed linegraph in the App.
Example
use Libraries.Robots.Spike.Linegraph
use Libraries.Robots.Spike.Hub
Hub hb
Color color
Linegraph lg
Color color
lg:Plot(color:RED, 0, 0)
lg:Plot(color:RED, 2, 4)
lg:Plot(color:RED, 4, 4)
lg:Plot(color:RED, 6, 5)
hb:Sleep(1000)
lg:Hide()
Plot(integer color, number x, number y)
Plots the x and y values with the provided color in the linegraph
Parameters
- integer color: The color constant that will used to plot the x and y coordinates (see Color)
- number x: The x coordinate of the new point tp be plotted
- number y: The y coordinate of the new point to be plotted
Example
use Libraries.Robots.Spike.Linegraph
Linegraph lg
Color color
lg:Plot(color:RED, 0, 0)
lg:Plot(color:RED, 2, 4)
Show(boolean fullscreen)
Shows the linegraph to the App display.
Parameters
- boolean fullscreen: A boolean which will show the linegraph in fullscreen if true, and as a pop-up if not.
Example
use Libraries.Robots.Spike.Linegraph
Linegraph lg
Color color
lg:Plot(color:RED, 0, 0)
lg:Plot(color:RED, 2, 4)
lg:Plot(color:RED, 4, 4)
lg:Plot(color:RED, 6, 5)
lg:Show(true)