Class: NGon

d3_geometer. NGon

new NGon(group)

Represents a polygon of n sides. Always returns the nGon selection which mimics the chainable d3 style interface.
Parameters:
Name Type Description
group Object A d3 group selection.
Source:

Methods

(inner) _nGon(radius, sides)

Inner "parent" function that is always returned in each method, which allows for chaining.
Parameters:
Name Type Description
radius Number Size of entire shape - calculated using the unit circle
sides Number Number of sides.
Source:

(inner) calculateEdgeOffsets(modulo) → {Object}

Calculates all positions for each vertex to connect to - offset by one, since adjacent vertices are already connected,
Parameters:
Name Type Description
modulo Number A modulo to allow custom numerical offsets.
Source:
Returns:
- nGon selection
Type
Object

(inner) drawAngle(deg, x, y, rotation) → {Object}

Draws any arbitrary angle given coordinates, degree and rotation.
Parameters:
Name Type Description
deg Number the degree of rotation
x Number the x position
y Number the y position
rotation Number the angle
Source:
Returns:
- nGon selection
Type
Object

(inner) drawCenterPoint(use_labels) → {Object}

Simply draws the center vertex
Parameters:
Name Type Description
use_labels Boolean Add a label to center point
Source:
Returns:
- nGon selection
Type
Object

(inner) drawLabels() → {Object}

Draws labels for all vertices on the nGon.
Source:
Returns:
- nGon selection
Type
Object

(inner) drawNearAdjacentEdges(connections) → {Object}

Draws edges directly adjacent + 1 to each vertex. see calculateEdgeOffsets for details.
Parameters:
Name Type Description
connections Array A list of custom connections -must be an array of objects with x and y accessors
Source:
Returns:
- nGon selection
Type
Object

(inner) drawPerimeterInteriorAngles() → {Object}

Uses util function to get all interior angles on the outer perimeter and then draws it for each vertex
Source:
Throws:
Error
Returns:
- nGon selection
Type
Object

(inner) drawRightAngle(x, y) → {Object}

Draws a right angle given coordinates.
Parameters:
Name Type Description
x Number the x position
y Number the y position
Source:
Returns:
- nGon selection
Type
Object

(inner) drawVertices() → {Object}

Draws vertices for all points on the nGon.
Source:
Returns:
- nGon selection
Type
Object

(inner) getCoords(radius, sides)

Generate the coordinates for each point based on number of sides of the nGon.
Parameters:
Name Type Description
radius Number Size of entire shape - calculated using the unit circle
sides Number Number of sides. returns {Array} - list of objects with coordinates and label of each vertex
Source:

(inner) label(text, x, y) → {Object}

Draw a custom label, wherever.
Parameters:
Name Type Description
text String the label text.
x Number x position
y Number y position
Source:
Returns:
- nGon selection
Type
Object

(inner) move(x, y) → {Object}

Move the entire nGon.
Parameters:
Name Type Description
x Number the x position to move to
y Number the y position to move to
Source:
Returns:
- nGon selection
Type
Object

(inner) rotate(deg, el) → {Object}

Rotate a given element.
Parameters:
Name Type Description
deg Number the amount, in degrees, to rotate by
el String the d3 selector (class, tag, etc..) to rotate.
Source:
Returns:
- nGon selection
Type
Object

(inner) sumTotalInteriorAngles() → {Number}

Calculates the sum of all interior angles.
Source:
Returns:
result - the result of calculating all interior angles
Type
Number