Skip to content

ChartComponent

ClassChartGuruChartGuru
public class ChartComponent : MonoBehaviour, IChartHost

Hosts a Chart Guru chart on a GameObject for component-driven authoring and runtime updates. Use ChartGuru.ChartGraphic when the chart should render inside a uGUI Canvas.

protected ChartType chartType

Returns

ChartGuru.ChartType

protected ChartTheme theme

Returns

ChartGuru.ChartTheme

protected float tinyPadding

Returns

System.Single

protected float tinyLineWidth

Returns

System.Single

protected bool showMinMax

Returns

System.Boolean

protected bool showLastValue

Returns

System.Boolean

protected MarkStackingMethod stackingMethod

Returns

ChartGuru.MarkStackingMethod

protected float cornerRadius

Returns

System.Single

protected InterpolationMethod interpolation

Returns

ChartGuru.InterpolationMethod

protected float lineWidth

Returns

System.Single

protected bool showSymbols

Returns

System.Boolean

protected float symbolSize

Returns

System.Single

protected SymbolShape symbol

Returns

ChartGuru.SymbolShape

protected float opacity

Returns

System.Single

protected float innerRadius

Returns

System.Single

protected float angularInset

Returns

System.Single

protected AxisConfig xAxis

Returns

ChartGuru.AxisConfig

protected AxisConfig yAxis

Returns

ChartGuru.AxisConfig

protected AxisConfig zAxis

Returns

ChartGuru.AxisConfig

protected LegendPosition legendPosition

Returns

ChartGuru.LegendPosition

protected LegendAlignment legendAlignment

Returns

ChartGuru.LegendAlignment

protected string _chartTitleText

Returns

System.String

protected string _chartSubtitleText

Returns

System.String

protected ChartTitlePosition _chartTitlePosition

Returns

ChartGuru.ChartTitlePosition

protected bool showAxisLabels

Returns

System.Boolean

protected bool showAxisTitles

Returns

System.Boolean

protected bool showDataLabels

Returns

System.Boolean

protected string dataLabelFormat

Returns

System.String

protected PieLabelMode pieLabelMode

Returns

ChartGuru.PieLabelMode

protected AnimationField animation

Returns

ChartGuru.AnimationField

protected FrameTimingSettings timing

Returns

ImpossibleRobert.Common.Timing.FrameTimingSettings

protected Chart _chart

Runtime chart model — never serialized on the component so it cannot collide with Chart3DComponent’s persisted chart field (formerly named _chart in YAML).

Returns

ChartGuru.Chart

protected ChartProxy _proxy

Returns

ChartGuru.ChartProxy

protected bool _initialized

Returns

System.Boolean

protected static bool IsTinyChartType(ChartType type)

Reports whether the chart type is a compact sparkline or mini-chart variant intended for reduced inline presentation.

Parameters

Name Type
type ChartGuru.ChartType

Returns

System.Boolean

protected virtual void Initialize()

Creates renderer state, applies serialized configuration, and prepares the component for chart updates.

protected virtual Chart BuildRuntimeChart()

Creates the runtime ChartGuru.ChartComponent.Chart from serialized fields. Chart3DComponent overrides this to build 3D charts and restore serialized chart models without duplicating _chart.

Returns

ChartGuru.Chart

protected void ApplyAxisConfig(AxisBuilder builder, AxisConfig config)

Applies axis config to the target chart while preserving unrelated data and presentation settings.

Parameters

Name Type
builder ChartGuru.AxisBuilder
config ChartGuru.AxisConfig
protected void ApplyTextAndLabelConfig(Chart chart)

Applies text and label config to the target chart while preserving unrelated data and presentation settings.

Parameters

Name Type
chart ChartGuru.Chart
protected ChartAuthoringStyleOptions CreateSerializedAuthoringStyle()

Snapshots the component’s serialized mark-style fields into the options applied to newly built charts.

Returns

ChartGuru.ChartAuthoringStyleOptions

protected virtual void ApplyMarkStyleConfig(Chart chart)

Applies mark style config to the target chart while preserving unrelated data and presentation settings.

Parameters

Name Type
chart ChartGuru.Chart
protected virtual void RefreshMarkStyle()

Reapplies serialized mark styling without replacing the component’s bound data.

protected virtual void Cleanup()

Releases renderer state and detaches runtime callbacks owned by the chart component.

protected virtual void RebuildChart()

Rebuilds chart marks and layout from the component’s current serialized data and configuration.

public virtual void SetDirty()

ChartGuru.IChartHost.SetDirty — requests a full rebuild on the next frame.

protected void SyncAxesFromSerializedFields()

Editor-only: pushes serialized X/Y/Z axis configs into the live chart so inspector tweaks apply without a full rebuild.

SyncChartPresentationFromSerializedFields()

Section titled “SyncChartPresentationFromSerializedFields()”
protected void SyncChartPresentationFromSerializedFields()

Pushes the serialized theme, text, label, and mark-style settings into the live chart without replacing its data or rebuilding its mark collection.

