Skip to content

ChartLayoutEngine

ClassChartGuruChartGuru
public class ChartLayoutEngine

Renderer-agnostic layout engine for charts. Computes all positions, sizes, and layout data needed for rendering. This is the single source of truth for chart geometry.

All internal calculations are done in Cartesian coordinates (Y=0 at bottom). Use ProjectToGUI() methods or set TargetCoordinateSystem to GUI to get positions suitable for Unity Editor GUI rendering.

public int GetSeriesColorIndex(IChartMark mark)

Gets the color index for a mark based on its series key. All marks with the same SeriesKey get the same color.

Parameters

Name Type Description
mark ChartGuru.IChartMark

Returns

System.Int32 — No return description is available.

public Color GetMarkColor(IChartMark mark, int fallbackIndex = 0, int dataPointIndex = -1, int stripEndIndex = -1)

Gets the color for a mark. Priority: explicit ForegroundColor → ColorScale (numeric key) → theme color by SeriesKey → fallback Applies hover/selection effects based on dataPointIndex. When stripEndIndex >= 0, used for area strips: don’t dim if either dataPointIndex or stripEndIndex is selected.

Parameters

Name Type Description
mark ChartGuru.IChartMark
fallbackIndex System.Int32
dataPointIndex System.Int32
stripEndIndex System.Int32

Returns

UnityEngine.Color — No return description is available.

public Color GetThemeColor(int seriesIndex)

Gets the theme color for a given series index, ignoring any mark overrides. Used for legend swatches which should always show the base theme color.

Parameters

Name Type Description
seriesIndex System.Int32

Returns

UnityEngine.Color — No return description is available.

DetermineTrendLabelPosition(float, float?, float?)

Section titled “DetermineTrendLabelPosition(float, float?, float?)”
public static DataLabelPosition DetermineTrendLabelPosition(float currentValue, float? previousValue, float? nextValue)

No description is available for this member.

Parameters

Name Type Description
currentValue System.Single
previousValue System.Nullable{System.Single}
nextValue System.Nullable{System.Single}

Returns

ChartGuru.DataLabelPosition — No return description is available.

DetermineRadialLabelPosition(Vector2, bool)

Section titled “DetermineRadialLabelPosition(Vector2, bool)”
public static DataLabelPosition DetermineRadialLabelPosition(Vector2 direction, bool yIncreasesDownward = false)

No description is available for this member.

Parameters

Name Type Description
direction UnityEngine.Vector2
yIncreasesDownward System.Boolean

Returns

ChartGuru.DataLabelPosition — No return description is available.

public GridRenderData GetGridRenderData()

Generates grid render data for the current layout.

Returns

ChartGuru.GridRenderData — No return description is available.

GetAnimatedGridRenderData(Vector2, Vector2, float)

Section titled “GetAnimatedGridRenderData(Vector2, Vector2, float)”
public GridRenderData GetAnimatedGridRenderData(Vector2 sourceXDomain, Vector2 sourceYDomain, float progress)

Returns grid render data with positions interpolated between source and target domains. Used during data-change animations to smoothly slide grid lines alongside mark animations. Positions outside the plot area are excluded to prevent grid lines from bleeding outside the chart bounds when the domain expands or contracts.

Source X Domain (x=min, y=max) before data change. Source Y Domain (x=min, y=max) before data change. Eased animation progress in [0,1].

Parameters

Name Type Description
sourceXDomain UnityEngine.Vector2
sourceYDomain UnityEngine.Vector2
progress System.Single

Returns

ChartGuru.GridRenderData — No return description is available.

FillAnimatedYAxisLabels(Vector2, float, List)

Section titled “FillAnimatedYAxisLabels(Vector2, float, List)”
public void FillAnimatedYAxisLabels(Vector2 sourceDomain, float progress, List<AxisLabelInfo> result)

Fills Y-axis labels with screen positions interpolated between source and target domains. Label texts remain at their final (target) values; only screen positions are animated. Labels whose animated screen positions fall outside the plot area are excluded so they don’t bleed outside the chart bounds during expansion/contraction animations.

Parameters

Name Type Description
sourceDomain UnityEngine.Vector2
progress System.Single
result System.Collections.Generic.List{ChartGuru.AxisLabelInfo}

FillAnimatedXAxisLabels(Vector2, float, List)

