ChartDataSourceBase
[ExecuteAlways]public abstract class ChartDataSourceBase : MonoBehaviour, IChartGuruElementDataSource, IChartDataSourceAbstract base class for chart data sources. Shared functionality for populating ChartGraphic with data.
Fields
Section titled “Fields”
_targetChart
Section titled “_targetChart”[Tooltip("Target ChartGraphic (2D) to populate. If null, discovers charts on same GameObject or in child hierarchy.")][SerializeField]protected ChartGraphic _targetChartReturns
ChartGuru.ChartGraphic
_targetChart3D
Section titled “_targetChart3D”[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 _targetChart3DReturns
UnityEngine.Component
Methods
Section titled “Methods”
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 |
ResolveTargetCharts()
Section titled “ResolveTargetCharts()”protected List<ChartGraphic> ResolveTargetCharts()Resolve target charts with the following priority:
- Explicit _targetChart (inspector-set) — just that one.
- ChartGraphic on same GameObject — just that one.
- All child ChartGraphic components that don’t have their own local ChartDataSourceBase.
Returns
System.Collections.Generic.List{ChartGuru.ChartGraphic}
GetResolvedTargetCharts()
Section titled “GetResolvedTargetCharts()”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}
ResolveTarget3DHosts()
Section titled “ResolveTarget3DHosts()”protected List<IChart3DHost> ResolveTarget3DHosts()Resolve 3D host targets for this data source. Priority:
- Explicit
ChartGuru.ChartDataSourceBase._targetChart3D(must implement ChartGuru.IChart3DHost). - Any component on the same GameObject implementing ChartGuru.IChart3DHost.
- 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}
RaiseDataChanged()
Section titled “RaiseDataChanged()”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}
ApplyData()
Section titled “ApplyData()”public abstract void ApplyData()Apply the configured data to the target chart. Subclasses must implement this to provide their specific data.
ApplyDataImmediate()
Section titled “ApplyDataImmediate()”protected void ApplyDataImmediate()Apply data immediately without EditorApplication.delayCall. Used during streaming to ensure chart and text labels update synchronously.
GetCornerRadius()
Section titled “GetCornerRadius()”protected float GetCornerRadius()Get the corner radius from the target chart (or active style override).
Returns
System.Single
GetStackingMethod()
Section titled “GetStackingMethod()”protected MarkStackingMethod GetStackingMethod()Get the stacking method from the target chart (or active style override).
Returns
ChartGuru.MarkStackingMethod
GetInterpolation()
Section titled “GetInterpolation()”protected InterpolationMethod GetInterpolation()Get the interpolation method from the target chart (or active style override).
Returns
ChartGuru.InterpolationMethod
GetLineWidth()
Section titled “GetLineWidth()”protected float GetLineWidth()Get the line width from the target chart (or active style override).
Returns
System.Single
GetInnerRadius()
Section titled “GetInnerRadius()”protected float GetInnerRadius()Get the donut inner radius from the target chart (or active style override).
Returns
System.Single
GetAngularInset()
Section titled “GetAngularInset()”protected float GetAngularInset()Get the sector pad angle from the target chart (or active style override).
Returns
System.Single
GetBarLayout()
Section titled “GetBarLayout()”protected BarLayout? GetBarLayout()Resolves the bar-layout override, preferring the active data-source style over the target chart.
Returns
System.Nullable{ChartGuru.BarLayout}
GetBarWidth()
Section titled “GetBarWidth()”protected MarkDimension GetBarWidth()Resolves bar width from the active style, then the target chart, falling back to automatic sizing.
Returns
ChartGuru.MarkDimension
GetBarHeight()
Section titled “GetBarHeight()”protected MarkDimension GetBarHeight()Resolves bar height from the active style, then the target chart, falling back to automatic sizing.
Returns
ChartGuru.MarkDimension
GetForegroundStyleMode()
Section titled “GetForegroundStyleMode()”protected ForegroundStyleMode GetForegroundStyleMode()Resolves the foreground-style mode from the active style or target chart, falling back to automatic selection.
Returns
ChartGuru.ForegroundStyleMode
GetHeatMapCellPadding()
Section titled “GetHeatMapCellPadding()”protected float GetHeatMapCellPadding()Resolves heat-map cell padding in pixels from the active style or chart authoring style, defaulting to zero.
Returns
System.Single
GetHeatMapCornerRadius()
Section titled “GetHeatMapCornerRadius()”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}
CreateMultiSeriesMarks(ChartType, List)
Section titled “CreateMultiSeriesMarks(ChartType, List)”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}
ResolveXPosition(ChartDataEntry, int)
Section titled “ResolveXPosition(ChartDataEntry, int)”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
Constructors
Section titled “Constructors”
ChartDataSourceBase()
Section titled “ChartDataSourceBase()”protected ChartDataSourceBase()Properties
Section titled “Properties”
TargetChart
Section titled “TargetChart”public ChartGraphic TargetChart { get; set; }The target ChartGraphic to populate. Setting this explicitly overrides hierarchy-based discovery.
Returns
ChartGuru.ChartGraphic
TargetChart3D
Section titled “TargetChart3D”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
Events
Section titled “Events”
DataChanged
Section titled “DataChanged”public event Action DataChangedRaised after ChartGuru.ChartDataSourceBase.ApplyData completes. Consumed primarily by
the UI Toolkit pipeline (ChartGuruElement) to re-pull marks.
Returns
System.Action