3.0.1 • Published 3 years ago

trugraph v3.0.1

Weekly downloads
7
License
ISC
Repository
bitbucket
Last release
3 years ago

TruGraph

Getting Started

Image of a graph generated by TruGraph

To use TruGraph in your project, first import the modules into your project using:

import TruGraph from 'trugraph'

Basic Usage

To add a graph to your page call TruGraph as follows:

let graph = new TruGraph(id, data, layout)
  • REQUIRED: id is the id of the container element you wish to append your graph to.
  • REQUIRED: data is an object (or array of objects) containing the information about the expressions you wish to graph, such as the mathematical function, color, stroke, arrowheads, etc.
  • OPTIONAL: layout is an object used to set the properties of the graph, such as the axes, legends, etc.

Data Object Properties

PropertyTypeOptionsDefault
expressionstringsee math-expressions packagex^2
colourstringhex, rgb, or rgba color scheme#FF0000
thicknessintegerany integer value2
stylestringsolidsolid
domainarrayMust contain 2 values. Any number or the string values 'negative infinity' and 'infinity''negative infinity', 'infinity'
rangearrayMust contain 2 values. Any number or the string values 'negative infinity' and 'infinity''negative infinity', 'infinity'
endpointsBooleantrue or falsetrue
endpointLeftstring'arrow', 'open-circle', 'closed-circle''arrow'
endpointRightstring'arrow', 'open-circle', 'closed-circle''arrow'

Layout Object Properties

PropertyTypeOptionsDefault
visibleDomainarrayMust contain 2 values. Any number or the string values 'negative infinity' and 'infinity'-10,10
visibleRangearrayMust contain 2 values. Any number or the string values 'negative infinity' and 'infinity'-10,10
dependentVarstringSet the variable to be labelled on the horizontal axis of the graph'x'
independentVarstringSet the variable to be labelled on the vertical axis of the graph'y'
borderbooleanSet to true to show a border around the graph, false for no bordertrue
borderColourstringhex, rgb, or rgba color scheme'#000000'
borderWidthintegerValue to set the thickness of the border2
squarebooleanWhen set to true the graph will always render in a square regardless of the container dimensionsfalse
xobjectSee axis properties below
yobjectSee axis properties below
graphTitlestringAny string of characters'This is the Title'

Axis Properties

PropertyTypeOptionsDefault
gridLinesbooleanSet to true to show the axis gridlines on the graph, or false to remove themtrue
gridstartnumberA reference value on the axis for gridlines to start from0
gridspacenumberA value for the spacing between gridlines0.5
tickStartnumberA reference value on the axis for axis ticks to start from0
tickSpacenumberA value for the spacing between gridlines0.5
3.0.1

3 years ago

3.0.0

3 years ago

2.1.10

3 years ago

2.1.9

6 years ago

2.1.8

6 years ago

2.1.7

6 years ago

2.1.4

6 years ago

2.1.3

6 years ago

2.1.6

6 years ago

2.1.5

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago