Skip to content

ChartDataSourceBase

ClassChartGuruChartGuru
[ExecuteAlways]
public abstract class ChartDataSourceBase : MonoBehaviour, IChartGuruElementDataSource, IChartDataSource

Abstract base class for chart data sources. Shared functionality for populating ChartGraphic with data.

[Tooltip("Target ChartGraphic (2D) to populate. If null, discovers charts on same GameObject or in child hierarchy.")]
[SerializeField]
protected ChartGraphic _targetChart

Returns

ChartGuru.ChartGraphic

[Tooltip("Optional target 3D host (e.g. Chart3DComponent). Typed as Component to avoid a hard dependency on the ChartGuru.3D add-on.")]
[SerializeField]
protected Component _targetChart3D

Returns

UnityEngine.Component

PopulateChart(Chart, ChartType, ChartAuthoringStyleOptions)

Section titled “PopulateChart(Chart, ChartType, ChartAuthoringStyleOptions)”
public void PopulateChart(Chart chart, ChartType chartType, ChartAuthoringStyleOptions style)

Pulls marks from ChartGuru.ChartDataSourceBase.BuildMarksForChartType(ChartGuru.ChartType%2cChartGuru.ChartAuthoringStyleOptions) and replaces the element chart’s content with them. The active style override is set for the duration of the call so existing Get* helpers (e.g. GetCornerRadius) read the UITK element’s authoring instead of the (possibly null) _targetChart.

Parameters

Name Type
chart ChartGuru.Chart
chartType ChartGuru.ChartType
style ChartGuru.ChartAuthoringStyleOptions
protected List<ChartGraphic> ResolveTargetCharts()

Resolve target charts with the following priority:

  1. Explicit _targetChart (inspector-set) — just that one.
  2. ChartGraphic on same GameObject — just that one.
  3. All child ChartGraphic components that don’t have their own local ChartDataSourceBase.

Returns

System.Collections.Generic.List{ChartGuru.ChartGraphic}

public List<ChartGraphic> GetResolvedTargetCharts()

Public accessor for ChartGuru.ChartDataSourceBase.ResolveTargetCharts so editor tooling (Quick Sample buttons) can apply the sample’s chart type to the connected chart when there is exactly one — without forcing the user to also assign the inspector field.

Returns

System.Collections.Generic.List{ChartGuru.ChartGraphic}

protected List<IChart3DHost> ResolveTarget3DHosts()

Resolve 3D host targets for this data source. Priority:

  1. Explicit ChartGuru.ChartDataSourceBase._targetChart3D (must implement ChartGuru.IChart3DHost).
  2. Any component on the same GameObject implementing ChartGuru.IChart3DHost.
  3. Any ChartGuru.IChart3DHost in children that doesn’t have its own local data source. Returns an empty list when no host is present — safe to call on pure 2D hierarchies.

Returns

System.Collections.Generic.List{ChartGuru.IChart3DHost}

protected void RaiseDataChanged()

Fire ChartGuru.ChartDataSourceBase.DataChanged. Subclasses call this at the end of their ChartGuru.ChartDataSourceBase.ApplyData override.

BuildMarksForChartType(ChartType, ChartAuthoringStyleOptions)

Section titled “BuildMarksForChartType(ChartType, ChartAuthoringStyleOptions)”
public virtual List<IChartMark> BuildMarksForChartType(ChartType chartType, ChartAuthoringStyleOptions style)

Build marks shaped for the requested chartType and style. Default implementation returns an empty list; subclasses override to provide their data. The base class sets ChartGuru.ChartDataSourceBase._activeStyleOverride for the duration of the call so existing Get* helpers transparently pick up the UITK style.

Parameters

Name Type
chartType ChartGuru.ChartType
style ChartGuru.ChartAuthoringStyleOptions

Returns

System.Collections.Generic.List{ChartGuru.IChartMark}

public abstract void ApplyData()

Apply the configured data to the target chart. Subclasses must implement this to provide their specific data.

protected void ApplyDataImmediate()

Apply data immediately without EditorApplication.delayCall. Used during streaming to ensure chart and text labels update synchronously.

protected float GetCornerRadius()

Get the corner radius from the target chart (or active style override).

Returns

System.Single

protected MarkStackingMethod GetStackingMethod()

Get the stacking method from the target chart (or active style override).

Returns

ChartGuru.MarkStackingMethod

protected InterpolationMethod GetInterpolation()

Get the interpolation method from the target chart (or active style override).

Returns

ChartGuru.InterpolationMethod

protected float GetLineWidth()

Get the line width from the target chart (or active style override).

Returns

System.Single

protected float GetInnerRadius()

Get the donut inner radius from the target chart (or active style override).

Returns

System.Single

protected float GetAngularInset()

Get the sector pad angle from the target chart (or active style override).

Returns

System.Single

protected BarLayout? GetBarLayout()

Resolves the bar-layout override, preferring the active data-source style over the target chart.

Returns

System.Nullable{ChartGuru.BarLayout}

protected MarkDimension GetBarWidth()