Section titled “FillAnimatedXAxisLabels(Vector2, float, List)”
public void FillAnimatedXAxisLabels(Vector2 sourceDomain, float progress, List<AxisLabelInfo> result)

Fills X-axis labels with screen positions interpolated between source and target domains. Label texts remain at their final (target) values; only screen positions are animated. Labels whose animated screen positions fall outside the plot area are excluded so they don’t bleed outside the chart bounds during expansion/contraction animations.

Parameters

Name Type Description
sourceDomain UnityEngine.Vector2
progress System.Single
result System.Collections.Generic.List{ChartGuru.AxisLabelInfo}
public AxesRenderData GetAxesRenderData()

Generates axes render data for the current layout.

Returns

ChartGuru.AxesRenderData — No return description is available.

public BarsRenderData GetBarsRenderData()

Generates bars render data from the pre-computed bar geometries. Use this for static rendering without animation.

Returns

ChartGuru.BarsRenderData — No return description is available.

public SectorsRenderData GetSectorsRenderData()

Generates sectors render data from the pre-computed sector geometries. Use this for static rendering without animation.

Returns

ChartGuru.SectorsRenderData — No return description is available.

public PointsRenderData GetPointsRenderData()

Generates points render data from the pre-computed point geometries. Use this for static rendering without animation.

Returns

ChartGuru.PointsRenderData — No return description is available.

public float ComputeBaselineY()

Screen-space Y coordinate where value 0 sits inside the plot area. Used by every renderer that needs a zero Baseline (bars, area fills, axis lines) so the position is computed once, in one place.

Returns

System.Single — No return description is available.

public float ComputeBaselineY(Vector2 yDomain)

Overload that accepts an explicit Y domain — use this during animations so the baseline interpolates in lockstep with the grid lines.

Parameters

Name Type Description
yDomain UnityEngine.Vector2

Returns

System.Single — No return description is available.

public float ComputeBaselineX()

Screen-space X coordinate where value 0 sits inside the plot area. Horizontal-bar counterpart of ChartGuru.ChartLayoutEngine.ComputeBaselineY.

Returns

System.Single — No return description is available.

public float ComputeBaselineX(Vector2 xDomain)

Overload that accepts an explicit X domain — use this during animations so the baseline interpolates in lockstep with the grid lines.

Parameters

Name Type Description
xDomain UnityEngine.Vector2

Returns

System.Single — No return description is available.

public void SetTheme(ChartTheme theme)

Updates the theme used for layout calculations.

Parameters

Name Type Description
theme ChartGuru.ChartTheme
public void ComputeLayout(Rect screenRect, float containerHeight = -1)

Compute all layout data for the given screen rect. Call this before rendering to update all cached positions.

Parameters

Name Type Description
screenRect UnityEngine.Rect The screen rectangle to compute layout within.
containerHeight System.Single Optional container height for GUI coordinate conversion. If not specified, uses screenRect.height.
public void InvalidateColorCache()

Invalidates the series color cache. Call when marks change.

public float ProjectY(float cartesianY)

Projects a Y coordinate from Cartesian to GUI coordinate system. In GUI coords: Y=0 is at top, Y increases downward.

Parameters

Name Type Description
cartesianY System.Single

Returns

System.Single — No return description is available.

public Vector2 ProjectPosition(Vector2 cartesianPos)

Projects a position from Cartesian to the target coordinate system.

Parameters

Name Type Description
cartesianPos UnityEngine.Vector2

Returns

UnityEngine.Vector2 — No return description is available.

public Rect ProjectRect(Rect cartesianRect)

Projects a rect from Cartesian to the target coordinate system.

Parameters

Name Type Description
cartesianRect UnityEngine.Rect

Returns

UnityEngine.Rect — No return description is available.

GetLayoutInCoordinateSystem(CoordinateSystem)

Section titled “GetLayoutInCoordinateSystem(CoordinateSystem)”
public LayoutSnapshot GetLayoutInCoordinateSystem(CoordinateSystem coordSystem)

Gets all layout data in the specified coordinate system without changing the default target coordinate system.

Parameters

Name Type Description
coordSystem ChartGuru.CoordinateSystem

Returns

ChartGuru.LayoutSnapshot — No return description is available.

public LayoutSnapshot GetLayoutForGUI()