SetData(IEnumerable, Func<T, float>, Func<T, float>)

Section titled “SetData(IEnumerable, Func<T, float>, Func<T, float>)”
public void SetData<T>(IEnumerable<T> data, Func<T, float> xSelector, Func<T, float> ySelector)

Replaces the Chart Component’s source data and refreshes its marks while preserving compatible chart configuration.

Parameters

Name Type
data System.Collections.Generic.IEnumerable{{T}}
xSelector System.Func{{T},System.Single}
ySelector System.Func{{T},System.Single}
public void SetData(float[] values)

Replaces the Chart Component’s source data and refreshes its marks while preserving compatible chart configuration.

Parameters

Name Type
values System.Single[]
public void SetData(float[] xValues, float[] yValues)

Replaces the Chart Component’s source data and refreshes its marks while preserving compatible chart configuration.

Parameters

Name Type
xValues System.Single[]
yValues System.Single[]
public void AddDataPoint(float x, float y)

Appends one data point to the series and notifies attached charts that their rendered data changed.

Parameters

Name Type
x System.Single
y System.Single
public void ClearData()

Removes all source values from the Chart Component and notifies attached charts to refresh.

public bool SelectAtPosition(Vector2 localPosition)

Updates chart selection from a chart-local pointer position using rendered mark geometry.

Parameters

Name Type
localPosition UnityEngine.Vector2

Returns

System.Boolean

public bool SelectAtX(float localX)

Updates horizontal selection from the supplied data or chart coordinate.

Parameters

Name Type
localX System.Single

Returns

System.Boolean

public bool SelectAngleAtPosition(Vector2 localPosition)

Updates angular selection by hit-testing a chart-local point against rendered sectors.

Parameters

Name Type
localPosition UnityEngine.Vector2

Returns

System.Boolean

public ClosedRange<float>? SelectXRange(float startLocalX, float endLocalX)

Sets the selected horizontal data range and notifies registered selection listeners.

Parameters

Name Type
startLocalX System.Single
endLocalX System.Single

Returns

System.Nullable{ChartGuru.ClosedRange{System.Single}}

public ClosedRange<float>? SelectYRange(float startLocalY, float endLocalY)

Sets the selected vertical data range and notifies registered selection listeners.

Parameters

Name Type
startLocalY System.Single
endLocalY System.Single

Returns

System.Nullable{ChartGuru.ClosedRange{System.Single}}

public void ScrollXBy(float delta)

Offsets the visible horizontal domain by the supplied data-space distance.

Parameters

Name Type
delta System.Single
public void ScrollYBy(float delta)

Offsets the visible vertical domain by the supplied data-space distance.

Parameters

Name Type
delta System.Single
public void ScrollToX(float value)

Moves the visible horizontal domain so the requested data value aligns according to the scroll-target behavior.

Parameters

Name Type
value System.Single
public void ScrollToY(float value)

Moves the visible vertical domain so the requested data value aligns according to the scroll-target behavior.

Parameters

Name Type
value System.Single
public void ZoomX(float zoomFactor, float anchorLocalX)

Scales the visible horizontal domain around the supplied data-space anchor.

Parameters

Name Type
zoomFactor System.Single
anchorLocalX System.Single
public void ZoomY(float zoomFactor, float anchorLocalY)

Scales the visible vertical domain around the supplied data-space anchor.

Parameters

Name Type
zoomFactor System.Single
anchorLocalY System.Single
public void Zoom(float zoomFactorX, float zoomFactorY, Vector2 anchorLocalPosition)

Scales both visible axis domains around the supplied anchor point while respecting configured limits.

Parameters

Name Type
zoomFactorX System.Single
zoomFactorY System.Single
anchorLocalPosition UnityEngine.Vector2
public void PanViewportByPixels(Vector2 pixelDelta)

Converts a screen-space drag delta into data-space offsets and pans the visible chart domains.

Parameters

Name Type
pixelDelta UnityEngine.Vector2
public void ResetViewport()

Restores both axes to their configured visible domains and clears transient pan and zoom offsets.

public void ClearSelectionRanges()

Clears active range selections and notifies registered selection listeners.

public void PlayEntryAnimation()

Replays the entry Animation (zero -> current values) using the component’s configured animation. No-op if the animation is disabled.

public void MorphTo(ChartType targetType, Animation? morphAnimation = null)

Morphs the chart to a new type. Driven end-to-end by the morpher: the request is handed to ChartGuru.Chart.MorphTo(ChartGuru.ChartType%2cChartGuru.MorphOptions), and the renderer kicks off the visual transition on its next tick.

Parameters

Name Type
targetType ChartGuru.ChartType
morphAnimation System.Nullable{ChartGuru.Animation}
public ChartComponent ConfigureXAxis(Action<AxisBuilder> configure)

Applies a callback to the horizontal axis configuration and refreshes the chart.

Parameters

Name Type
configure System.Action{ChartGuru.AxisBuilder}

Returns

ChartGuru.ChartComponent

public ChartComponent ConfigureYAxis(Action<AxisBuilder> configure)

