Skip to content

ChartGuruElement

ClassChartGuruChartGuru
[UxmlElement]
public class ChartGuruElement : VisualElement, IChartHost

Shallow UI Toolkit adapter on top of the existing ChartGuru.ChartGuruElement.Chart + ChartGuru.ChartRenderer + ChartGuru.ChartProxy engine. Owns the UI Toolkit lifecycle (geometry invalidation, visual content emission, pointer events, animation ticking) and delegates everything else to the shared helpers: ChartGuru.ChartInteractionController, ChartGuru.ChartAuthoringBinder, pooled UI Toolkit labels, and ChartGuru.UITKMeshDrawSink.

V1 rendering strategy: the existing GL pipeline renders into a `UnityEngine.RenderTexture` sized to contentRect.size * scaledPixelsPerPoint, and a single textured quad is emitted through `UnityEngine.UIElements.MeshGenerationContext.Allocate(System.Int32%2cSystem.Int32%2cUnityEngine.Texture)`. Once the `ChartGuru.ChartRenderer` primitive sites have been migrated to emit through [ChartGuru.IChartDrawSink](/tools/chartguru/api/chartguru-ichartdrawsink/), the same element swaps the RT step for native geometry emission via [ChartGuru.UITKMeshDrawSink](/tools/chartguru/api/chartguru-uitkmeshdrawsink/) - no API changes required.

public ChartGuruElement()

public void SetData(IReadOnlyList<float> values)

Replace the chart marks with a single series of values.

Parameters

Name Type
values System.Collections.Generic.IReadOnlyList{System.Single}
public void SetChartData(Chart src)

Swap in a pre-built chart model. Use this for richer multi-series scenarios.

Parameters

Name Type
src ChartGuru.Chart
public void MorphTo(ChartType type, MorphOptions options = null)

Morph to a new chart type with animation, matching ChartGraphic.MorphTo.

Parameters

Name Type
type ChartGuru.ChartType
options ChartGuru.MorphOptions
public void ReplayEntryAnimation(Animation? animation = null)

Replay the configured entry animation without recreating the element.

Parameters

Name Type
animation System.Nullable{ChartGuru.Animation}
public void RebuildChart()

Re-applies the ChartGuru.ChartAuthoringState to the chart/renderer and requests a repaint. Idempotent.

public void SetDirty()

ChartGuru.IChartHost.SetDirty — triggers a full rebuild and repaint.

public ChartAuthoringStyleOptions BuildStyleOptions()

Builds a ChartGuru.ChartAuthoringStyleOptions snapshot from the current ChartGuru.ChartAuthoringState. Used by ChartGuru.IChartGuruElementDataSource implementations so marks are shaped consistently with the element’s authoring.

Returns

ChartGuru.ChartAuthoringStyleOptions

public void ResetViewport()

Restores both axes to their configured visible domains and requests a repaint.

[UxmlAttribute("chart-type")]
[CreateProperty]
public ChartType ChartType { get; set; }

Returns

ChartGuru.ChartType

[CreateProperty]
public ChartTheme Theme { get; set; }

Returns

ChartGuru.ChartTheme

[UxmlAttribute("animate-on-start")]
[CreateProperty]
public bool AnimateOnStart { get; set; }

Returns

System.Boolean

[UxmlAttribute("show-axis-labels")]
[CreateProperty]
public bool ShowAxisLabels { get; set; }

Returns

System.Boolean

[UxmlAttribute("show-axis-titles")]
[CreateProperty]
public bool ShowAxisTitles { get; set; }

Returns

System.Boolean

[UxmlAttribute("show-data-labels")]
[CreateProperty]
public bool ShowDataLabels { get; set; }

Returns

System.Boolean

[UxmlAttribute("legend-alignment")]
[CreateProperty]
public LegendAlignment LegendAlignment { get; set; }

Returns

ChartGuru.LegendAlignment

[UxmlAttribute("stacking-method")]
[CreateProperty]
public MarkStackingMethod StackingMethod { get; set; }

Returns

ChartGuru.MarkStackingMethod

[UxmlAttribute("interpolation")]
[CreateProperty]
public InterpolationMethod Interpolation { get; set; }

Returns

ChartGuru.InterpolationMethod

[UxmlAttribute("line-width")]
[CreateProperty]
public float LineWidth { get; set; }

Returns

System.Single

[UxmlAttribute("corner-radius")]
[CreateProperty]
public float CornerRadius { get; set; }

Returns

System.Single

[UxmlAttribute("inner-radius")]
[CreateProperty]
public float InnerRadius { get; set; }

