Skip to content

TrendLinePlot

ClassChartGuruChartGuru
public class TrendLinePlot : ChartMark, IChartMark, IChartContent, IGeneratedChartContent

First-class trend line mark that wraps TrendLineUtils regression calculations into a renderable chart mark implementing IChartContent. Swift Charts equivalent: LinearRegressionPlot(x:y:) (ChartGuru extends beyond linear to polynomial, exponential, logarithmic, and power regressions).

public TrendLinePlot(Vector2[] sourcePoints, RegressionType type = RegressionType.Linear)

Creates a regression plot over the supplied XY samples. A null point array is rejected.

Parameters

NameType
sourcePointsUnityEngine.Vector2[]
typeChartGuru.RegressionType

TrendLinePlot(float[], float[], RegressionType)

Section titled “TrendLinePlot(float[], float[], RegressionType)”
public TrendLinePlot(float[] xValues, float[] yValues, RegressionType type = RegressionType.Linear)

Creates a regression plot by pairing X and Y arrays up to the shorter length. Null arrays are rejected.

Parameters

NameType
xValuesSystem.Single[]
yValuesSystem.Single[]
typeChartGuru.RegressionType

FromData(IEnumerable, Func<T, float>, Func<T, float>, RegressionType)

Section titled “FromData(IEnumerable, Func<T, float>, Func<T, float>, RegressionType)”
public static TrendLinePlot FromData<T>(IEnumerable<T> data, Func<T, float> xSelector, Func<T, float> ySelector, RegressionType type = RegressionType.Linear)

Creates a trend-line plot from the supplied source records and projection callbacks.

Parameters

NameType
dataSystem.Collections.Generic.IEnumerable{{T}}
xSelectorSystem.Func{{T},System.Single}
ySelectorSystem.Func{{T},System.Single}
typeChartGuru.RegressionType

Returns

ChartGuru.TrendLinePlot

public IEnumerable<IChartMark> GetMarks()

Expands this composite content into individual chart marks for rendering.

Returns

System.Collections.Generic.IEnumerable{ChartGuru.IChartMark}: Enumerable of primitive chart marks.

public IEnumerable<IChartMark> GetGeneratedMarks()

Expands this regression plot through the common generated-content pipeline.

Returns

System.Collections.Generic.IEnumerable{ChartGuru.IChartMark}

public TrendLinePlot RegressionType(RegressionType type)

Selects the regression model fitted to the trend-line source points.

Parameters

NameType
typeChartGuru.RegressionType

Returns

ChartGuru.TrendLinePlot

public TrendLinePlot PolynomialDegree(int degree)

Sets the polynomial regression degree used when polynomial fitting is selected.

Parameters

NameType
degreeSystem.Int32

Returns

ChartGuru.TrendLinePlot

public TrendLinePlot Samples(int count)

Sets how many evenly spaced samples are generated across a function plot domain.

Parameters

NameType
countSystem.Int32

Returns

ChartGuru.TrendLinePlot

public TrendLinePlot Domain(float min, float max)

Sets the numeric input domain sampled by the plot; values outside the interval are not generated.

Parameters

NameType
minSystem.Single
maxSystem.Single

Returns

ChartGuru.TrendLinePlot

public TrendLinePlot LineStyle(float width)

Configures line width and dash behavior; selector overloads resolve the stroke separately for each datum.

Parameters

NameType
widthSystem.Single

Returns

ChartGuru.TrendLinePlot

public TrendLinePlot LineStyle(StrokeStyle style)

Configures line width and dash behavior; selector overloads resolve the stroke separately for each datum.

Parameters

NameType
styleChartGuru.StrokeStyle

Returns

ChartGuru.TrendLinePlot

public TrendLinePlot ForegroundStyle(Color color)

Configures the fill or stroke color used by generated marks; selector overloads resolve the style separately for each datum.

Parameters

NameType
colorUnityEngine.Color

Returns

ChartGuru.TrendLinePlot

public TrendLinePlot ShowEquation(bool show = true)

Controls whether the fitted trend-line equation is exposed as an annotation.

Parameters

NameType
showSystem.Boolean

Returns

ChartGuru.TrendLinePlot

public TrendLinePlot ShowRSquared(bool show = true)

Controls whether the fitted coefficient of determination is exposed with the trend-line annotation.

Parameters

NameType
showSystem.Boolean

Returns

ChartGuru.TrendLinePlot

public override (Vector2 source, Vector2 target) GetMorphTargets(ChartType targetType, Rect plotArea)

Projects this mark into plot-space geometry that the morph renderer can interpolate toward the requested chart type.

Parameters

NameType
targetTypeChartGuru.ChartType
plotAreaUnityEngine.Rect

Returns

System.ValueTuple{UnityEngine.Vector2,UnityEngine.Vector2}

public override IChartMark Clone()

Creates an independent copy of this Trend Line Plot; later configuration changes do not affect the original instance.

Returns

ChartGuru.IChartMark

public override ChartType MarkType { get; }

Returns

ChartGuru.ChartType

public DataPoint IChartContent_DataPoint { get; }

Returns

ChartGuru.DataPoint

public RegressionType RegressionKind { get; }

Returns

ChartGuru.RegressionType

public float RSquared { get; }

Returns

System.Single

public string EquationText { get; }

Returns

System.String

public bool ShowsEquation { get; set; }

Returns

System.Boolean

public bool ShowsRSquared { get; set; }

Returns

System.Boolean