Applies a callback to the vertical axis configuration and refreshes the chart.

Parameters

Name Type
configure System.Action{ChartGuru.AxisBuilder}

Returns

ChartGuru.ChartComponent

public ChartComponent ConfigureZAxis(Action<AxisBuilder> configure)

Applies a callback to the depth axis configuration used by supported 3D chart hosts.

Parameters

Name Type
configure System.Action{ChartGuru.AxisBuilder}

Returns

ChartGuru.ChartComponent

public ChartComponent ConfigureLegend(LegendPosition position)

Applies a callback or replacement snapshot to the legend configuration and refreshes the chart.

Parameters

Name Type
position ChartGuru.LegendPosition

Returns

ChartGuru.ChartComponent

ConfigureLegend(LegendPosition, LegendAlignment)

Section titled “ConfigureLegend(LegendPosition, LegendAlignment)”
public ChartComponent ConfigureLegend(LegendPosition position, LegendAlignment alignment)

Applies a callback or replacement snapshot to the legend configuration and refreshes the chart.

Parameters

Name Type
position ChartGuru.LegendPosition
alignment ChartGuru.LegendAlignment

Returns

ChartGuru.ChartComponent

public ChartComponent ConfigureAnimation(Animation? newAnimation)

Configures the animation used for data changes and entry animation. Pass null for instant (non-animated) updates.

Parameters

Name Type
newAnimation System.Nullable{ChartGuru.Animation}

Returns

ChartGuru.ChartComponent

public ChartComponent ConfigureCompactChart(float padding = 2, float lineWidth = 1.5)

Configure compact chart settings. Use ChartType property to set the compact type (Sparkline, Trend, MiniBar, MiniPie, MiniDonut, Indicator).

Parameters

Name Type
padding System.Single
lineWidth System.Single

Returns

ChartGuru.ChartComponent

public RenderTexture RenderToTexture(int width, int height)

Renders the current chart into the supplied render target using the configured dimensions and theme.

Parameters

Name Type
width System.Int32
height System.Int32

Returns

UnityEngine.RenderTexture

public Texture2D RenderToTexture2D(int width, int height)

Renders the current chart and returns a new readable texture containing the resulting pixels.

Parameters

Name Type
width System.Int32
height System.Int32

Returns

UnityEngine.Texture2D

public ChartComponent()

public Chart Chart { get; }

The bound ChartGuru.IChartHost.Chart model, if any.

Returns

ChartGuru.Chart

public ChartProxy Proxy { get; }

Returns

ChartGuru.ChartProxy

public bool IsTinyChart { get; }

Returns

System.Boolean

public MarkStackingMethod StackingMethod { get; set; }

Returns

ChartGuru.MarkStackingMethod

public float CornerRadius { get; set; }

Returns

System.Single

public InterpolationMethod Interpolation { get; set; }

Returns

ChartGuru.InterpolationMethod

public float LineWidth { get; set; }

Returns

System.Single

public bool ShowSymbols { get; set; }

Returns

System.Boolean

public float SymbolSize { get; set; }

Returns

System.Single

public SymbolShape Symbol { get; set; }

Returns

ChartGuru.SymbolShape

public float Opacity { get; set; }

Returns

System.Single

public float InnerRadius { get; set; }

Returns

System.Single

public float AngularInset { get; set; }

Returns

System.Single

public ChartType ChartType { get; set; }

Returns

ChartGuru.ChartType

public ChartTheme Theme { get; set; }

Returns

ChartGuru.ChartTheme

public Vector2 Size { get; set; }

Returns

UnityEngine.Vector2

public bool UseBackgroundOverride { get; set; }

Enables or disables the background override (overrides theme).

Returns

System.Boolean

public ChartBackgroundMode BackgroundOverrideMode { get; set; }

Background rendering mode used when ChartGuru.ChartComponent.UseBackgroundOverride is true.

Returns

ChartGuru.ChartBackgroundMode

public Color BackgroundOverrideColor { get; set; }

Solid colour used when ChartGuru.ChartComponent.BackgroundOverrideMode is SolidColor.

Returns

UnityEngine.Color

public LinearGradientStyle BackgroundOverrideGradient { get; set; }

Linear gradient used when ChartGuru.ChartComponent.BackgroundOverrideMode is LinearGradient.

Returns

ChartGuru.LinearGradientStyle

public FourCornerGradient BackgroundOverrideFourCorner { get; set; }

Four-corner gradient used when ChartGuru.ChartComponent.BackgroundOverrideMode is FourCornerGradient.

Returns

ChartGuru.FourCornerGradient

public event Action<int, DataPoint> OnDataPointClicked

Raised with the mark index and data point after a rendered point is clicked.

Returns

System.Action{System.Int32,ChartGuru.DataPoint}

public event Action<int, DataPoint> OnDataPointHovered

Raised with the mark index and data point when the hover target changes.

Returns

System.Action{System.Int32,ChartGuru.DataPoint}

public event Action OnAnimationComplete

Raised after the chart’s current data or presentation animation completes.

Returns

System.Action