<lineSegment>
<lineSegment> is a Graphical
component that renders a line segment when nested within a <graph> component.
Attributes and Properties
Attributes for <lineSegment>
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 (11)
addControlskeyword. Whether to render interactive control handles.
| Value | Description |
|---|---|
endpoints (default) | Show control handles for both endpoints of the segment. |
none | Show no control handles. |
applyStyleToLabelboolean. Default value: false. Whether to apply this component's selected style to its label.
controlOrderinteger. Default value: 0. Slot order for graph controls (1-indexed; 0 means no explicit slot request).
boolean. Default value: true. Whether the line segment can be dragged on a graph.
[ pointList ]. The two endpoints of the line segment.
boolean. Whether the line segment's endpoints can be dragged.
labelPositionkeyword. Where the label sits along this line/curve.
| Value | Description |
|---|---|
upperRight | Place the label above and to the right of the line. |
upperLeft | Place the label above and to the left of the line. |
lowerRight | Place the label below and to the right of the line. |
lowerLeft | Place the label below and to the left of the line. |
center (default) | Place the label at the midpoint of the line. |
top | Place the label directly above the line. |
bottom | Place the label directly below the line. |
left | Place the label directly to the left of the line. |
right | Place the label directly to the right of the line. |
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.
boolean. Default value: true. Whether to show coordinate labels while dragging.
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 <lineSegment name="l">
Number display (5)
$l.avoidScientificNotationboolean. Whether to render numbers in full decimal form rather than scientific notation.
$l.displayDecimalsinteger. Number of decimal places to display when rendering this number.
$l.displayDigitsinteger. Number of significant digits to display when rendering this number.
$l.displaySmallAsZeronumber. Threshold below which numbers are displayed as zero.
$l.padZerosboolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Labels (2)
$l.labellabel. The label rendered with this component.
$l.labelIsNameboolean. Whether to use this component's name as its rendered label.
Other (18)
$l.addControlstext. Whether to render interactive control handles.
$l.applyStyleToLabelboolean. Whether to apply this component's selected style to its label.
$l.controlOrderinteger. Slot order for graph controls (1-indexed; 0 means no explicit slot request).
$l.disabledboolean. Whether this component is disabled and cannot be interacted with.
$l.draggableboolean. Whether the line segment can be dragged on a graph.
$l.endpoints[ math ]. The endpoints of the line segment.
$l.endpointsDraggableboolean. Whether each endpoint can be dragged independently.
$l.fixedboolean. Whether this component's value is fixed and cannot be modified.
$l.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$l.labelPositiontext. Where the label sits along this line/curve.
$l.layerinteger. Z-order layer index used to stack graphical components (higher values render on top).
$l.lengthmath. The length of the line segment.
number. Number of dimensions the segment lives in.
$l.showCoordsWhenDraggingboolean. Whether to show coordinate labels while dragging.
$l.slopenumber. The slope of the line segment (2D only).
$l.styleDescriptiontext. A textual description of the line segment's style.
$l.styleDescriptionWithNountext. Style description including "line segment".
Common to all components (4)
$l.doenetMLtext. The DoenetML source code that produced this component.
$l.hideboolean. Whether to hide this component from the rendered output.
$l.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$l.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: Default <lineSegment>
Without any attributes, the default <lineSegment> has endpoints and .
Example: <lineSegment> with rendered endpoints
The endpoints property of a named <lineSegment> can be
rendered on a <graph> with the reference $name.property.
Example: <lineSegment> constrained to a grid
The endpoints of a <lineSegment> are predefined as constrained points,
thereby constraining the segment to a grid as well.
Attribute Examples
Attribute Example: endpoints
The endpoints attribute takes as an input a list of two points.
Attribute Example: draggable
The draggable attribute determines whether the <lineSegment> can be
dragged around the <graph>. All graphical objects are draggable by default.
Attribute Example: endpointsDraggable
Endpoints are draggable by default. Use the endpointsDraggable attribute set to
false to disable users from changing the shape and length of the <lineSegment>. The segment
as a whole can still be repositioned on the <graph>.
Attribute Example: showCoordsWhenDragging
By default, a light-grey set of coordinates is shown while the user drags the
endpoints of the line segment. To turn off this default behavior, set the showCoordsWhenDragging attribute
to false.
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: numDimensions
The numDimensions property returns the number of dimesions of the <lineSegment>.
Property Example: length
The length property returns the length of the <lineSegment>.
Property Example: slope
The slope property returns the slope of the <lineSegment>.