Referencegraph (Page 1)

<graph>

<graph> is a Graphical component that renders a 2D cartesian graph.

Attributes and Properties

Attributes for <graph>
AttributeTypeValues
aspectRatio = "…"number
displayDecimals = "…"integer
displayDigits = "…"integer
displayMode = "…"text"block" "inline"
displaySmallAsZero = "…"number
displayXAxis = "…"boolean"true" "false"
displayXAxisTickLabels = "…"boolean"true" "false"
displayYAxis = "…"boolean"true" "false"
displayYAxisTickLabels = "…"boolean"true" "false"
fixAxes = "…"boolean"true" "false"
grid = "…"
hideOffGraphIndicators = "…"boolean"true" "false"
horizontalAlign = "…"text"center" "left" "right"
identicalAxisScales = "…"boolean"true" "false"
padZeros = "…"boolean"true" "false"
showBorder = "…"boolean"true" "false"
showNavigation = "…"boolean"true" "false"
size = "…"text"tiny" "small" "medium" "large" "full"
width = "…"componentSize
xLabelPosition = "…"text"right" "left"
xMax = "…"number
xMin = "…"number
xTickScaleFactor = "…"math
yLabelAlignment = "…"text"left" "right"
yLabelPosition = "…"text"top" "bottom"
yMax = "…"number
yMin = "…"number
yTickScaleFactor = "…"math
Props for <graph name="g">
PropertyType
$g.aspectRationumber
$g.disabledboolean
$g.displayDecimalsinteger
$g.displayDigitsinteger
$g.displayModetext
$g.displaySmallAsZeronumber
$g.displayXAxisboolean
$g.displayXAxisTickLabelsboolean
$g.displayYAxisboolean
$g.displayYAxisTickLabelsboolean
$g.fixAxesboolean
$g.fixedboolean
$g.fixLocationboolean
$g.grid
$g.hiddenboolean
$g.hideOffGraphIndicatorsboolean
$g.horizontalAligntext
$g.identicalAxisScalesboolean
$g.padZerosboolean
$g.showBorderboolean
$g.showNavigationboolean
$g.sizetext
$g.widthcomponentSize
$g.xLabellabel
$g.xLabelPositiontext
$g.xMaxnumber
$g.xMinnumber
$g.xscalenumber
$g.xTickScaleFactormath
$g.yLabellabel
$g.yLabelAlignmenttext
$g.yLabelPositiontext
$g.yMaxnumber
$g.yMinnumber
$g.yscalenumber
$g.yTickScaleFactormath

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 (0,0)(0,0).

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