Skip to content

ChartComponent

ClassChartGuruChartGuru
public abstract class ChartComponent : MonoBehaviour, IChartHost

Base of the chart hosts that live in the world outside a Canvas, such as Chart3DComponent. Like every host it shows a ChartDefinition or a ChartAsset with bound data; the subclass draws it. A ChartRaycaster on the camera brings it EventSystem pointer events for hover, tooltips, selection and orbit. Show 2D charts with ChartGraphic, on a world-space Canvas to place them in the world.

public void SetChart(Chart chart)

Shows a chart built in code. The chart is runtime state: it is not saved and replaces the definition until ChartComponent.ClearChart() is called.

Parameters

NameType
chartChartGuru.Chart
public void ClearChart()

Returns from a chart set in code to the definition.

public void SetData(ChartDataFrame data, bool shapeChanged = true)

Shows data 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

NameType
dataChartGuru.ChartDataFrame
shapeChangedSystem.Boolean
public void ClearData()

Returns from data set in code to the bound data.

public void Rebuild()

Recompiles the chart from the definition and its data now.

public void SetDirty()

Recompiles the chart from the definition and its data on the next update.

public void MorphTo(ChartType type, ChartMorphStyle? style = null)

Changes the chart type and morphs the live chart into it. Families with different layouts, such as bars and pies, switch without a morph. A chart set from code changes its own type.

Parameters

NameType
typeChartGuru.ChartType
styleSystem.Nullable{ChartGuru.ChartMorphStyle}
public void ReplayEntryAnimation(Animation? animation = null)

Replays the entry animation, using the chart’s animation when none is given.

Parameters

NameType
animationSystem.Nullable{ChartGuru.Animation}
public void OnPointerDown(PointerEventData eventData)

Starts a press: a tap when released in place, an orbit or pinch when it moves.

Parameters

NameType
eventDataUnityEngine.EventSystems.PointerEventData
public void OnPointerUp(PointerEventData eventData)

Ends a press, selecting the mark or value under a tap or finishing a drag.

Parameters

NameType
eventDataUnityEngine.EventSystems.PointerEventData
public void OnPointerMove(PointerEventData eventData)

Tracks hover, which drives highlights and tooltips.

Parameters

NameType
eventDataUnityEngine.EventSystems.PointerEventData
public void OnPointerExit(PointerEventData eventData)

Clears the hover target when the pointer leaves the chart.

Parameters

NameType
eventDataUnityEngine.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

NameType
eventDataUnityEngine.EventSystems.PointerEventData
public void OnDrag(PointerEventData eventData)

Moves a pressed pointer, which orbits the chart or feeds its custom drag gesture.

Parameters

NameType
eventDataUnityEngine.EventSystems.PointerEventData
public void OnScroll(PointerEventData eventData)

Zooms the view, or feeds the chart’s magnification gesture.

Parameters

NameType
eventDataUnityEngine.EventSystems.PointerEventData

protected ChartComponent()

public ChartHostContent Content { get; }

What this component shows: an inline definition or a chart asset, plus bound data.

Returns

ChartGuru.ChartHostContent

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 component that uses a chart asset returns its own copy, like Renderer.material, so runtime edits never change the asset. Call ChartComponent.Rebuild() after editing it.

Returns

ChartGuru.ChartDefinition

public ChartAsset DefinitionAsset { get; set; }

Shared chart asset; assigning one replaces the inline definition until it is cleared.

Returns

ChartGuru.ChartAsset

public ChartDefinition InlineDefinition { get; set; }

The definition stored with this component, used when no asset is assigned.

Returns

ChartGuru.ChartDefinition

public ChartDataAsset DataAsset { get; set; }

Shared data table bound to this chart.

Returns

ChartGuru.ChartDataAsset

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, selection and viewport control for the runtime chart.

Returns

ChartGuru.ChartProxy

public bool HasRuntimeChart { get; }

True while a chart set from code replaces the definition.

Returns

System.Boolean

public bool IsShowingPreviewData { get; }

True while generated preview data is shown because nothing is bound and the definition has no rows.

Returns

System.Boolean

public ChartType ChartType { get; set; }

The displayed chart type. Setting it morphs the live chart when the families allow it.

Returns

ChartGuru.ChartType

public event Action<int, DataPoint> OnDataPointClicked

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

Returns

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

public event Action<int, DataPoint> OnDataPointSelected

Raised with the mark index and data point after selection changes.

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 OnSelectionCleared

Raised after the current selection is cleared.

Returns

System.Action

public event Action<ChartTooltipState> OnTooltipChanged

Raised whenever tooltip visibility, content, pin state or the semantic hit changes.

Returns

System.Action{ChartGuru.ChartTooltipState}