Skip to content

Rendering Paths

Rendering hosts share the ChartDefinition and Chart model. Choose a host for its destination, then reuse chart assets and data frames across compatible hosts. A 2D host displays a 3D definition in its flat form, including sampled surfaces as heat-map cells; use a 3D host when depth is required.

Host

Use it when

ChartGraphic

The chart belongs in a uGUI Canvas, including Screen Space Overlay, Screen Space Camera, or World Space Canvas.

ChartComponent

You want a quick scene component for prototyping without building a full Canvas workflow.

ChartGuruElement

The UI is built with UI Toolkit, UXML, USS, or Unity data binding.

Chart Designer and Galleries

You need an editor preview or a visual authoring surface.

UI Toolkit

ChartGuruElement is a UI Toolkit VisualElement with UXML attributes and the same inline-definition, ChartAsset and ChartDataAsset model as other hosts. Use UIToolkitChartBinder to find a named chart element inside a UIDocument or compatible PanelRenderer host and bind scene data to it. The binder supports both 2D and Chart3DElement outputs.

Unity UI Builder with the Daylight ChartGuruElement selected, its Chart asset assigned in the Inspector, and the chart drawn in the viewport.
Select the ChartGuruElement in UI Builder to see its Chart asset and preview the embedded result.
<UXML xmlns="UnityEngine.UIElements" xmlns:cg="ChartGuru">
<cg:ChartGuruElement name="sales-chart"
chart-type="Line" style="flex-grow: 1;" />
</UXML>

On the UI Toolkit Chart Binder, assign UI Panel and Element Name, then use Chart Asset and Data Asset as needed. Add a source to the binder's GameObject or inherit one from a parent; Add Data Source and Select Source help manage it. In code the asset properties are DefinitionAsset and DataAsset. On Unity versions without asset UXML attributes, assign assets through the binder or code.

Sharing Data and Images

Use ChartDataExporter.ToCsv(chart) or ToJson(chart) to obtain deterministic semantic data, or WriteCsv and WriteJson to save it to an application-chosen path. Exports describe the chart's marks and their meaning, including X/Y/Z values where applicable; they are separate from a rendered image.

For a Canvas ChartGraphic, use EncodeOutputPng(includeText: true) for PNG bytes or SaveOutputPng(path, includeText: true) for a file. Including text composes titles, axes, legends and data labels with the chart. Choose includeText: false when only the chart geometry is wanted. Use a writable application path such as Application.persistentDataPath on supported targets and provide truthful save feedback in the surrounding UI.