Returns

System.Single

[UxmlAttribute("x-axis-type")]
[CreateProperty]
public AxisScaleType XAxisType { get; set; }

Returns

ChartGuru.AxisScaleType

[UxmlAttribute("x-axis-time-unit")]
[CreateProperty]
public TimeUnit XAxisTimeUnit { get; set; }

Returns

ChartGuru.TimeUnit

[UxmlAttribute("x-axis-time-format")]
[CreateProperty]
public string XAxisTimeFormat { get; set; }

Returns

System.String

[UxmlAttribute("y-axis-type")]
[CreateProperty]
public AxisScaleType YAxisType { get; set; }

Returns

ChartGuru.AxisScaleType

[UxmlAttribute("y-axis-time-unit")]
[CreateProperty]
public TimeUnit YAxisTimeUnit { get; set; }

Returns

ChartGuru.TimeUnit

[UxmlAttribute("y-axis-time-format")]
[CreateProperty]
public string YAxisTimeFormat { get; set; }

Returns

System.String

[UxmlAttribute("data-source")]
[CreateProperty]
public ChartDataSourceAsset DataSourceAsset { get; set; }

Asset-typed UXML attribute for project-authored data (Unity 2023.2+). Setting this assigns ChartGuru.ChartGuruElement.DataSource to the asset; reading it returns the previously-assigned asset (or null when an MB or custom source is in use).

Returns

ChartGuru.ChartDataSourceAsset

public IChartGuruElementDataSource DataSource { get; set; }

Active data source. May be a ChartGuru.ChartDataSourceAsset, a ChartGuru.ChartDataSourceBase MonoBehaviour, a ViewModel, or any custom ChartGuru.IChartGuruElementDataSource implementation.

Assigning a new source automatically subscribes to its `ChartGuru.IChartGuruElementDataSource.DataChanged` event and pulls the initial data set into the chart. Set to null to detach.

Returns

ChartGuru.IChartGuruElementDataSource

[CreateProperty]
public IReadOnlyList<float> Data { get; set; }

Live single-series data buffer for runtime / ViewModel binding (Unity 6+ CreateProperty). Setting the property replaces the chart’s current marks with one mark per value, shaped for the current ChartGuru.ChartGuruElement.ChartType. Bypasses ChartGuru.ChartGuruElement.DataSource — assignment makes the element act as its own data feed.

Returns

System.Collections.Generic.IReadOnlyList{System.Single}

public Chart Chart { get; }

Underlying chart instance. Exposed for programmatic data manipulation.

Returns

ChartGuru.Chart

public ChartProxy Proxy { get; }

Underlying proxy for position/domain queries.

Returns

ChartGuru.ChartProxy

[UxmlAttribute("legend-position")]
[CreateProperty]
public LegendPosition LegendPosition { get; set; }

Returns

ChartGuru.LegendPosition

[UxmlAttribute("chart-title")]
[CreateProperty]
public string ChartTitle { get; set; }

Returns

System.String

[UxmlAttribute("chart-subtitle")]
[CreateProperty]
public string ChartSubtitle { get; set; }

Returns

System.String

[UxmlAttribute("chart-title-position")]
[CreateProperty]
public ChartTitlePosition ChartTitlePosition { get; set; }

Returns

ChartGuru.ChartTitlePosition

[UxmlAttribute("show-x-axis")]
[CreateProperty]
public bool ShowXAxis { get; set; }

Returns

System.Boolean

[UxmlAttribute("show-y-axis")]
[CreateProperty]
public bool ShowYAxis { get; set; }

Returns

System.Boolean

[UxmlAttribute("x-axis-label")]
[CreateProperty]
public string XAxisLabel { get; set; }

Returns

System.String

[UxmlAttribute("y-axis-label")]
[CreateProperty]
public string YAxisLabel { get; set; }

Returns

System.String

[UxmlAttribute("show-x-grid-lines")]
[CreateProperty]
public bool ShowXGridLines { get; set; }

Returns

System.Boolean

[UxmlAttribute("show-y-grid-lines")]
[CreateProperty]
public bool ShowYGridLines { get; set; }

Returns

System.Boolean

[UxmlAttribute("x-axis-tick-count")]
[CreateProperty]
public int XAxisTickCount { get; set; }

Returns

System.Int32

[UxmlAttribute("y-axis-tick-count")]
[CreateProperty]
public int YAxisTickCount { get; set; }

Returns

System.Int32

[UxmlAttribute("x-axis-tick-format")]
[CreateProperty]
public string XAxisTickFormat { get; set; }

