Referencelegend

<legend>

A legend describing the contents of a graph

<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)
labelIsName

boolean. Default value: false. Whether to use this component's name as its rendered label.

Other (4)
applyStyleToLabel

boolean. 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.

layer

integer. 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.

ValueDescription
upperRight (default)Place the legend in the upper-right corner.
upperLeftPlace the legend in the upper-left corner.
lowerRightPlace the legend in the lower-right corner.
lowerLeftPlace the legend in the lower-left corner.
Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. 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.label

label. The label rendered with this component.

$l.labelIsName

boolean. Whether to use this component's name as its rendered label.

Other (8)
$l.applyStyleToLabel

boolean. Whether to apply this component's selected style to its label.

$l.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$l.displayClosedSwatches

boolean. Whether to render closed/filled swatches in the legend.

$l.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$l.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$l.hidden

boolean. Whether this component is hidden from the rendered output.

$l.layer

integer. Z-order layer index used to stack graphical components (higher values render on top).

$l.position

text. Position of the legend on the graph.

Common to all components (4)
$l.doenetML

text. The DoenetML source code that produced this component.

$l.hide

boolean. Whether to hide this component from the rendered output.

$l.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$l.styleNumber

integer. 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.