Axis

An Axis for plotting data.

Constructor

new Axis(range, render_start, render_end, labelopt, ticksopt, styleopt, stroke_widthopt)

Creates a new Axis with the given range and label.

Parameters:
NameTypeAttributesDescription
rangeClosedInterval

The range of the axis.

render_startPoint2D

The minimum coordinates of the axis when rendered.

render_endPoint2D

The maximum coordinates of the axis when rendered.

labelVectorObjectBuilder | null<optional>

The label of the axis.

ticksArray.<Tick> | null<optional>

The ticks of the axis.

styleStyle | null<optional>

The style of the axis.

stroke_widthnumber | null<optional>

The stroke width of the axis.

Classes

Axis

Members

label

Returns the label of the axis.

num_ticks

Returns the number of ticks on the axis.

range

Returns the range of the axis.

render_end

Returns the maximum x-coordinate of the axis when rendered.

render_start

Returns the minimum x-coordinate of the axis when rendered.

style

Returns the style of the axis.

ticks

Returns the ticks of the axis.

Methods

clone() → {Axis}

Clones the axis.

Returns:
Type: 
Axis

coord_to_point(num) → {Point2D}

Gets the coordinates of a point in the axis.

Parameters:
NameTypeDescription
numnumber
Returns:

The coordinates of the point in the axis.

Type: 
Point2D

point_to_coord(point) → {number}

Gets the value of a point in the axis.

Parameters:
NameTypeDescription
pointPoint2D
Returns:

The value of the point in the axis.

Type: 
number

tick(num) → {Tick|undefined}

Returns the tick at the given number.

Parameters:
NameTypeDescription
numnumber

The number coo

Returns:

The tick at the given number.

Type: 
Tick | undefined

vector_object_builder(label_directionopt, label_offsetopt, tick_label_directionopt, tick_label_offsetopt, add_labelopt) → {VectorObjectBuilder}

Gets the VectorObjectBuilder such that when built and rendered, the axis is drawn.

Parameters:
NameTypeAttributesDescription
label_directionPoint2D | null<optional>

The direction of the label. The default is (1, 0).

label_offsetnumber | null<optional>

The offset of the label. The default is 20.0.

tick_label_directionPoint2D | null<optional>

The direction of the tick label. The default is (0, 1).

tick_label_offsetnumber | null<optional>

The offset of the tick label. The default is 10.0.

add_labelboolean | null<optional>

Whether to add the axis label. The default is true.

Returns:

A vector object builder with the axis.

Type: 
VectorObjectBuilder

with_tip_at_the_end(tip_shape, label_directionopt, label_offsetopt, tick_label_directionopt, tick_label_offsetopt) → {VectorObjectBuilder}

Returns the VectorObjectBuilder with the axis and tip at the end.

Parameters:
NameTypeAttributesDescription
tip_shapeVectorObjectBuilder

The shape of the tip. The shape must be pointing to the right and centered to (0, 0), this function will rotate and move it to the correct angle.

label_directionPoint2D | null<optional>

The direction of the label. The default is (1, 0).

label_offsetnumber | null<optional>

The offset of the label. The default is 20.0.

tick_label_directionPoint2D | null<optional>

The direction of the tick label. The default is (0, 1).

tick_label_offsetnumber | null<optional>

The offset of the tick label. The default is 10.0.

Returns:

A VectorObjectBuilder with the axis and tip at the end.

Type: 
VectorObjectBuilder

with_tips_at_both_ends(tip_shape, label_directionopt, label_offsetopt, tick_label_directionopt, tick_label_offsetopt) → {VectorObjectBuilder}

Returns the VectorObjectBuilder with the axis and tips at both ends.

Parameters:
NameTypeAttributesDescription
tip_shapeVectorObjectBuilder

The shape of the tip. The shape must be pointing to the right, this function will rotate and move it to the correct angle.

label_directionPoint2D | null<optional>

The direction of the label. The default is (1, 0).

label_offsetnumber | null<optional>

The offset of the label. The default is 20.0.

tick_label_directionPoint2D | null<optional>

The direction of the tick label. The default is (0, 1).

tick_label_offsetnumber | null<optional>

The offset of the tick label. The default is 10.0.

Returns:

A VectorObjectBuilder with the axis and tips at both ends.

Type: 
VectorObjectBuilder