Returns

System.String

[UxmlAttribute("y-axis-tick-format")]
[CreateProperty]
public string YAxisTickFormat { get; set; }

Returns

System.String

[UxmlAttribute("x-axis-auto-domain")]
[CreateProperty]
public bool XAxisAutoDomain { get; set; }

Returns

System.Boolean

[UxmlAttribute("y-axis-auto-domain")]
[CreateProperty]
public bool YAxisAutoDomain { get; set; }

Returns

System.Boolean

[UxmlAttribute("x-axis-domain-min")]
[CreateProperty]
public float XAxisDomainMin { get; set; }

Returns

System.Single

[UxmlAttribute("x-axis-domain-max")]
[CreateProperty]
public float XAxisDomainMax { get; set; }

Returns

System.Single

[UxmlAttribute("y-axis-domain-min")]
[CreateProperty]
public float YAxisDomainMin { get; set; }

Returns

System.Single

[UxmlAttribute("y-axis-domain-max")]
[CreateProperty]
public float YAxisDomainMax { get; set; }

Returns

System.Single

[UxmlAttribute("y-axis-on-right")]
[CreateProperty]
public bool YAxisOnRight { get; set; }

Returns

System.Boolean

[UxmlAttribute("x-axis-label-preset")]
[CreateProperty]
public AxisMarkPreset XAxisLabelPreset { get; set; }

Returns

ChartGuru.AxisMarkPreset

[UxmlAttribute("y-axis-label-preset")]
[CreateProperty]
public AxisMarkPreset YAxisLabelPreset { get; set; }

Returns

ChartGuru.AxisMarkPreset

[UxmlAttribute("show-symbols")]
[CreateProperty]
public bool ShowSymbols { get; set; }

Returns

System.Boolean

[UxmlAttribute("symbol-size")]
[CreateProperty]
public float SymbolSize { get; set; }

Returns

System.Single

[UxmlAttribute("symbol")]
[CreateProperty]
public SymbolShape Symbol { get; set; }

Returns

ChartGuru.SymbolShape

[UxmlAttribute("opacity")]
[CreateProperty]
public float Opacity { get; set; }

Returns

System.Single

[UxmlAttribute("show-area-line")]
[CreateProperty]
public bool ShowAreaLine { get; set; }

Returns

System.Boolean

[UxmlAttribute("angular-inset")]
[CreateProperty]
public float AngularInset { get; set; }

Returns

System.Single

[UxmlAttribute("auto-contrast-text")]
[CreateProperty]
public bool AutoContrastText { get; set; }

Returns

System.Boolean

[UxmlAttribute("enable-selection")]
[CreateProperty]
public bool EnableSelection { get; set; }

Returns

System.Boolean

[UxmlAttribute("enable-hover-highlight")]
[CreateProperty]
public bool EnableHoverHighlight { get; set; }

Returns

System.Boolean

[UxmlAttribute("enable-drag-selection")]
[CreateProperty]
public bool EnableDragSelection { get; set; }

Returns

System.Boolean

[UxmlAttribute("enable-viewport-drag")]
[CreateProperty]
public bool EnableViewportDrag { get; set; }

Returns

System.Boolean

[UxmlAttribute("enable-viewport-zoom")]
[CreateProperty]
public bool EnableViewportZoom { get; set; }

Returns

System.Boolean

[UxmlAttribute("viewport-zoom-sensitivity")]
[CreateProperty]
public float ViewportZoomSensitivity { get; set; }

Returns

System.Single

[UxmlAttribute("selection-indicator-style")]
[CreateProperty]
public SelectionIndicatorStyle SelectionIndicatorStyle { get; set; }

Returns

ChartGuru.SelectionIndicatorStyle

[UxmlAttribute("bar-orientation")]
[CreateProperty]
public BarLayout BarOrientation { get; set; }

Returns

ChartGuru.BarLayout

[UxmlAttribute("morph-style")]
[CreateProperty]
public ChartMorphStyle MorphStyle { get; set; }

Returns

ChartGuru.ChartMorphStyle

[CreateProperty]
public Color BackgroundColor { get; set; }

Returns

UnityEngine.Color

[UxmlAttribute("plot-area-border-width")]
[CreateProperty]
public float PlotAreaBorderWidth { get; set; }

Returns

System.Single

[UxmlAttribute("plot-area-corner-radius")]
[CreateProperty]
public float PlotAreaCornerRadius { get; set; }

Returns

System.Single