Resolves bar width from the active style, then the target chart, falling back to automatic sizing.

Returns

ChartGuru.MarkDimension

protected MarkDimension GetBarHeight()

Resolves bar height from the active style, then the target chart, falling back to automatic sizing.

Returns

ChartGuru.MarkDimension

protected ForegroundStyleMode GetForegroundStyleMode()

Resolves the foreground-style mode from the active style or target chart, falling back to automatic selection.

Returns

ChartGuru.ForegroundStyleMode

protected float GetHeatMapCellPadding()

Resolves heat-map cell padding in pixels from the active style or chart authoring style, defaulting to zero.

Returns

System.Single

protected float GetHeatMapCornerRadius()

Resolves heat-map cell corner radius in pixels from the active style or chart authoring style, defaulting to zero.

Returns

System.Single

CreateSingleSeriesMarks(ChartType, List, string, Color)

Section titled “CreateSingleSeriesMarks(ChartType, List, string, Color)”
protected List<IChartMark> CreateSingleSeriesMarks(ChartType chartType, List<ChartDataEntry> dataPoints, string seriesName, Color primaryColor)

Create marks for single-series data.

Parameters

Name Type
chartType ChartGuru.ChartType
dataPoints System.Collections.Generic.List{ChartGuru.ChartDataEntry}
seriesName System.String
primaryColor UnityEngine.Color

Returns

System.Collections.Generic.List{ChartGuru.IChartMark}

protected List<IChartMark> CreateMultiSeriesMarks(ChartType chartType, List<ChartDataSeries> dataSeries)

Create marks for multi-series data.

Parameters

Name Type
chartType ChartGuru.ChartType
dataSeries System.Collections.Generic.List{ChartGuru.ChartDataSeries}

Returns

System.Collections.Generic.List{ChartGuru.IChartMark}

protected float ResolveXPosition(ChartDataEntry entry, int fallbackIndex)

Resolves x position from the supplied entry, and fallback index, applying configured fallbacks when no explicit value is available.

Parameters

Name Type
entry ChartGuru.ChartDataEntry
fallbackIndex System.Int32

Returns

System.Single

ResolveXPosition(ChartDataEntry, int, bool)

Section titled “ResolveXPosition(ChartDataEntry, int, bool)”
protected float ResolveXPosition(ChartDataEntry entry, int fallbackIndex, bool labelIsAmbiguous)

Resolves x position from the supplied entry, fallback index, and label is ambiguous, applying configured fallbacks when no explicit value is available.

Parameters

Name Type
entry ChartGuru.ChartDataEntry
fallbackIndex System.Int32
labelIsAmbiguous System.Boolean

Returns

System.Single

CreateMark(ChartType, float, float, string, Color, LinearGradientStyle)

Section titled “CreateMark(ChartType, float, float, string, Color, LinearGradientStyle)”
protected IChartMark CreateMark(ChartType chartType, float xValue, float value, string label, Color colorOverride, LinearGradientStyle gradientOverride)

Create a chart mark of the appropriate type.

Parameters

Name Type
chartType ChartGuru.ChartType
xValue System.Single
value System.Single
label System.String
colorOverride UnityEngine.Color
gradientOverride ChartGuru.LinearGradientStyle

Returns

ChartGuru.IChartMark

CreateMark(ChartType, float, float, string, Color, LinearGradientStyle, ChartDataEntry)

Section titled “CreateMark(ChartType, float, float, string, Color, LinearGradientStyle, ChartDataEntry)”
protected IChartMark CreateMark(ChartType chartType, float xValue, float value, string label, Color colorOverride, LinearGradientStyle gradientOverride, ChartDataEntry entry)

Overload that threads the originating ChartGuru.ChartDataEntry down to ChartGuru.ChartMarkFactory.CreateMark(ChartGuru.ChartType%2cSystem.Single%2cSystem.Single%2cSystem.String%2cUnityEngine.Color%2cChartGuru.LinearGradientStyle%2cChartGuru.ChartAuthoringStyleOptions%2cChartGuru.ChartDataEntry) so OHLC-bearing entries can be turned into real candlestick marks.

Parameters

Name Type
chartType ChartGuru.ChartType
xValue System.Single
value System.Single
label System.String
colorOverride UnityEngine.Color
gradientOverride ChartGuru.LinearGradientStyle
entry ChartGuru.ChartDataEntry

Returns

ChartGuru.IChartMark

protected ChartDataSourceBase()

public ChartGraphic TargetChart { get; set; }

The target ChartGraphic to populate. Setting this explicitly overrides hierarchy-based discovery.

Returns

ChartGuru.ChartGraphic

public Component TargetChart3D { get; set; }

Optional 3D host (e.g. Chart3DComponent). Set this when the data source lives alongside a 3D chart; the 2D and 3D targets can coexist so the same data source populates both views when a scene contains each.

Returns

UnityEngine.Component

public event Action DataChanged

Raised after ChartGuru.ChartDataSourceBase.ApplyData completes. Consumed primarily by the UI Toolkit pipeline (ChartGuruElement) to re-pull marks.

Returns

System.Action