ReferencebestFitLine

<bestFitLine>

<bestFitLine> is a Graphical component computes a linear regression through a list of points. When nested inside a <graph>, the <bestFitLine> component displays a line.
The equation for the line of best fit can be rendered by accessing the equation property.

Attributes and Properties

Attributes for <bestFitLine>
AttributeTypeValues
applyStyleToLabel = "…"boolean"true" "false"
data = "…"[ math ]
displayDecimals = "…"integer
displayDigits = "…"integer
displaySmallAsZero = "…"number
labelIsName = "…"boolean"true" "false"
labelPosition = "…"text"upperright" "upperleft" "lowerright" "lowerleft"
layer = "…"integer
padZeros = "…"boolean"true" "false"
parallelTo = "…"
perpendicularTo = "…"
variables = "…"[ _variableName ]
Props for <bestFitLine name="b">
PropertyType
$b.applyStyleToLabelboolean
$b.backgroundColortext
$b.coeff0math
$b.coeffvar1math
$b.coeffvar2math
$b.data[ math ]
$b.disabledboolean
$b.displayDecimalsinteger
$b.displayDigitsinteger
$b.displaySmallAsZeronumber
$b.draggableboolean
$b.equationmath
$b.fixedboolean
$b.fixLocationboolean
$b.hiddenboolean
$b.labellabel
$b.labelIsNameboolean
$b.labelPositiontext
$b.latexlatex
$b.layerinteger
$b.numDimensionsnumber
$b.padZerosboolean
$b.points[ math ]
$b.slopemath
$b.styleDescriptiontext
$b.styleDescriptionWithNountext
$b.texttext
$b.textColortext
$b.textStyleDescriptiontext
$b.variables[ _variableName ]
$b.xinterceptmath
$b.yinterceptmath

Example: <bestFitLine> through 3 points

A <bestFitLine> is rendered through three named <point> components. Note that the data in this example are not specified as fixed and when the points are moved the regression line will update accordingly.


Example: <bestFitLine> from user-input

A <bestFitLine> is rendered through three named <point> components. Coordinates for the points are provided by the user with the <mathInput/> component.


Example: Plot data and determine equation

A <bestFitLine> is rendered through an arbitrary number of data points generated with a <callAction> component that adds <point> children to the named <graph>.

The <collect> component gathers the information required from the <graph> to provide to the data attribute of the <bestFitLine> without having to assign individual names to each <point>.


Attribute Example: data

The data attribute specifies the data points through which to fit a regression.


Attribute Example: variables

The variables attribute allows customization of the independent and dependent variable name when rendering the equation of the computed regression line.


Property Example: equation

The equation property of the named <bestFitLine> renders the equation of the computed regression line.


Property Example: slope

The slope property of the named <bestFitLine> renders the slope of the computed regression line.


Property Example: coeff0, coeffVar1, coeffVar2

Linear coefficients corresponding to the linear form A x + B y + C = 0 can be obtained with the above properties, where C=C = coeff0, B=B = coeffVar2 and A=A = coeffVar1.


Property Example: xIntercept, yIntercept

Use the xIntercept and yIntercept properties of the named <bestFitLine> to determine the intercepts of the computed regression line.


Property Example: latex

The latex property renders the latex code for rendering the equation of the computed regression line.


Property Example: data

The data property renders two through points computed for the linear regression.


Property Example: variables

The variables property renders the two variables used when rendering the equation for the linear regression.


Property Example: numDimensions

The numDimensions property renders the number of dimensions for the linear regression.