ChartGraphic
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”
SetChart(Chart)
Section titled “SetChart(Chart)”public void SetChart(Chart chart)Shows a chart built in code. The chart is runtime state: it is not saved with the scene and
replaces the definition until ChartGraphic.ClearChart() is called.
Parameters
| Name | Type |
|---|---|
chart | ChartGuru.Chart |
ClearChart()
Section titled “ClearChart()”public void ClearChart()Returns from a chart set in code to the definition.
SetData(ChartDataFrame, bool)
Section titled “SetData(ChartDataFrame, bool)”public void SetData(ChartDataFrame frame, bool shapeChanged = true)Shows frame instead of the bound data, mapped by the definition’s layers. The data is
runtime state and is not saved; pass null to return to the bound data. Pass shapeChanged false
when the data keeps the columns, row count and categories shown, so the chart’s values update in place.
Parameters
| Name | Type |
|---|---|
frame | ChartGuru.ChartDataFrame |
shapeChanged | System.Boolean |
ClearData()
Section titled “ClearData()”public void ClearData()Returns from data set in code to the bound data.
Rebuild()
Section titled “Rebuild()”public void Rebuild()Recompiles the chart from the definition, for example after editing it from code.
SetDirty()
Section titled “SetDirty()”public void SetDirty()Marks the chart for a rebuild on the next update.
MorphTo(ChartType, ChartMorphStyle?)
Section titled “MorphTo(ChartType, ChartMorphStyle?)”public void MorphTo(ChartType type, ChartMorphStyle? style = null)Changes the chart type and morphs the live chart into it, bars into pies included; types without a 2D morph recipe, such as 3D types, rebuild instead. A chart set from code changes its own type.
Parameters
| Name | Type |
|---|---|
type | ChartGuru.ChartType |
style | System.Nullable{ChartGuru.ChartMorphStyle} |
ClearSelection()
Section titled “ClearSelection()”public void ClearSelection()Clears the selection on the runtime chart.
OnPointerDown(PointerEventData)
Section titled “OnPointerDown(PointerEventData)”public void OnPointerDown(PointerEventData eventData)Starts a press: a tap when released in place, a drag, orbit or pinch when it moves.
Parameters
| Name | Type |
|---|---|
eventData | UnityEngine.EventSystems.PointerEventData |
OnPointerUp(PointerEventData)
Section titled “OnPointerUp(PointerEventData)”public void OnPointerUp(PointerEventData eventData)Ends a press, selecting the mark under a tap or finishing a drag.
Parameters
| Name | Type |
|---|---|
eventData | UnityEngine.EventSystems.PointerEventData |
OnPointerMove(PointerEventData)
Section titled “OnPointerMove(PointerEventData)”public void OnPointerMove(PointerEventData eventData)Tracks hover, which drives highlights and tooltips.
Parameters
| Name | Type |
|---|---|
eventData | UnityEngine.EventSystems.PointerEventData |
OnPointerExit(PointerEventData)
Section titled “OnPointerExit(PointerEventData)”public void OnPointerExit(PointerEventData eventData)Clears the hover target when the pointer leaves the chart.
Parameters
| Name | Type |
|---|---|
eventData | UnityEngine.EventSystems.PointerEventData |
OnInitializePotentialDrag(PointerEventData)
Section titled “OnInitializePotentialDrag(PointerEventData)”public void OnInitializePotentialDrag(PointerEventData eventData)Lets drags start at the chart’s own threshold, which tells taps from drags for every host alike.
Parameters
| Name | Type |
|---|---|
eventData | UnityEngine.EventSystems.PointerEventData |
OnDrag(PointerEventData)
Section titled “OnDrag(PointerEventData)”public void OnDrag(PointerEventData eventData)Moves a pressed pointer, for drag selection, panning, pinching or the chart’s custom drag gesture.
Parameters
| Name | Type |
|---|---|
eventData | UnityEngine.EventSystems.PointerEventData |
OnScroll(PointerEventData)
Section titled “OnScroll(PointerEventData)”public void OnScroll(PointerEventData eventData)Zooms scrollable axes or feeds magnification; unhandled wheel input reaches a parent scroll view.
Parameters
| Name | Type |
|---|---|
eventData | UnityEngine.EventSystems.PointerEventData |
ReplayEntryAnimation(Animation?)
Section titled “ReplayEntryAnimation(Animation?)”public void ReplayEntryAnimation(Animation? animation = null)Replays the entry animation, using the chart’s animation when none is given.
Parameters
| Name | Type |
|---|---|
animation | System.Nullable{ChartGuru.Animation} |
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 renders the chart, or defers until the next update when a Canvas rebuild is in progress.
GetOutputTexture(bool)
Section titled “GetOutputTexture(bool)”public Texture GetOutputTexture(bool includeText)Returns the current straight-alpha 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
EncodeOutputPng(bool)
Section titled “EncodeOutputPng(bool)”public byte[] EncodeOutputPng(bool includeText = true)Performs an explicit GPU readback and encodes the current chart as PNG. This is intended for export and screenshots, not per-frame rendering.
Parameters
| Name | Type |
|---|---|
includeText | System.Boolean |
Returns
System.Byte[]
SaveOutputPng(string, bool)
Section titled “SaveOutputPng(string, bool)”public void SaveOutputPng(string path, bool includeText = true)Encodes and writes the current chart to an explicit PNG path.
Parameters
| Name | Type |
|---|---|
path | System.String |
includeText | System.Boolean |
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 a Canvas quad for the chart render texture, or clears the mesh before a render target exists.
Parameters
| Name | Type |
|---|---|
vh | UnityEngine.UI.VertexHelper |
UpdateMaterial()
Section titled “UpdateMaterial()”protected override void UpdateMaterial()Updates the Canvas material and selects the chart texture matching its alpha convention.
Constructors
Section titled “Constructors”
ChartGraphic()
Section titled “ChartGraphic()”public ChartGraphic()Properties
Section titled “Properties”
Content
Section titled “Content”public ChartHostContent Content { get; }What this graphic shows: an inline definition or a chart asset, plus bound data.
Returns
ChartGuru.ChartHostContent
Definition
Section titled “Definition”public ChartDefinition Definition { get; }The definition to read or edit: the asset’s when one is assigned, otherwise the inline one. In Play Mode a
graphic that uses a chart asset returns its own copy, like Renderer.material, so runtime edits never
change the asset. Call ChartGraphic.Rebuild() after editing it.
Returns
ChartGuru.ChartDefinition
DefinitionAsset
Section titled “DefinitionAsset”public ChartAsset DefinitionAsset { get; set; }Shared chart asset; assigning one replaces the inline definition until it is cleared.
Returns
ChartGuru.ChartAsset
InlineDefinition
Section titled “InlineDefinition”public ChartDefinition InlineDefinition { get; set; }The definition stored with this component, used when no asset is assigned.
Returns
ChartGuru.ChartDefinition
DataAsset
Section titled “DataAsset”public ChartDataAsset DataAsset { get; set; }Shared data table bound to this chart.
Returns
ChartGuru.ChartDataAsset
Timing
Section titled “Timing”public FrameTimingSettings Timing { get; set; }Update rate and edit-mode ticking.
Returns
ImpossibleRobert.Common.Timing.FrameTimingSettings
public Chart Chart { get; }The runtime chart being drawn.
Returns
ChartGuru.Chart
public ChartProxy Proxy { get; }Hit testing and coordinate conversion for the runtime chart.
Returns
ChartGuru.ChartProxy
TooltipState
Section titled “TooltipState”public ChartTooltipState TooltipState { get; }A snapshot of tooltip visibility, pin state, hit, pointer position, retained content, and version; returns the default state before the runtime controller exists.
Returns
ChartGuru.ChartTooltipState
HasRuntimeChart
Section titled “HasRuntimeChart”public bool HasRuntimeChart { get; }True while a chart set from code replaces the definition.
Returns
System.Boolean
ChartType
Section titled “ChartType”public ChartType ChartType { get; set; }The definition’s chart family. Setting it morphs the live chart when a 2D morph recipe exists.
Returns
ChartGuru.ChartType
IsShowingPreviewData
Section titled “IsShowingPreviewData”public bool IsShowingPreviewData { get; }True while generated preview data is shown because nothing is bound and the definition has no rows.
Returns
System.Boolean
mainTexture
Section titled “mainTexture”public override Texture mainTexture { get; }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 RadarLabelLayout.
Returns
UnityEngine.Texture
defaultMaterial
Section titled “defaultMaterial”public override Material defaultMaterial { get; }The default Canvas material consumes the private filtered premultiplied chart target.
Returns
UnityEngine.Material
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
OnTooltipChanged
Section titled “OnTooltipChanged”public event Action<ChartTooltipState> OnTooltipChangedRaised whenever retained tooltip visibility, content, pin state, or the semantic hit changes.
Returns
System.Action{ChartGuru.ChartTooltipState}
OnTooltipPresentationChanged
Section titled “OnTooltipPresentationChanged”public event Action<ChartTooltipState> OnTooltipPresentationChangedRaised for all tooltip presentation updates, including pointer-only and animated placement changes.
Returns
System.Action{ChartGuru.ChartTooltipState}