<legend>
<legend> is a Graphical
component that renders a legend when nested inside a <graph>. Individual
legend entries are defined with the <label> component.
Attributes and Properties
Attributes for <legend>
Labels (1)
labelIsNameboolean. Default value: false. Whether to use this component's name as its rendered label.
Other (4)
applyStyleToLabelboolean. Default value: false. Whether to apply this component's selected style to its label.
boolean. Default value: false. Whether to render closed/filled swatches in the legend.
layerinteger. Default value: 0. Z-order layer index used to stack graphical components (higher values render on top).
keyword. Position of the legend on the graph.
| Value | Description |
|---|---|
upperRight (default) | Place the legend in the upper-right corner. |
upperLeft | Place the legend in the upper-left corner. |
lowerRight | Place the legend in the lower-right corner. |
lowerLeft | Place the legend in the lower-left corner. |
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 <legend name="l">
Labels (2)
$l.labellabel. The label rendered with this component.
$l.labelIsNameboolean. Whether to use this component's name as its rendered label.
Other (8)
$l.applyStyleToLabelboolean. Whether to apply this component's selected style to its label.
$l.disabledboolean. Whether this component is disabled and cannot be interacted with.
$l.displayClosedSwatchesboolean. Whether to render closed/filled swatches in the legend.
$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.layerinteger. Z-order layer index used to stack graphical components (higher values render on top).
$l.positiontext. Position of the legend on the graph.
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 <legend> within a <graph>
By default, <label> children are assigned to graphical objects with unique styleNumber
attributes in the order in which they are defined within the <graph>.
Example: <legend> with labels assigned by name
By default, <label> children are assigned to graphical objects with unique styleNumber
attributes in the order in which they are defined within the <graph>.
This default order can be altered in the following way: use the forObject attribute
within each <label> child, and as its input list the name of the component the
label is attached to (no need to include the $).
Attribute Examples
Attribute Example: position
The default position for the <legend> is in the upper-right corner of the graphing window.
To adjust this, use the position attribute. Valid text inputs for this attribute
are: upperright, upperleft, lowerright and lowerleft.
Attribute Example: displayClosedSwatches
When a graph contains filled shapes, the displayClosedSwatches attribute can be
used to alter the appearance of the symbols within the <legend> from that of the default line.