Gets layout data projected to GUI coordinates (Y=0 at top). Convenience method for Editor GUI rendering.

Returns

ChartGuru.LayoutSnapshot — No return description is available.

public LayoutSnapshot GetLayoutForCartesian()

Gets layout data in Cartesian coordinates (Y=0 at bottom). Convenience method for GL/runtime rendering.

Returns

ChartGuru.LayoutSnapshot — No return description is available.

public float DataToScreenX(float dataX)

Convert a data value to screen X coordinate.

Parameters

Name Type Description
dataX System.Single

Returns

System.Single — No return description is available.

public float DataToScreenY(float dataY)

Convert a data value to screen Y coordinate.

Parameters

Name Type Description
dataY System.Single

Returns

System.Single — No return description is available.

public Vector2 ScreenToData(Vector2 screenPos)

Convert a screen position to data coordinates.

Parameters

Name Type Description
screenPos UnityEngine.Vector2

Returns

UnityEngine.Vector2 — No return description is available.

public static float GetPointLabelOffset(IChartMark mark)

No description is available for this member.

Parameters

Name Type Description
mark ChartGuru.IChartMark

Returns

System.Single — No return description is available.

public bool HasNegativeYValues { get; }

True when the effective Y domain extends below zero.

Returns

System.Boolean — No return description is available.

public bool HasNegativeXValues { get; }

True when the effective X domain extends below zero.

Returns

System.Boolean — No return description is available.

public CoordinateSystem TargetCoordinateSystem { get; set; }

Gets or sets the target coordinate system for output positions. Default is Cartesian. Set to GUI for Unity Editor IMGUI rendering.

Returns

ChartGuru.CoordinateSystem — No return description is available.

public float MarkAlphaMultiplier { get; set; }

Global alpha multiplier applied to every mark color returned by ChartGuru.ChartLayoutEngine.GetMarkColor(ChartGuru.IChartMark%2cSystem.Int32%2cSystem.Int32%2cSystem.Int32). The renderer uses this to cross-fade the source and target chart type while a chart-type morph is in progress. Default is 1.

Returns

System.Single — No return description is available.

public Rect PlotArea { get; }

Gets the computed plot area in the target coordinate system.

Returns

UnityEngine.Rect — No return description is available.

public Rect PlotAreaCartesian { get; }

Gets the computed plot area in Cartesian coordinates (always). Use this when you need the raw Cartesian plot area regardless of target system.

Returns

UnityEngine.Rect — No return description is available.

public IReadOnlyList<AxisLabelInfo> XAxisLabels { get; }

Gets the cached X-axis labels in the target coordinate system.

Returns

System.Collections.Generic.IReadOnlyList{ChartGuru.AxisLabelInfo} — No return description is available.

public bool XAxisComputedAsBand { get; }

True when X-axis labels were placed at slot centers (band/categorical mode). Grid lines and ticks should use band boundaries in this case.

Returns

System.Boolean — No return description is available.

public IReadOnlyList<AxisLabelInfo> YAxisLabels { get; }

Gets the cached Y-axis labels in the target coordinate system.

Returns

System.Collections.Generic.IReadOnlyList{ChartGuru.AxisLabelInfo} — No return description is available.

public IReadOnlyList<DataLabelInfo> DataLabels { get; }

Gets the cached data labels in the target coordinate system.

Returns

System.Collections.Generic.IReadOnlyList{ChartGuru.DataLabelInfo} — No return description is available.

public IReadOnlyList<LegendLabelInfo> LegendLabels { get; }

Gets the cached legend labels in the target coordinate system.

Returns

System.Collections.Generic.IReadOnlyList{ChartGuru.LegendLabelInfo} — No return description is available.

public LegendPosition ResolvedLegendPosition { get; }

Legend position resolved after Automatic evaluation. When the configured position is Automatic, this returns Bottom if the chart has multiple series, or Hidden otherwise.

Returns

ChartGuru.LegendPosition — No return description is available.

public ColorScaleLegendInfo ColorScaleLegend { get; }

Gets the color scale legend info for heatmap charts.

Returns

ChartGuru.ColorScaleLegendInfo — No return description is available.

public AxisTitleInfo XAxisTitle { get; }

Gets the cached X-axis title info in the target coordinate system.

Returns

