ChartComponent
public class ChartComponent : MonoBehaviour, IChartHostHosts 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.
Fields
Section titled “Fields”
chartType
Section titled “chartType”protected ChartType chartTypeReturns
ChartGuru.ChartType
protected ChartTheme themeReturns
ChartGuru.ChartTheme
tinyPadding
Section titled “tinyPadding”protected float tinyPaddingReturns
System.Single
tinyLineWidth
Section titled “tinyLineWidth”protected float tinyLineWidthReturns
System.Single
showMinMax
Section titled “showMinMax”protected bool showMinMaxReturns
System.Boolean
showLastValue
Section titled “showLastValue”protected bool showLastValueReturns
System.Boolean
stackingMethod
Section titled “stackingMethod”protected MarkStackingMethod stackingMethodReturns
ChartGuru.MarkStackingMethod
cornerRadius
Section titled “cornerRadius”protected float cornerRadiusReturns
System.Single
interpolation
Section titled “interpolation”protected InterpolationMethod interpolationReturns
ChartGuru.InterpolationMethod
lineWidth
Section titled “lineWidth”protected float lineWidthReturns
System.Single
showSymbols
Section titled “showSymbols”protected bool showSymbolsReturns
System.Boolean
symbolSize
Section titled “symbolSize”protected float symbolSizeReturns
System.Single
symbol
Section titled “symbol”protected SymbolShape symbolReturns
ChartGuru.SymbolShape
opacity
Section titled “opacity”protected float opacityReturns
System.Single
innerRadius
Section titled “innerRadius”protected float innerRadiusReturns
System.Single
angularInset
Section titled “angularInset”protected float angularInsetReturns
System.Single
protected AxisConfig xAxisReturns
ChartGuru.AxisConfig
protected AxisConfig yAxisReturns
ChartGuru.AxisConfig
protected AxisConfig zAxisReturns
ChartGuru.AxisConfig
legendPosition
Section titled “legendPosition”protected LegendPosition legendPositionReturns
ChartGuru.LegendPosition
legendAlignment
Section titled “legendAlignment”protected LegendAlignment legendAlignmentReturns
ChartGuru.LegendAlignment
_chartTitleText
Section titled “_chartTitleText”protected string _chartTitleTextReturns
System.String
_chartSubtitleText
Section titled “_chartSubtitleText”protected string _chartSubtitleTextReturns
System.String
_chartTitlePosition
Section titled “_chartTitlePosition”protected ChartTitlePosition _chartTitlePositionReturns
ChartGuru.ChartTitlePosition
showAxisLabels
Section titled “showAxisLabels”protected bool showAxisLabelsReturns
System.Boolean
showAxisTitles
Section titled “showAxisTitles”protected bool showAxisTitlesReturns
System.Boolean
showDataLabels
Section titled “showDataLabels”protected bool showDataLabelsReturns
System.Boolean
dataLabelFormat
Section titled “dataLabelFormat”protected string dataLabelFormatReturns
System.String
pieLabelMode
Section titled “pieLabelMode”protected PieLabelMode pieLabelModeReturns
ChartGuru.PieLabelMode
animation
Section titled “animation”protected AnimationField animationReturns
ChartGuru.AnimationField
timing
Section titled “timing”protected FrameTimingSettings timingReturns
ImpossibleRobert.Common.Timing.FrameTimingSettings
_chart
Section titled “_chart”protected Chart _chartRuntime 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
_proxy
Section titled “_proxy”protected ChartProxy _proxyReturns
ChartGuru.ChartProxy
_initialized
Section titled “_initialized”protected bool _initializedReturns
System.Boolean
Methods
Section titled “Methods”
IsTinyChartType(ChartType)
Section titled “IsTinyChartType(ChartType)”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
Initialize()
Section titled “Initialize()”protected virtual void Initialize()Creates renderer state, applies serialized configuration, and prepares the component for chart updates.
BuildRuntimeChart()
Section titled “BuildRuntimeChart()”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
ApplyAxisConfig(AxisBuilder, AxisConfig)
Section titled “ApplyAxisConfig(AxisBuilder, AxisConfig)”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 |
ApplyTextAndLabelConfig(Chart)
Section titled “ApplyTextAndLabelConfig(Chart)”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 |
CreateSerializedAuthoringStyle()
Section titled “CreateSerializedAuthoringStyle()”protected ChartAuthoringStyleOptions CreateSerializedAuthoringStyle()Snapshots the component’s serialized mark-style fields into the options applied to newly built charts.
Returns
ChartGuru.ChartAuthoringStyleOptions
ApplyMarkStyleConfig(Chart)
Section titled “ApplyMarkStyleConfig(Chart)”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 |
RefreshMarkStyle()
Section titled “RefreshMarkStyle()”protected virtual void RefreshMarkStyle()Reapplies serialized mark styling without replacing the component’s bound data.
Cleanup()
Section titled “Cleanup()”protected virtual void Cleanup()Releases renderer state and detaches runtime callbacks owned by the chart component.
RebuildChart()
Section titled “RebuildChart()”protected virtual void RebuildChart()Rebuilds chart marks and layout from the component’s current serialized data and configuration.
SetDirty()
Section titled “SetDirty()”public virtual void SetDirty()ChartGuru.IChartHost.SetDirty — requests a full rebuild on the next frame.
SyncAxesFromSerializedFields()
Section titled “SyncAxesFromSerializedFields()”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} |
SetData(float[])
Section titled “SetData(float[])”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[] |
SetData(float[], float[])
Section titled “SetData(float[], float[])”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[] |
AddDataPoint(float, float)
Section titled “AddDataPoint(float, float)”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 |
ClearData()
Section titled “ClearData()”public void ClearData()Removes all source values from the Chart Component and notifies attached charts to refresh.
SelectAtPosition(Vector2)
Section titled “SelectAtPosition(Vector2)”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
SelectAtX(float)
Section titled “SelectAtX(float)”public bool SelectAtX(float localX)Updates horizontal selection from the supplied data or chart coordinate.
Parameters
| Name | Type |
|---|---|
localX |
System.Single |
Returns
System.Boolean
SelectAngleAtPosition(Vector2)
Section titled “SelectAngleAtPosition(Vector2)”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
SelectXRange(float, float)
Section titled “SelectXRange(float, float)”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}}
SelectYRange(float, float)
Section titled “SelectYRange(float, float)”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}}
ScrollXBy(float)
Section titled “ScrollXBy(float)”public void ScrollXBy(float delta)Offsets the visible horizontal domain by the supplied data-space distance.
Parameters
| Name | Type |
|---|---|
delta |
System.Single |
ScrollYBy(float)
Section titled “ScrollYBy(float)”public void ScrollYBy(float delta)Offsets the visible vertical domain by the supplied data-space distance.
Parameters
| Name | Type |
|---|---|
delta |
System.Single |
ScrollToX(float)
Section titled “ScrollToX(float)”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 |
ScrollToY(float)
Section titled “ScrollToY(float)”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 |
ZoomX(float, float)
Section titled “ZoomX(float, float)”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 |
ZoomY(float, float)
Section titled “ZoomY(float, float)”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 |
Zoom(float, float, Vector2)
Section titled “Zoom(float, float, Vector2)”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 |
PanViewportByPixels(Vector2)
Section titled “PanViewportByPixels(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 |
ResetViewport()
Section titled “ResetViewport()”public void ResetViewport()Restores both axes to their configured visible domains and clears transient pan and zoom offsets.
ClearSelectionRanges()
Section titled “ClearSelectionRanges()”public void ClearSelectionRanges()Clears active range selections and notifies registered selection listeners.
PlayEntryAnimation()
Section titled “PlayEntryAnimation()”public void PlayEntryAnimation()Replays the entry Animation (zero -> current values) using the component’s configured animation. No-op if the animation is disabled.
MorphTo(ChartType, Animation?)
Section titled “MorphTo(ChartType, Animation?)”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} |
ConfigureXAxis(Action)
Section titled “ConfigureXAxis(Action)”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
ConfigureYAxis(Action)
Section titled “ConfigureYAxis(Action)”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
ConfigureZAxis(Action)
Section titled “ConfigureZAxis(Action)”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
ConfigureLegend(LegendPosition)
Section titled “ConfigureLegend(LegendPosition)”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
ConfigureAnimation(Animation?)
Section titled “ConfigureAnimation(Animation?)”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
ConfigureCompactChart(float, float)
Section titled “ConfigureCompactChart(float, float)”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
RenderToTexture(int, int)
Section titled “RenderToTexture(int, int)”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
RenderToTexture2D(int, int)
Section titled “RenderToTexture2D(int, int)”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
Constructors
Section titled “Constructors”
ChartComponent()
Section titled “ChartComponent()”public ChartComponent()Properties
Section titled “Properties”
public Chart Chart { get; }The bound ChartGuru.IChartHost.Chart model, if any.
Returns
ChartGuru.Chart
public ChartProxy Proxy { get; }Returns
ChartGuru.ChartProxy
IsTinyChart
Section titled “IsTinyChart”public bool IsTinyChart { get; }Returns
System.Boolean
StackingMethod
Section titled “StackingMethod”public MarkStackingMethod StackingMethod { get; set; }Returns
ChartGuru.MarkStackingMethod
CornerRadius
Section titled “CornerRadius”public float CornerRadius { get; set; }Returns
System.Single
Interpolation
Section titled “Interpolation”public InterpolationMethod Interpolation { get; set; }Returns
ChartGuru.InterpolationMethod
LineWidth
Section titled “LineWidth”public float LineWidth { get; set; }Returns
System.Single
ShowSymbols
Section titled “ShowSymbols”public bool ShowSymbols { get; set; }Returns
System.Boolean
SymbolSize
Section titled “SymbolSize”public float SymbolSize { get; set; }Returns
System.Single
Symbol
Section titled “Symbol”public SymbolShape Symbol { get; set; }Returns
ChartGuru.SymbolShape
Opacity
Section titled “Opacity”public float Opacity { get; set; }Returns
System.Single
InnerRadius
Section titled “InnerRadius”public float InnerRadius { get; set; }Returns
System.Single
AngularInset
Section titled “AngularInset”public float AngularInset { get; set; }Returns
System.Single
ChartType
Section titled “ChartType”public ChartType ChartType { get; set; }Returns
ChartGuru.ChartType
public ChartTheme Theme { get; set; }Returns
ChartGuru.ChartTheme
public Vector2 Size { get; set; }Returns
UnityEngine.Vector2
UseBackgroundOverride
Section titled “UseBackgroundOverride”public bool UseBackgroundOverride { get; set; }Enables or disables the background override (overrides theme).
Returns
System.Boolean
BackgroundOverrideMode
Section titled “BackgroundOverrideMode”public ChartBackgroundMode BackgroundOverrideMode { get; set; }Background rendering mode used when ChartGuru.ChartComponent.UseBackgroundOverride is true.
Returns
ChartGuru.ChartBackgroundMode
BackgroundOverrideColor
Section titled “BackgroundOverrideColor”public Color BackgroundOverrideColor { get; set; }Solid colour used when ChartGuru.ChartComponent.BackgroundOverrideMode is SolidColor.
Returns
UnityEngine.Color
BackgroundOverrideGradient
Section titled “BackgroundOverrideGradient”public LinearGradientStyle BackgroundOverrideGradient { get; set; }Linear gradient used when ChartGuru.ChartComponent.BackgroundOverrideMode is LinearGradient.
Returns
ChartGuru.LinearGradientStyle
BackgroundOverrideFourCorner
Section titled “BackgroundOverrideFourCorner”public FourCornerGradient BackgroundOverrideFourCorner { get; set; }Four-corner gradient used when ChartGuru.ChartComponent.BackgroundOverrideMode is FourCornerGradient.
Returns
ChartGuru.FourCornerGradient
Events
Section titled “Events”
OnDataPointClicked
Section titled “OnDataPointClicked”public event Action<int, DataPoint> OnDataPointClickedRaised with the mark index and data point after a rendered point is clicked.
Returns
System.Action{System.Int32,ChartGuru.DataPoint}
OnDataPointHovered
Section titled “OnDataPointHovered”public event Action<int, DataPoint> OnDataPointHoveredRaised with the mark index and data point when the hover target changes.
Returns
System.Action{System.Int32,ChartGuru.DataPoint}
OnAnimationComplete
Section titled “OnAnimationComplete”public event Action OnAnimationCompleteRaised after the chart’s current data or presentation animation completes.
Returns
System.Action