ChartGraphic
[AddComponentMenu("ChartGuru/Chart Graphic")][ExecuteAlways][RequireComponent(typeof(RectTransform))][RequireComponent(typeof(CanvasRenderer))]public class ChartGraphic : MaskableGraphic, IChartHostRenders a Chart Guru chart inside a Unity UI Canvas and exposes runtime data, configuration, animation, and pointer-interaction entry points.
Methods
Section titled “Methods”
OnPointerClick(PointerEventData)
Section titled “OnPointerClick(PointerEventData)”public void OnPointerClick(PointerEventData eventData)Hit-tests a pointer click against rendered marks and raises the chart’s click or selection callbacks.
Parameters
| Name | Type |
|---|---|
eventData |
UnityEngine.EventSystems.PointerEventData |
OnPointerMove(PointerEventData)
Section titled “OnPointerMove(PointerEventData)”public void OnPointerMove(PointerEventData eventData)Updates hover hit-testing from the current pointer position and raises hover callbacks when the target changes.
Parameters
| Name | Type |
|---|---|
eventData |
UnityEngine.EventSystems.PointerEventData |
OnPointerExit(PointerEventData)
Section titled “OnPointerExit(PointerEventData)”public void OnPointerExit(PointerEventData eventData)Clears the current hover target when the pointer leaves the chart.
Parameters
| Name | Type |
|---|---|
eventData |
UnityEngine.EventSystems.PointerEventData |
OnBeginDrag(PointerEventData)
Section titled “OnBeginDrag(PointerEventData)”public void OnBeginDrag(PointerEventData eventData)Begins chart panning when the active interaction configuration permits dragging.
Parameters
| Name | Type |
|---|---|
eventData |
UnityEngine.EventSystems.PointerEventData |
OnDrag(PointerEventData)
Section titled “OnDrag(PointerEventData)”public void OnDrag(PointerEventData eventData)Pans the visible chart domain by the pointer’s drag delta.
Parameters
| Name | Type |
|---|---|
eventData |
UnityEngine.EventSystems.PointerEventData |
OnEndDrag(PointerEventData)
Section titled “OnEndDrag(PointerEventData)”public void OnEndDrag(PointerEventData eventData)Finishes chart panning and applies any configured scroll-target alignment.
Parameters
| Name | Type |
|---|---|
eventData |
UnityEngine.EventSystems.PointerEventData |
OnScroll(PointerEventData)
Section titled “OnScroll(PointerEventData)”public void OnScroll(PointerEventData eventData)Zooms or scrolls the visible chart domain from a pointer-wheel event according to the interaction settings.
Parameters
| Name | Type |
|---|---|
eventData |
UnityEngine.EventSystems.PointerEventData |
ReplayEntryAnimation()
Section titled “ReplayEntryAnimation()”public void ReplayEntryAnimation()Replays the entry Animation (zero → current values) using the component’s configured animation. No-op if animation is disabled or the chart isn’t ready.
RequestRefresh()
Section titled “RequestRefresh()”public void RequestRefresh()Marks the chart as needing layout and rendering on the next valid update.
ForceRenderChart()
Section titled “ForceRenderChart()”public void ForceRenderChart()Immediately rebuilds and renders the chart instead of waiting for the normal refresh cycle.
NotifyExternalDataChanged()
Section titled “NotifyExternalDataChanged()”public void NotifyExternalDataChanged()Marks data, style, layout, and legend state dirty after caller-owned data changes, then schedules a redraw.
SetDirty()
Section titled “SetDirty()”public void SetDirty()ChartGuru.IChartHost.SetDirty implementation: requests a vertex/render
rebuild on the next frame.
GetOutputTexture(bool)
Section titled “GetOutputTexture(bool)”public Texture GetOutputTexture(bool includeText)Returns the current chart texture. When includeText is false,
this is the fast chart-geometry texture. When true, this returns the last
refreshed composed texture that includes Chart Guru’s TMP labels, titles, and legend.
Parameters
| Name | Type |
|---|---|
includeText |
System.Boolean |
Returns
UnityEngine.Texture
RefreshOutputTexture(bool)
Section titled “RefreshOutputTexture(bool)”public Texture RefreshOutputTexture(bool includeText)Refreshes and returns the selected chart texture.
Parameters
| Name | Type |
|---|---|
includeText |
System.Boolean |
Returns
UnityEngine.Texture
NeedsOutputTextureRefresh(bool)
Section titled “NeedsOutputTextureRefresh(bool)”public bool NeedsOutputTextureRefresh(bool includeText)Returns true when the selected texture path needs a refresh before use.
Parameters
| Name | Type |
|---|---|
includeText |
System.Boolean |
Returns
System.Boolean
ReleaseComposedOutputTexture()
Section titled “ReleaseComposedOutputTexture()”public void ReleaseComposedOutputTexture()Releases the cached composed texture and its hidden capture objects.
OnRectTransformDimensionsChange()
Section titled “OnRectTransformDimensionsChange()”protected override void OnRectTransformDimensionsChange()Ensures renderer exists, recreating if needed after OnDisable.
OnCanvasHierarchyChanged()
Section titled “OnCanvasHierarchyChanged()”protected override void OnCanvasHierarchyChanged()Forces an immediate render of the chart to the render texture. Called when the texture is recreated to avoid blank frames. In editor mode, this completes any animation immediately. In play mode with animation enabled, this allows animation to continue.
OnPopulateMesh(VertexHelper)
Section titled “OnPopulateMesh(VertexHelper)”protected override void OnPopulateMesh(VertexHelper vh)Builds the list of radar-ring tick-value labels and spoke-tip category labels
based on the chart’s axis configuration, then pushes them to the text manager.
Layout is shared with the editor previews via ChartGuru.RadarLabelLayout.
Parameters
| Name | Type |
|---|---|
vh |
UnityEngine.UI.VertexHelper |
SetChartData(Chart)
Section titled “SetChartData(Chart)”public void SetChartData(Chart chart)Adopts a prebuilt chart as the programmatic source, synchronizes host size and authored settings, and recreates rendering, interaction, and text services. A null chart is ignored.
Parameters
| Name | Type |
|---|---|
chart |
ChartGuru.Chart |
RefreshFromSerializedState()
Section titled “RefreshFromSerializedState()”public void RefreshFromSerializedState()Rebuilds the chart from the serialized Inspector state and exits programmatic-chart mode. Intended for editor tooling that imports chart configuration into serialized fields.
ApplyAuthoredConfiguration(Chart)
Section titled “ApplyAuthoredConfiguration(Chart)”public void ApplyAuthoredConfiguration(Chart chart)Copies every authored configuration value from the supplied ChartGuru.ChartGraphic.Chart into this
component’s serialized fields, so the Inspector reflects the chart state.
Unlike ChartGuru.ChartGraphic.SetChartData(ChartGuru.Chart), this does NOT switch the component into programmatic
mode: the next ChartGuru.ChartGraphic.RebuildChart will recompose a chart from the synced fields,
which keeps the new object fully editable (e.g. when instantiated from the Chart Designer).
Parameters
| Name | Type | Description |
|---|---|---|
chart |
ChartGuru.Chart | Source chart to copy configuration from. No-op when null. |
SetData(float[])
Section titled “SetData(float[])”public void SetData(float[] values)Set chart data using an array of values.
Parameters
| Name | Type |
|---|---|
values |
System.Single[] |
SetData(Vector2[])
Section titled “SetData(Vector2[])”public void SetData(Vector2[] points)Set chart data with X and Y values.
Parameters
| Name | Type |
|---|---|
points |
UnityEngine.Vector2[] |
AddDataPoint(float, float)
Section titled “AddDataPoint(float, float)”public void AddDataPoint(float x, float y)Add a data point to the chart.
Parameters
| Name | Type |
|---|---|
x |
System.Single |
y |
System.Single |
ClearData()
Section titled “ClearData()”public void ClearData()Clear all data from the chart.
ClearSelection()
Section titled “ClearSelection()”public void ClearSelection()Clear the current selection.
Constructors
Section titled “Constructors”
ChartGraphic()
Section titled “ChartGraphic()”public ChartGraphic()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
StackingMethod
Section titled “StackingMethod”public MarkStackingMethod StackingMethod { get; set; }Returns
ChartGuru.MarkStackingMethod
CornerRadius
Section titled “CornerRadius”public float CornerRadius { get; set; }Returns
System.Single
ForegroundStyleMode
Section titled “ForegroundStyleMode”public ForegroundStyleMode ForegroundStyleMode { get; set; }Returns
ChartGuru.ForegroundStyleMode
UseForegroundGradient
Section titled “UseForegroundGradient”public bool UseForegroundGradient { get; set; }Returns
System.Boolean
ForegroundGradient
Section titled “ForegroundGradient”public Gradient ForegroundGradient { get; set; }Returns
UnityEngine.Gradient
ForegroundGradientStartPoint
Section titled “ForegroundGradientStartPoint”public UnitPoint ForegroundGradientStartPoint { get; set; }Returns
ChartGuru.UnitPoint
ForegroundGradientEndPoint
Section titled “ForegroundGradientEndPoint”public UnitPoint ForegroundGradientEndPoint { get; set; }Returns
ChartGuru.UnitPoint
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
ShowAreaLine
Section titled “ShowAreaLine”public bool ShowAreaLine { get; set; }Returns
System.Boolean
InnerRadius
Section titled “InnerRadius”public float InnerRadius { get; set; }Returns
System.Single
AngularInset
Section titled “AngularInset”public float AngularInset { get; set; }Angular inset between pie/donut slices in degrees.
Returns
System.Single
YAxisOnRight
Section titled “YAxisOnRight”public bool YAxisOnRight { get; set; }Gets or sets whether the Y-axis is on the right side (default is left).
Returns
System.Boolean
YAxisTickFormat
Section titled “YAxisTickFormat”public string YAxisTickFormat { get; set; }Gets or sets the Y-axis tick format string (e.g., “F0” for integers, “F1” for one decimal).
Returns
System.String
ShowAxisLabels
Section titled “ShowAxisLabels”public bool ShowAxisLabels { get; set; }Returns
System.Boolean
ShowAxisTitles
Section titled “ShowAxisTitles”public bool ShowAxisTitles { get; set; }Returns
System.Boolean
ShowDataLabels
Section titled “ShowDataLabels”public bool ShowDataLabels { get; set; }Returns
System.Boolean
AutoContrastText
Section titled “AutoContrastText”public bool AutoContrastText { get; set; }When enabled, axis labels, axis titles, data labels, and legend text automatically adjust to white or black for maximum contrast against their background.
Returns
System.Boolean
OverrideDataLabelColor
Section titled “OverrideDataLabelColor”public bool OverrideDataLabelColor { get; set; }When true, ChartGuru.ChartGraphic.DataLabelColor overrides the theme text colour
for data labels (mirrors the Chart Designer’s “Label Color Override”).
Returns
System.Boolean
DataLabelColor
Section titled “DataLabelColor”public Color DataLabelColor { get; set; }Explicit data-label colour applied when ChartGuru.ChartGraphic.OverrideDataLabelColor
is true. Equivalent to chart.DataLabelColor for code-driven flows.
Returns
UnityEngine.Color
OverrideAxisLabelColor
Section titled “OverrideAxisLabelColor”public bool OverrideAxisLabelColor { get; set; }When true, ChartGuru.ChartGraphic.AxisLabelColor overrides the theme text colour
for axis tick labels (and radar ring/spoke labels).
Returns
System.Boolean
AxisLabelColor
Section titled “AxisLabelColor”public Color AxisLabelColor { get; set; }Explicit axis-label colour applied when ChartGuru.ChartGraphic.OverrideAxisLabelColor
is true. Equivalent to chart.AxisLabelColor for code-driven flows.
Returns
UnityEngine.Color
DataLabelFormat
Section titled “DataLabelFormat”public string DataLabelFormat { get; set; }Returns
System.String
PieLabelMode
Section titled “PieLabelMode”public PieLabelMode PieLabelMode { get; set; }Returns
ChartGuru.PieLabelMode
XAxisLabelRotation
Section titled “XAxisLabelRotation”public LabelRotation XAxisLabelRotation { get; set; }Returns
ChartGuru.LabelRotation
SelectionIndicatorStyle
Section titled “SelectionIndicatorStyle”public SelectionIndicatorStyle SelectionIndicatorStyle { get; set; }Style for selection/hover indicators. Swift Charts equivalent: selection indicator styling
Returns
ChartGuru.SelectionIndicatorStyle
PlotAreaBorderColor
Section titled “PlotAreaBorderColor”public Color PlotAreaBorderColor { get; set; }Color of the plot area border.
Returns
UnityEngine.Color
PlotAreaBorderWidth
Section titled “PlotAreaBorderWidth”public float PlotAreaBorderWidth { get; set; }Width of the plot area border.
Returns
System.Single
PlotAreaCornerRadius
Section titled “PlotAreaCornerRadius”public float PlotAreaCornerRadius { get; set; }Corner radius for the plot area. Swift Charts equivalent: .chartPlotStyle { $0.CornerRadius(…) }
Returns
System.Single
ChartBorderColor
Section titled “ChartBorderColor”public Color ChartBorderColor { get; set; }Color of the chart border stroke.
Returns
UnityEngine.Color
ChartBorderWidth
Section titled “ChartBorderWidth”public float ChartBorderWidth { get; set; }Width of the chart border stroke in pixels.
Returns
System.Single
ChartBorderCornerRadius
Section titled “ChartBorderCornerRadius”public float ChartBorderCornerRadius { get; set; }Corner radius for a rounded chart border.
Returns
System.Single
LegendAlignment
Section titled “LegendAlignment”public LegendAlignment LegendAlignment { get; set; }Alignment of the legend within its position area. Swift Charts equivalent: .ChartLegend(position:alignment:)
Returns
ChartGuru.LegendAlignment
ChartType
Section titled “ChartType”public ChartType ChartType { get; set; }Returns
ChartGuru.ChartType
Animation
Section titled “Animation”public Animation? Animation { get; set; }Animation used for data changes. Set to an animation to interpolate values, or null to apply instantly (matching Swift Charts’ default).
Returns
System.Nullable{ChartGuru.Animation}
public ChartTheme Theme { get; set; }Returns
ChartGuru.ChartTheme
UseBackgroundColorOverride
Section titled “UseBackgroundColorOverride”public bool UseBackgroundColorOverride { get; set; }Gets or sets whether to override the theme background color.
Returns
System.Boolean
BackgroundMode
Section titled “BackgroundMode”public ChartBackgroundMode BackgroundMode { get; set; }Background rendering mode used when ChartGuru.ChartGraphic.UseBackgroundColorOverride is true.
Returns
ChartGuru.ChartBackgroundMode
BackgroundColorOverride
Section titled “BackgroundColorOverride”public Color BackgroundColorOverride { get; set; }Gets or sets the background color override. Applied when UseBackgroundColorOverride is true and BackgroundMode is SolidColor. Setting to transparent achieves the same as TransparentBackground.
Returns
UnityEngine.Color
BackgroundGradientStyle
Section titled “BackgroundGradientStyle”public LinearGradientStyle BackgroundGradientStyle { get; set; }Linear gradient override for chart background. Applied when UseBackgroundColorOverride is true and BackgroundMode is LinearGradient.
Returns
ChartGuru.LinearGradientStyle
BackgroundFourCorner
Section titled “BackgroundFourCorner”public FourCornerGradient BackgroundFourCorner { get; set; }Four-corner gradient override for chart background. Applied when UseBackgroundColorOverride is true and BackgroundMode is FourCornerGradient.
Returns
ChartGuru.FourCornerGradient
UsePlotAreaColorOverride
Section titled “UsePlotAreaColorOverride”public bool UsePlotAreaColorOverride { get; set; }Gets or sets whether to override the theme plot area color.
Returns
System.Boolean
PlotAreaMode
Section titled “PlotAreaMode”public ChartBackgroundMode PlotAreaMode { get; set; }Background rendering mode for the plot area override.
Returns
ChartGuru.ChartBackgroundMode
PlotAreaColorOverride
Section titled “PlotAreaColorOverride”public Color PlotAreaColorOverride { get; set; }Gets or sets the plot area fill color override. Applied when UsePlotAreaColorOverride is true and PlotAreaMode is SolidColor.
Returns
UnityEngine.Color
PlotAreaGradientStyle
Section titled “PlotAreaGradientStyle”public LinearGradientStyle PlotAreaGradientStyle { get; set; }Linear gradient for the plot area background. Applied when UsePlotAreaColorOverride is true and PlotAreaMode is LinearGradient.
Returns
ChartGuru.LinearGradientStyle
PlotAreaFourCorner
Section titled “PlotAreaFourCorner”public FourCornerGradient PlotAreaFourCorner { get; set; }Four-corner gradient for the plot area background. Applied when UsePlotAreaColorOverride is true and PlotAreaMode is FourCornerGradient.
Returns
ChartGuru.FourCornerGradient
SelectedIndex
Section titled “SelectedIndex”public int SelectedIndex { get; set; }Gets or sets the currently selected data point index.
Returns
System.Int32
mainTexture
Section titled “mainTexture”public override Texture mainTexture { get; }Returns
UnityEngine.Texture
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}
OnDataPointSelected
Section titled “OnDataPointSelected”public event Action<int, DataPoint> OnDataPointSelectedRaised with the mark index and data point after selection changes.
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}
OnSelectionCleared
Section titled “OnSelectionCleared”public event Action OnSelectionClearedRaised after the current chart selection is cleared.
Returns
System.Action