Skip to content

Chart3DElement

ClassChartGuruChartGuru.3D
public class Chart3DElement : VisualElement, IChartElement, IChartHost

UI 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.

public void ClearSelection()

Clears the selection on the runtime chart.

public void ResetViewport()

Returns to the pose and zoom before the user orbited or zoomed, as a double tap does.

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

NameType
typeChartGuru.ChartType
styleSystem.Nullable{ChartGuru.ChartMorphStyle}
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

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 on the next scheduler tick, merging repeated requests.

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 Invalidate()

Renders again on the next update, for content that changed without telling the chart.

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

NameType
liftSystem.Single
animationSystem.Nullable{ChartGuru.Animation}
completedSystem.Action
public void Dispose()

Releases the chart this element compiled, its view, texture, schedules and subscriptions.

public Chart3DElement()

Creates an element that shows a 3D bar chart definition of its own.

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

public int SelectedIndex { get; }

Index of the selected mark, or -1.

Returns

System.Int32

public int HoveredIndex { get; }

Index of the hovered mark, or -1.

Returns

System.Int32

public ChartHostContent Content { get; }

What this element shows: its own 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 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

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

public ChartAsset DefinitionAsset { get; set; }

Shared chart asset. When set, it replaces the element’s own definition. UXML: chart.

Returns

ChartGuru.ChartAsset

public ChartDataAsset DataAsset { get; set; }

Shared data table bound to the chart. UXML: data.

Returns

ChartGuru.ChartDataAsset

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

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

public ChartType ChartType { get; set; }

The type of the chart being drawn. Setting it is Chart3DElement.MorphTo(ChartType, ChartMorphStyle?).

Returns

ChartGuru.ChartType

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

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

public Chart3DCameraProjection Projection { get; set; }

The projection this element shows; setting it stops following the chart’s camera.

Returns

ChartGuru.Chart3DCameraProjection

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

public RenderTexture Texture { get; }

The texture the element draws, sized to its content in pixels; null before the first render.

Returns

UnityEngine.RenderTexture

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

public event Action<int, DataPoint> DataPointClicked

Raised when a data point is clicked or tapped.

Returns

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

public event Action<int, DataPoint> DataPointSelected

Raised when a data point becomes selected.

Returns

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

public event Action<int, DataPoint> DataPointHovered

Raised when the pointer moves onto a data point.

Returns

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

public event Action SelectionCleared

Raised when the selection is cleared.

Returns

System.Action

public event Action<ChartTooltipState> TooltipChanged

Raised when the tooltip content or visibility changes.

Returns

System.Action{ChartGuru.ChartTooltipState}