ChartGuru.AxisTitleInfo — No return description is available.

public AxisTitleInfo YAxisTitle { get; }

Gets the cached Y-axis title info in the target coordinate system.

Returns

ChartGuru.AxisTitleInfo — No return description is available.

public BarLayoutParams BarLayout { get; }

Gets the bar layout parameters.

Returns

ChartGuru.BarLayoutParams — No return description is available.

public MarkStackingMethod StackingMethod { get; }

Gets the detected stacking method for bars (set during geometry computation).

Returns

ChartGuru.MarkStackingMethod — No return description is available.

public LabelRotation ResolvedXLabelRotation { get; }

Gets the X-axis label rotation resolved by the layout engine for the most recently computed labels. Mirrors the auto-mode threshold logic in ChartGuru.ChartLabelBuilder.DetermineXAxisRotation(System.Collections.Generic.IReadOnlyList%7bChartGuru.TickLabel%7d%2cSystem.Single%2cSystem.Int32%2cSystem.Single) plus a diagonal-overhang fallback that downgrades Right45 to Right90 when the chart frame can’t accommodate the diagonal extent of the rightmost label. Consumers that need to render labels (runtime UGUI, editor IMGUI preview) should read this instead of recomputing, so the inset offsets baked into ChartGuru.ChartLayoutEngine.XAxisLabels match the actual rendered rotation. Returns ChartGuru.LabelRotation.Auto when no labels are present (callers should treat that as “fall back to your own auto logic”).

Returns

ChartGuru.LabelRotation — No return description is available.

public IReadOnlyList<BarGeometry> Bars { get; }

Gets the cached bar geometries in the target coordinate system.

Returns

System.Collections.Generic.IReadOnlyList{ChartGuru.BarGeometry} — No return description is available.

public PieLayoutParams PieLayout { get; }

Gets the pie layout parameters.

Returns

ChartGuru.PieLayoutParams — No return description is available.

public IReadOnlyList<SectorGeometry> Sectors { get; }

Gets the cached sector geometries in the target coordinate system.

Returns

System.Collections.Generic.IReadOnlyList{ChartGuru.SectorGeometry} — No return description is available.

public LineLayoutParams LineLayout { get; }

Gets the line layout parameters.

Returns

ChartGuru.LineLayoutParams — No return description is available.

public IReadOnlyList<PointGeometry> Points { get; }

Gets the cached point geometries in the target coordinate system.

Returns

System.Collections.Generic.IReadOnlyList{ChartGuru.PointGeometry} — No return description is available.

public IReadOnlyList<CandleGeometry> Candles { get; }

Gets the cached candlestick geometries in the target coordinate system.

Returns

System.Collections.Generic.IReadOnlyList{ChartGuru.CandleGeometry} — No return description is available.

public IReadOnlyList<StackedShadowExtent> StackedShadowExtents { get; }

Per-category stacked shadow/glow extents computed during bar geometry. Empty when bars are not stacked.

Returns

System.Collections.Generic.IReadOnlyList{ChartGuru.StackedShadowExtent} — No return description is available.

public NativeArray<float> AnimatedValues { set; }

Sets the animated values array for the current frame. When set, bar/point geometry will read interpolated values instead of raw mark data. Pass default (non-created) to clear.

Returns

Unity.Collections.NativeArray{System.Single} — No return description is available.

public bool AnimatedValuesAreEntryAnimation { set; }

True when ChartGuru.ChartLayoutEngine.AnimatedValues represent an entry replay from zero to final values.

Returns

System.Boolean — No return description is available.

public Vector2 XDomain { get; }

Gets the computed X Domain (min, max).

Returns

UnityEngine.Vector2 — No return description is available.

public Vector2 YDomain { get; }

Gets the computed Y Domain (min, max).

Returns

UnityEngine.Vector2 — No return description is available.

public Rect LastScreenRect { get; }

Gets the last screen rect used for layout computation.

Returns

UnityEngine.Rect — No return description is available.

public float ContainerHeight { get; }

Gets the container height used for GUI coordinate conversion.

Returns

System.Single — No return description is available.

public ChartLayoutEngine(Chart chart, ChartTheme theme = null)

No description is available for this member.

Parameters

Name Type Description
chart ChartGuru.Chart
theme ChartGuru.ChartTheme