<polyline>
<polyline> is a Graphical
component that renders a polyline when nested inside a <graph> component.
Attributes and Properties
Attributes for <polyline>
Number display (5)
avoidScientificNotationboolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.
displayDecimalsinteger. Default value: 2. Number of decimal places to display when rendering this number.
displayDigitsinteger. Default value: 3. Number of significant digits to display when rendering this number.
displaySmallAsZeronumber. Default value: 1e-14. Threshold below which numbers are displayed as zero.
padZerosboolean. Default value: false. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Labels (1)
labelIsNameboolean. Default value: false. Whether to use this component's name as its rendered label.
Other (19)
boolean. Default value: true. Whether the shape can be dilated (scaled) under drag.
boolean. Default value: true. Whether the polyline can be reflected under drag.
boolean. Default value: true. Whether the polyline can be rotated under drag.
boolean. Default value: true. Whether the polyline can be translated under drag.
applyStyleToLabelboolean. Default value: false. Whether to apply this component's selected style to its label.
boolean. Default value: true. Whether the polyline can be dragged on a graph.
layerinteger. Default value: 0. Z-order layer index used to stack graphical components (higher values render on top).
lineStylekeyword. Stroke style for lines.
| Value | Description |
|---|---|
solid | Continuous, unbroken stroke. |
dashed | Stroke composed of evenly-spaced dashes. |
dotted | Stroke composed of evenly-spaced dots. |
lineWidthnumber. Stroke width for lines, in pixels.
minShrinknumber. Default value: 0.1. Minimum scaling factor allowed when dilating.
boolean. Default value: false. Whether the shape is preserved up to similarity (uniform scaling) under drag.
boolean. Default value: false. Whether the polyline is treated as rigid (preserves shape under drag).
keyword. What point to rotate the shape around.
| Value | Description |
|---|---|
centroid (default) | Rotate around the centroid of the shape. |
vertex | Rotate around the vertex specified by rotationVertex. |
point | Rotate around the explicit point given by rotationCenter. |
rotationCenterpoint. The point to rotate around when rotateAround is 'point'.
rotationHandleVerticesnumberList. Default value: [1]. Vertex indices that should display rotation handles when the shape is rigid or preserves similarity.
rotationVertexinteger. Default value: 1. The vertex index to rotate around when rotateAround is 'vertex'.
showCoordsWhenDraggingboolean. Default value: true. Whether to show coordinate labels while dragging.
[ pointList ]. The list of vertex points that define the shape.
boolean. Whether individual vertices may be dragged independently.
Common to all components (9)
copyreference. Create an independent copy of another component by reference. Enter a references a $name.
disabledboolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseboolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. Default value: 1. The style number used to select this component's visual styling from the available style definitions.
Properties for <polyline name="p">
Number display (5)
$p.avoidScientificNotationboolean. Whether to render numbers in full decimal form rather than scientific notation.
$p.displayDecimalsinteger. Number of decimal places to display when rendering this number.
$p.displayDigitsinteger. Number of significant digits to display when rendering this number.
$p.displaySmallAsZeronumber. Threshold below which numbers are displayed as zero.
$p.padZerosboolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Labels (2)
$p.labellabel. The label rendered with this component.
$p.labelIsNameboolean. Whether to use this component's name as its rendered label.
Other (22)
$p.allowDilationboolean. Whether the polyline can be dilated under drag.
$p.allowReflectionboolean. Whether the polyline can be reflected under drag.
$p.allowRotationboolean. Whether the polyline can be rotated under drag.
$p.allowTranslationboolean. Whether the polyline can be translated under drag.
$p.applyStyleToLabelboolean. Whether to apply this component's selected style to its label.
$p.center[ math ]. The centroid of the polyline's vertices.
$p.disabledboolean. Whether this component is disabled and cannot be interacted with.
$p.draggableboolean. Whether the polyline can be dragged on a graph.
$p.fixedboolean. Whether this component's value is fixed and cannot be modified.
$p.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$p.layerinteger. Z-order layer index used to stack graphical components (higher values render on top).
$p.lengthnumber. The total length of the polyline.
$p.numDimensionsnumber. The number of dimensions the polyline lives in.
$p.numVerticesnumber. The number of vertices in the polyline.
$p.preserveSimilarityboolean. Whether the polyline preserves its shape (up to similarity).
$p.rigidboolean. Whether the polyline is treated as rigid (preserves shape under drag).
$p.showCoordsWhenDraggingboolean. Whether to show coordinate labels while dragging.
$p.styleDescriptiontext. A textual description of the polyline's style.
$p.styleDescriptionWithNountext. Style description including the word "polyline".
$p.vertices[ math ]. The vertices of the polyline.
$p.verticesDraggableboolean. Whether each vertex can be dragged independently.
Common to all components (4)
$p.doenetMLtext. The DoenetML source code that produced this component.
$p.hideboolean. Whether to hide this component from the rendered output.
$p.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$p.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: Default <polyline>
The default <polyline> requires the vertices attribute as a minimum.
Example: <polyline> constrained to grid
The vertices of a <polyline> are predefined as constrained points, thereby
constraining the polyline to a grid as well.
Attribute Examples
Attribute Example: vertices
The vertices attribute takes a list of points as its input.
Attribute Example: draggable
The draggable attribute determines whether the <polyline> can be
dragged around the <graph>. All graphical objects are draggable by default.
Attribute Example: verticesDraggable
Vertices are draggable by default. Use the verticesDraggable attribute set
to false to disable users from changing the proportions of the <polyline>. The
polyline as a whole can still be repositioned on the <graph>.
Attribute Example: rigid
The rigid attribute locks the shape and size of the <polyline>, treating it as a rigid body. Drag an edge to translate the polyline, and drag the highlighted vertex to rotate it about its centroid. Only that highlighted vertex (the rotation handle) is draggable; the other vertices are locked. The default value is false, in which case each vertex may be dragged independently.
Attribute Example: preserveSimilarity
The preserveSimilarity attribute preserves the shape of the <polyline> up to similarity: dragging the highlighted vertex rotates and uniformly scales (dilates) the polyline, while dragging an edge translates it. Unlike rigid, the overall size may change. The default value is false.
Attribute Example: allowRotation
When the <polyline> is rigid or preserves similarity, the allowRotation attribute controls whether dragging the highlighted vertex may rotate it. Set to false to forbid rotation. The default value is true. Because this polyline uses preserveSimilarity (which allows dilation), disabling rotation leaves the highlighted vertex able to uniformly scale the polyline.
Attribute Example: allowTranslation
When the <polyline> is rigid or preserves similarity, the allowTranslation attribute controls whether dragging an edge may move it. Set to false to forbid translation. The default value is true.
Attribute Example: allowDilation
When the <polyline> preserves similarity, the allowDilation attribute controls whether dragging the highlighted vertex may uniformly scale it. The default value is true; combining preserveSimilarity with allowDilation="false" is equivalent to rigid. (Setting rigid always forces dilation off.)
Attribute Example: allowReflection
The allowReflection attribute controls whether the <polyline> may be flipped (reflected) across a vertical line through its centroid. The default value is true.
Reflection is not currently triggered by a built-in drag or click gesture; it is performed by the reflectPolyline action. In this example that action is invoked with <callAction> whenever a polyline is clicked. The first polyline reflects on each click, while the second has allowReflection="false", so clicking it has no effect.
Attribute Example: rotateAround
When the <polyline> is rigid or preserves similarity, the rotateAround attribute sets the center of rotation. Valid values are centroid (the default), vertex (the vertex given by rotationVertex), and point (the explicit point given by rotationCenter).
Attribute Example: Standard graphical attributes
The uses of the following standard graphical attributes are
illustrated: hide, fixLocation, layer, styleNumber, applyStyleToLabel and labelIsName.
Property Examples
Property Example: Style properties
The styleDescription and styleDescriptionWithNoun properties render a
text description corresponding to the styleNumber of the component.