Libraries.Robots.Spike.Bargraph Documentation

The Bargraph library is used to graph and display bargraphs in the SPIKE App. The categories in the bargraph are the different color values from the Color library.

Example Code


use Libraries.Robots.Spike.Bargraph
Bargraph bg
Color color
bg:SetValue(color:RED, 0.5)
bg:Show(true)

Inherits from: Libraries.Language.Object

Actions Documentation

Change(integer color, number value)

Adds the provided value to the value that corresponds to the selected color

Parameters

  • integer color: The color constant whose value will be changed (see Color)
  • number value: The value to be added

Example

use Libraries.Robots.Spike.Bargraph
Bargraph bg
Color color
bg:SetValue(color:RED, 0.5)
bg:Change(color:RED, 1.0)
bg:Change(color:RED, -2) //Red bar is at -0.5

ClearAll()

Set the corresponding values for each color back to 0

Example

use Libraries.Robots.Spike.Bargraph
Bargraph bg
Color color
bg:SetValue(color:RED, 0.5)
bg:SetValue(color:BLACK, 1.5)
bg:SetValue(color:BLUE, 2.5)
bg:ClearAll() //values for all colors is 0 now

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

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

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)

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()

GetValue(integer color)

Get the corresponding values for the provided color

Parameters

  • integer color: The color constant whose value will be returned (see Color)

Return

number: The corresponding value for the provided color

Example

use Libraries.Robots.Spike.Bargraph
Bargraph bg
Color color
bg:SetValue(color:RED, 0.5)
number redValue = bg:GetValue(color:RED)

Hide()

Hides the currently displayed bargraph in the App.

Example

use Libraries.Robots.Spike.Bargraph
use Libraries.Robots.Spike.Hub
Bargraph bg
Hub hb
Color color
bg:SetValue(color:RED, 0.5)
hb:Sleep(1000)
bg:Hide()

SetValue(integer color, number value)

Sets the value corresponding to the color in the bargraph

Parameters

  • integer color: The color constant whose value will set (see Color)
  • number value

Example

use Libraries.Robots.Spike.Bargraph
Bargraph bg
Color color
bg:SetValue(color:RED, 0.5)

Show(boolean fullscreen)

Shows the bargraph to the App display.

Parameters

  • boolean fullscreen: A boolean which will show the bargraph in fullscreen if true, and as a pop-up if not.

Example

use Libraries.Robots.Spike.Bargraph
Bargraph bg
Color color
bg:SetValue(color:RED, 0.5)
bg:Show(true)