<graph>
<graph> is a Graphical
component that renders a 2D cartesian graph.
Attributes and Properties
Attributes for <graph>
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.
Other (30)
addControlskeyword. Whether to render interactive zoom/pan controls.
| Value | Description |
|---|---|
all | Render both sliders and input boxes. |
slidersOnly | Render only slider controls. |
inputsOnly | Render only input-box controls. |
none (default) | Render no interactive controls. |
number. Default value: 1. Aspect ratio (width / height) for the graph.
controlsPositionkeyword. Position of the graph controls.
| Value | Description |
|---|---|
bottom | Place controls below the graph. |
left (default) | Place controls to the left of the graph. |
right | Place controls to the right of the graph. |
top | Place controls above the graph. |
boolean. Default value: false. Whether the graph is purely decorative (excluded from a11y tree).
keyword. How to size the graph.
| Value | Description |
|---|---|
block (default) | Display as a block element on its own line. |
inline | Render inline with surrounding text. |
boolean. Default value: true. Whether to display the x axis.
boolean. Default value: true. Whether to display labels on x-axis ticks.
boolean. Default value: true. Whether to display tick marks on the x axis.
boolean. Default value: true. Whether to display the y axis.
boolean. Default value: true. Whether to display labels on y-axis ticks.
boolean. Default value: true. Whether to display tick marks on the y axis.
boolean. Default value: false. Whether the axis limits are locked (preventing zoom/pan).
text. Grid density to render on the graph (off, minor, medium, or major).
hideOffGraphIndicatorsboolean. Default value: false. Whether to suppress indicators for objects outside the visible region.
keyword. Horizontal alignment of the graph within its container.
| Value | Description |
|---|---|
center (default) | Center the graph horizontally. |
left | Align the graph to the left edge. |
right | Align the graph to the right edge. |
boolean. Default value: false. Whether to force the x and y axis scales to be equal.
rendererkeyword. Which renderer to use for the graph.
| Value | Description |
|---|---|
doenet (default) | Render using the built-in Doenet graph renderer. |
prefigure | Render using the PreFigure SVG-based renderer. |
boolean. Default value: true. Whether to render a border around the graph.
keyword. Named size preset for the graph.
| Value | Description |
|---|---|
tiny | About 1/12 the full width. |
small | About 30% of the full width. |
medium (default) | About half the full width. |
large | About 70% of the full width. |
full | The full available width. |
componentSize. Explicit width of the graph (overrides size).
keyword. Position of the x-axis label.
| Value | Description |
|---|---|
right (default) | Place the x-axis label at the right end of the axis. |
left | Place the x-axis label at the left end of the axis. |
number. Default value: 10. Maximum value displayed on the x axis.
number. Default value: -10. Minimum value displayed on the x axis.
math. Scale factor applied to x-axis tick spacing.
keyword. Alignment of the y-axis label.
| Value | Description |
|---|---|
left (default) | Align the y-axis label to the left of the axis. |
right | Align the y-axis label to the right of the axis. |
keyword. Position of the y-axis label.
| Value | Description |
|---|---|
top (default) | Place the y-axis label at the top of the axis. |
bottom | Place the y-axis label at the bottom of the axis. |
number. Default value: 10. Maximum value displayed on the y axis.
number. Default value: -10. Minimum value displayed on the y axis.
math. Scale factor applied to y-axis tick spacing.
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 <graph name="g">
Number display (5)
$g.avoidScientificNotationboolean. Whether to render numbers in full decimal form rather than scientific notation.
$g.displayDecimalsinteger. Number of decimal places to display when rendering this number.
$g.displayDigitsinteger. Number of significant digits to display when rendering this number.
$g.displaySmallAsZeronumber. Threshold below which numbers are displayed as zero.
$g.padZerosboolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Other (42)
$g.addControlstext. Whether to render interactive zoom/pan controls.
$g.aspectRationumber. The aspect ratio (width / height) of the graph.
$g.controlsPositiontext. Position of the graph controls.
$g.decorativeboolean. Whether the graph is purely decorative (excluded from a11y tree).
$g.disabledboolean. Whether this component is disabled and cannot be interacted with.
$g.displayModetext. How to size the graph.
$g.displayXAxisboolean. Whether to display the x axis.
$g.displayXAxisTickLabelsboolean. Whether x-axis tick labels are displayed.
$g.displayXAxisTicksboolean. Whether to display tick marks on the x axis.
$g.displayYAxisboolean. Whether to display the y axis.
$g.displayYAxisTickLabelsboolean. Whether y-axis tick labels are displayed.
$g.displayYAxisTicksboolean. Whether to display tick marks on the y axis.
$g.effectiveRenderertext. The renderer actually used after resolving fallbacks.
$g.fixAxesboolean. Whether the visible axes range is locked.
$g.fixedboolean. Whether this component's value is fixed and cannot be modified.
$g.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$g.gridGrid line spacing on the graph.
$g.hasAuthorAnnotationsboolean. Whether the graph contains any author-provided <annotations> child.
$g.hideOffGraphIndicatorsboolean. Whether to suppress indicators for objects outside the visible region.
$g.horizontalAligntext. Horizontal alignment of the graph within its container.
$g.identicalAxisScalesboolean. Whether to force the x and y axis scales to be equal.
$g.prefigureXMLtext. The Prefigure-formatted XML rendered for this graph, or null if not using the Prefigure renderer.
$g.renderertext. Which renderer to use for the graph.
$g.shortDescriptiontext. A short accessibility description of the graph.
$g.showBorderboolean. Whether to render a border around the graph.
$g.sizetext. The size of the graph.
$g.widthcomponentSize. The width of the graph.
$g.xLabellabel. The x-axis label text.
$g.xLabelPositiontext. Position of the x-axis label.
$g.xMaxnumber. Maximum x value displayed.
$g.xMinnumber. Minimum x value displayed.
$g.xscalenumber. Scale used along the x axis (xMax − xMin).
$g.xTickScaleFactormath. Scale factor applied to x-axis tick spacing.
$g.yLabellabel. The y-axis label text.
$g.yLabelAlignmenttext. Alignment of the y-axis label.
$g.yLabelPositiontext. Position of the y-axis label.
$g.yMaxnumber. Maximum y value displayed.
$g.yMinnumber. Minimum y value displayed.
$g.yscalenumber. Scale used along the y axis (yMax − yMin).
$g.yTickScaleFactormath. Scale factor applied to y-axis tick spacing.
Common to all components (4)
$g.doenetMLtext. The DoenetML source code that produced this component.
$g.hideboolean. Whether to hide this component from the rendered output.
$g.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$g.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples Page 1
Example: Default <graph>
Here a default <graph> is illustrated without any additional attributes.
Example: <graph> with default grid
A <graph> with a default grid is illustrated. As you zoom in and out of
the graph the size of the grid adapts to the view. To zoom, use the (+) and (-) buttons
at the bottom of the graph.
Example: Invisible <graph> with shapes
A <graph> without border, axes, or navigation buttons appears invisible.
Example: <graph> with axis labels
Axis labels are specified using the <xLabel> and <yLabel> components as
children of the <graph>.
Example: <graph> with legend
Legends are constructed by adding a <legend> child to the <graph>
component. See <legend> for more examples.
Example: Components that can be placed on a <graph>
Many different components can be placed on a <graph>. If the anchor attribute
is included, the rendered object is centered at the point specified. Otherwise, the
component is centered at .
Note that <mathInput/> components cannot be placed on a <graph>.
Instead, a <textInput/> can be included, and basic math expressions can be
performed for math entered into a <textInput/>.
Attribute Examples
Attribute Example: xmin, xmax, ymin, ymax
Use the xmin, xmax, ymin and ymax attributes to adjust the extents of
the axis scales. Note that the relative proportions of the axes will automatically
adjust to keep the <graph> square unless the identicalAxisScales attribute
is also specified, as illustrated in the second graph.
Attribute Example: width
The width attribute specifies the absolute width of the graph. Doenet determines
the size category that corresponds to that width and sizes the graph accordingly.
Attribute Example: size
The size attribute specifies one of 5 size categories for the
<graph>: tiny, small, medium, large, or full.
Attribute Example: aspectRatio
The aspectRatio attribute allows for customization of the graph’s default proportions.
Attribute Example: displayMode
The displayMode attribute affects how the <graph> is positioned on screen.
The default mode is “block”, which renders the graph centered on screen. The available
modes are inline, and block.
Attribute Example: horizontalAlign
The horizontalAlign attribute specifies the horizontal position on-screen
for the default block-mode style graph. Valid values are left, center, and right,
with a default of center.