ChartGuruElement
public class ChartGuruElement : VisualElement, IChartHostUI Toolkit chart host. Like ChartGraphic it shows a ChartDefinition or a
ChartAsset with data from a ChartDataAsset, a ChartDataSource or
code, and draws through the shared ChartRenderer. In UXML, chart and data
reference assets and chart-type sets the type of the element's own definition.
The chart lays out in panel points and renders into a UnityEngine.RenderTexture sized to the content rect in pixels, emitted as one
textured quad through UITKMeshDrawSink. Axis, data and legend labels, titles and tooltips are
pooled UI Toolkit elements on an overlay, placed from the same layout ChartGraphic uses.
Constructors
Section titled “Constructors”
ChartGuruElement()
Section titled “ChartGuruElement()”public ChartGuruElement()Creates an element that shows a bar chart definition of its own.
Methods
Section titled “Methods”
Rebuild()
Section titled “Rebuild()”public void Rebuild()Recompiles the chart from the definition and its data now.
SetDirty()
Section titled “SetDirty()”public void SetDirty()Recompiles the chart on the next scheduler tick, merging repeated requests.
Dispose()
Section titled “Dispose()”public void Dispose()Releases renderer, tooltip, chart, schedule, and texture resources owned by this element.
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 and replaces the definition until
ChartGuruElement.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 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
| Name | Type |
|---|---|
data |
ChartGuru.ChartDataFrame |
shapeChanged |
System.Boolean |
ClearData()
Section titled “ClearData()”public void ClearData()Returns from data set in code to the bound data.
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} |
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} |
ClearSelection()
Section titled “ClearSelection()”public void ClearSelection()Clears the selection on the runtime chart.
ResetViewport()
Section titled “ResetViewport()”public void ResetViewport()Restores both axes to their configured visible domains.
Properties
Section titled “Properties”
Content
Section titled “Content”public ChartHostContent Content { get; }What this element shows: its own 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 element's own. In Play Mode
an element that uses a chart asset returns its own copy, like Renderer.material, so runtime edits
never change the asset. Call ChartGuruElement.Rebuild() after editing it.
Returns
ChartGuru.ChartDefinition
InlineDefinition
Section titled “InlineDefinition”public ChartDefinition InlineDefinition { get; set; }The element's own definition, used when no chart asset is assigned. UXML saves only its chart type.
Returns
ChartGuru.ChartDefinition
DefinitionAsset
Section titled “DefinitionAsset”public ChartAsset DefinitionAsset { get; set; }Shared chart asset. When set, it replaces the element's own definition. UXML: chart.
Returns
ChartGuru.ChartAsset
DataAsset
Section titled “DataAsset”public ChartDataAsset DataAsset { get; set; }Shared data table bound to the chart. UXML: data.
Returns
ChartGuru.ChartDataAsset
DataSource
Section titled “DataSource”public ChartDataSource DataSource { get; set; }Live data source bound to the chart, such as a CSV file, a web endpoint or mock data. UXML cannot reference
scene objects, so assign it from code or with a UIToolkitChartBinder.
Returns
ChartGuru.ChartDataSource
InlineChartType
Section titled “InlineChartType”public ChartType InlineChartType { get; set; }Chart type of the element's own definition, used when no chart asset is assigned. UXML: chart-type.
Returns
ChartGuru.ChartType
public ChartDataFrame Data { get; set; }Data shown instead of the bound data, for code and Unity 6 runtime data binding. Null returns to the bound data. Not saved.
Returns
ChartGuru.ChartDataFrame
ChartType
Section titled “ChartType”public ChartType ChartType { get; set; }The displayed chart type. Setting it morphs the live chart when a 2D morph recipe exists.
Returns
ChartGuru.ChartType
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
HasRuntimeChart
Section titled “HasRuntimeChart”public bool HasRuntimeChart { get; }True while a chart set from code replaces the definition.
Returns
System.Boolean
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
TooltipState
Section titled “TooltipState”public ChartTooltipState TooltipState { get; }A snapshot of tooltip visibility, pin state, hit, pointer position, retained content, and version, refreshed as interactions or presentation change.
Returns
ChartGuru.ChartTooltipState
SelectedIndex
Section titled “SelectedIndex”public int SelectedIndex { get; }Index of the selected mark, or -1.
Returns
System.Int32
HoveredIndex
Section titled “HoveredIndex”public int HoveredIndex { get; }Index of the hovered mark, or -1.
Returns
System.Int32
Events
Section titled “Events”
DataPointClicked
Section titled “DataPointClicked”public event Action<int, DataPoint> DataPointClickedRaised when a data point is clicked or tapped.
Returns
System.Action{System.Int32,ChartGuru.DataPoint}
DataPointSelected
Section titled “DataPointSelected”public event Action<int, DataPoint> DataPointSelectedRaised when a data point becomes selected.
Returns
System.Action{System.Int32,ChartGuru.DataPoint}
DataPointHovered
Section titled “DataPointHovered”public event Action<int, DataPoint> DataPointHoveredRaised when the pointer moves onto a data point.
Returns
System.Action{System.Int32,ChartGuru.DataPoint}
SelectionCleared
Section titled “SelectionCleared”public event Action SelectionClearedRaised when the selection is cleared.
Returns
System.Action
TooltipChanged
Section titled “TooltipChanged”public event Action<ChartTooltipState> TooltipChangedRaised when the tooltip content or visibility changes.
Returns
System.Action{ChartGuru.ChartTooltipState}
TooltipPresentationChanged
Section titled “TooltipPresentationChanged”public event Action<ChartTooltipState> TooltipPresentationChangedRaised when the tooltip moves, including content changes.
Returns
System.Action{ChartGuru.ChartTooltipState}
OnSelectionChanged
Section titled “OnSelectionChanged”public event Action<int> OnSelectionChangedRaised with the selected mark index after pointer or programmatic selection changes.
Returns
System.Action{System.Int32}
OnHoverChanged
Section titled “OnHoverChanged”public event Action<int> OnHoverChangedRaised with the hovered mark index, or -1 after the pointer leaves all marks.
Returns
System.Action{System.Int32}
OnMorphComplete
Section titled “OnMorphComplete”public event Action<ChartType> OnMorphCompleteRaised with the new chart type after an animated morph reaches its target.
Returns
System.Action{ChartGuru.ChartType}