Graph

Graph for tracking variables

Constructor

new Graph(width, height, position, options)

Creates a graph

Parameters:
NameTypeDefaultDescription
widthnumber200

Width of the graph

heightnumber200

Height of the graph

positionvec

Position of the graph

optionsobject

Other graph options

Properties
NameTypeAttributesDefaultDescription
titlestring<optional>
""

Title of the graph

titleSizenumber<optional>
14

Font size of title

titleColorstring<optional>
"white"

Color of title

enabledboolean<optional>
true

If graph starts enabled

anchorX"left" | "right" | "center"<optional>
"left"

Relative x position of graph on the screen

anchorY"top" | "bottom" | "center"<optional>
"top"

Relative y position of graph on the screen

backgroundstring<optional>
"#0D0D0DE6"

Background color of graph

paddingnumber<optional>
8

Amount of padding around the graph

roundnumber<optional>
5

Amount of round around the graph

scaleRangenumber<optional>
100

Minimum y range. When specified as an integer rather than an array of min and max values, it uses auto scaling

scaleRangeArray<optional>

Minimum and maximum y values of the graph, as Array of [min, max]. Leaving undefined or specifying a number uses auto scaling.

maxLengthnumber<optional>
200

Maximum number of points the graph can have

lineColorstring<optional>
"#9C9C9C"

Color of the line. Use this if you only have 1 value you're graphing

lineColorobject<optional>
{ default: "#9C9C9C" }

Colors of each line name. Use this notation if you have multiple lines on one graph

lineWidthnumber<optional>
1

Width of the graph lines

Example
let graph = new Graph(200, 150, new vec(20, 20), {
	maxLength: 800,
	title: "Hello graph",
	titleSize: 12,
	background: "transparent",
	lineColor: {
		itemA: "#9D436C",
		itemB: "#5EA8BA",
	},
	padding: 10,
	scaleRange: [0, 144 * 2],
});

Members

(readonly) enabled :boolean

If the graph is enabled

Type:
  • boolean

Methods

setEnabled()

Set if the graph is enabled

addData(value, nameopt)

Adds value to the graph

Parameters:
NameTypeAttributesDefaultDescription
valuenumber

Value to add

namestring<optional>
"default"

Name of line

Example
graph.addData(20); // Adds value 20. Only works if you used a string (not object) to set lineColor
graph.addData(102.4, "itemA"); // Adds value 102.4 to the line named itemA