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 radiusNumber Size of entire shape - calculated using the unit circle sidesNumber 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 moduloNumber 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 degNumber the degree of rotation xNumber the x position yNumber the y position rotationNumber the angle - Source:
Returns:
- nGon selection- Type
- Object
-
(inner) drawCenterPoint(use_labels) → {Object}
-
Simply draws the center vertex
Parameters:
Name Type Description use_labelsBoolean 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 connectionsArray 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:
ErrorReturns:
- nGon selection- Type
- Object
-
(inner) drawRightAngle(x, y) → {Object}
-
Draws a right angle given coordinates.
Parameters:
Name Type Description xNumber the x position yNumber 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 radiusNumber Size of entire shape - calculated using the unit circle sidesNumber 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 textString the label text. xNumber x position yNumber y position - Source:
Returns:
- nGon selection- Type
- Object
-
(inner) move(x, y) → {Object}
-
Move the entire nGon.
Parameters:
Name Type Description xNumber the x position to move to yNumber 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 degNumber the amount, in degrees, to rotate by elString 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