Skip to content

TrendLinePlot

ClassChartGuruChartGuru
public class TrendLinePlot : ChartMark, IChartMark, IChartContent

First-class trend line mark that wraps ChartGuru.TrendLineUtils regression calculations into a renderable chart mark implementing ChartGuru.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

Name Type
sourcePoints UnityEngine.Vector2[]
type ChartGuru.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

Name Type
xValues System.Single[]
yValues System.Single[]
type ChartGuru.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

Name Type
data System.Collections.Generic.IEnumerable{{T}}
xSelector System.Func{{T},System.Single}
ySelector System.Func{{T},System.Single}
type ChartGuru.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 TrendLinePlot RegressionType(RegressionType type)

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

Parameters

Name Type
type ChartGuru.RegressionType

Returns

ChartGuru.TrendLinePlot

public TrendLinePlot PolynomialDegree(int degree)

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

Parameters

Name Type
degree System.Int32

Returns

ChartGuru.TrendLinePlot

public TrendLinePlot Samples(int count)

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

Parameters

Name Type
count System.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

Name Type
min System.Single
max System.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

Name Type
width System.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

Name Type
style ChartGuru.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

Name Type
color UnityEngine.Color

Returns

ChartGuru.TrendLinePlot

public TrendLinePlot ShowEquation(bool show = true)

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

Parameters

Name Type
show System.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

Name Type
show System.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

Name Type
targetType ChartGuru.ChartType
plotArea UnityEngine.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