Chart3DElement
public class Chart3DElement : VisualElement, IChartElement, IChartHostUI Toolkit host for 3D charts. Like Chart3DComponent it shows a ChartDefinition or a
ChartAsset with data from a ChartDataAsset, a ChartDataSource or code,
compiled into a 3D chart. Its own private view renders the chart into a texture sized to the element in pixels,
only when something it shows changed, and the element draws that texture. Drags orbit the pose, scroll and pinch
zoom, and hover, taps and tooltips use the pointer path every chart host shares. In UXML, chart and
data reference assets and chart-type sets the type of the element's own definition.
Methods
Section titled “Methods”
ClearSelection()
Section titled “ClearSelection()”public void ClearSelection()Clears the selection on the runtime chart.
ResetViewport()
Section titled “ResetViewport()”public void ResetViewport()Returns to the pose and zoom before the user orbited or zoomed, as a double tap does.
MorphTo(ChartType, ChartMorphStyle?)
Section titled “MorphTo(ChartType, ChartMorphStyle?)”public void MorphTo(ChartType type, ChartMorphStyle? style = null)Changes the chart type and morphs the drawn chart into it where a morph recipe exists, else rebuilds it. A chart set from code changes its own type.
Parameters
| Name | Type |
|---|---|
type | ChartGuru.ChartType |
style | System.Nullable{ChartGuru.ChartMorphStyle} |
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
Chart3DElement.ClearChart() is called. The element runs the chart’s transitions, so a chart that a scene host
already animates belongs in a Chart3DImage or Chart3DTexture that follows it.
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.
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.
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} |
Invalidate()
Section titled “Invalidate()”public void Invalidate()Renders again on the next update, for content that changed without telling the chart.
PlayLift(float, Animation?, Action)
Section titled “PlayLift(float, Animation?, Action)”public void PlayLift(float lift, Animation? animation = null, Action completed = null)Plays the lift into 3D (toward 1) or the flattening into 2D (toward 0), as Chart3DComponent.PlayLift(float, Animation?, Action).
Parameters
| Name | Type |
|---|---|
lift | System.Single |
animation | System.Nullable{ChartGuru.Animation} |
completed | System.Action |
Dispose()
Section titled “Dispose()”public void Dispose()Releases the chart this element compiled, its view, texture, schedules and subscriptions.
Constructors
Section titled “Constructors”
Chart3DElement()
Section titled “Chart3DElement()”public Chart3DElement()Creates an element that shows a 3D bar chart definition of its own.
Properties
Section titled “Properties”
TooltipState
Section titled “TooltipState”public ChartTooltipState TooltipState { get; }A snapshot of the tooltip’s visibility, pin state, hit, pointer position (in the element’s content points from its bottom-left corner), retained content and change version; hovers and taps update it, and renders from a new camera move its hit with the mark.
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
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 Chart3DElement.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.
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; 2D types draw as their 3D
counterparts. UXML: chart-type.
Returns
ChartGuru.ChartType
public Chart Chart { get; }The runtime chart being drawn.
Returns
ChartGuru.Chart
ChartType
Section titled “ChartType”public ChartType ChartType { get; set; }The type of the chart being drawn. Setting it is Chart3DElement.MorphTo(ChartType, ChartMorphStyle?).
Returns
ChartGuru.ChartType
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
ViewSettings
Section titled “ViewSettings”public Chart3DViewSettings ViewSettings { get; }Camera, theme, quality and refresh settings of this element’s view. Changes render on the next update; call
Chart3DElement.Invalidate() after changing content the chart is not told about.
Returns
ChartGuru.Chart3DViewSettings
public ChartTheme Theme { get; set; }Optional theme for this element’s 3D look, axis, grid and text colors and background. Empty uses the chart’s theme; the chart’s own palette always colors the marks.
Returns
ChartGuru.ChartTheme
Appearance
Section titled “Appearance”public Chart3DAppearanceOverride Appearance { get; set; }Optional changes to the theme’s 3D look for this element only, such as another environment cubemap.
Returns
ChartGuru.Chart3DAppearanceOverride
public Chart3DPose Pose { get; set; }The pose this element shows; setting it stops following the chart’s camera.
Returns
ChartGuru.Chart3DPose
Projection
Section titled “Projection”public Chart3DCameraProjection Projection { get; set; }The projection this element shows; setting it stops following the chart’s camera.
Returns
ChartGuru.Chart3DCameraProjection
AutoRotate
Section titled “AutoRotate”public bool AutoRotate { get; set; }Whether the view turns about the chart in Play Mode.
Returns
System.Boolean
public float Zoom { get; set; }Lens zoom of this element’s view, changed by scroll and pinch; 1 is the framed size. Runtime only.
Returns
System.Single
Texture
Section titled “Texture”public RenderTexture Texture { get; }The texture the element draws, sized to its content in pixels; null before the first render.
Returns
UnityEngine.RenderTexture
HasError
Section titled “HasError”public bool HasError { get; }True when the latest render failed; it is retried once anything it shows changes.
Returns
System.Boolean
public float Lift { get; set; }How lifted the chart is drawn, as Chart3DComponent.Lift: 1 at full depth and the chart’s pose, 0 flat
and facing the viewer, as its 2D chart. Setting it shows the new lift at once.
Returns
System.Single
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}