[CreateProperty]
public Color PlotAreaBorderColor { get; set; }

Returns

UnityEngine.Color

[UxmlAttribute("plot-area-padding-left")]
[CreateProperty]
public float PlotAreaPaddingLeft { get; set; }

Returns

System.Single

[UxmlAttribute("plot-area-padding-right")]
[CreateProperty]
public float PlotAreaPaddingRight { get; set; }

Returns

System.Single

[UxmlAttribute("plot-area-padding-top")]
[CreateProperty]
public float PlotAreaPaddingTop { get; set; }

Returns

System.Single

[UxmlAttribute("plot-area-padding-bottom")]
[CreateProperty]
public float PlotAreaPaddingBottom { get; set; }

Returns

System.Single

[UxmlAttribute("chart-border-width")]
[CreateProperty]
public float ChartBorderWidth { get; set; }

Returns

System.Single

[UxmlAttribute("chart-border-corner-radius")]
[CreateProperty]
public float ChartBorderCornerRadius { get; set; }

Returns

System.Single

[CreateProperty]
public Color ChartBorderColor { get; set; }

Returns

UnityEngine.Color

[CreateProperty]
public bool UseForegroundGradient { get; set; }

Returns

System.Boolean

[CreateProperty]
public Gradient ForegroundGradient { get; set; }

Returns

UnityEngine.Gradient

[CreateProperty]
public UnitPoint ForegroundGradientStartPoint { get; set; }

Returns

ChartGuru.UnitPoint

[CreateProperty]
public UnitPoint ForegroundGradientEndPoint { get; set; }

Returns

ChartGuru.UnitPoint

[UxmlAttribute("data-label-format")]
[CreateProperty]
public string DataLabelFormat { get; set; }

Returns

System.String

[UxmlAttribute("pie-label-mode")]
[CreateProperty]
public PieLabelMode PieLabelMode { get; set; }

Returns

ChartGuru.PieLabelMode

[CreateProperty]
public bool OverrideDataLabelColor { get; set; }

Returns

System.Boolean

[CreateProperty]
public Color DataLabelColor { get; set; }

Returns

UnityEngine.Color

[CreateProperty]
public bool OverrideAxisLabelColor { get; set; }

Returns

System.Boolean

[CreateProperty]
public Color AxisLabelColor { get; set; }

Returns

UnityEngine.Color

[UxmlAttribute("x-axis-include-zero")]
[CreateProperty]
public bool XAxisIncludeZeroInDomain { get; set; }

Returns

System.Boolean

[UxmlAttribute("y-axis-include-zero")]
[CreateProperty]
public bool YAxisIncludeZeroInDomain { get; set; }

Returns

System.Boolean

[UxmlAttribute("heatmap-color-scale-preset")]
[CreateProperty]
public int HeatMapColorScalePreset { get; set; }

Returns

System.Int32

[UxmlAttribute("radar-ring-style")]
[CreateProperty]
public RadarRingStyle RadarRingStyle { get; set; }

Returns

ChartGuru.RadarRingStyle

[UxmlAttribute("animation-duration")]
[CreateProperty]
public float AnimationDuration { get; set; }

Returns

System.Single

[UxmlAttribute("animation-easing")]
[CreateProperty]
public Easing AnimationEasing { get; set; }

Returns

ChartGuru.Easing

[UxmlAttribute("scrollable-axes")]
[CreateProperty]
public ScrollableAxes ScrollableAxes { get; set; }

Returns

ChartGuru.ScrollableAxes

[UxmlAttribute("x-visible-domain-length")]
[CreateProperty]
public float XVisibleDomainLength { get; set; }

Returns

System.Single

[UxmlAttribute("y-visible-domain-length")]
[CreateProperty]
public float YVisibleDomainLength { get; set; }

Returns

System.Single

public int SelectedIndex { get; }

Returns

System.Int32

public int HoveredIndex { get; }

Returns

System.Int32

public event Action<int, DataPoint> DataPointClicked

Raised when the user selects a mark.

Returns

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

public event Action<int, DataPoint> DataPointHovered

Raised when the user hovers a mark.

Returns

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

public event Action<int> OnSelectionChanged

Raised with the selected mark index after pointer or programmatic selection changes.

Returns

System.Action{System.Int32}

public event Action<int> OnHoverChanged

Raised with the hovered mark index, or -1 after the pointer leaves all marks.

Returns

System.Action{System.Int32}

public event Action<ChartType> OnMorphComplete

Raised with the new chart type after an animated morph reaches its target.

Returns

System.Action{ChartGuru.ChartType}