Skip to content

IChartGuruElementDataSource

InterfaceChartGuruChartGuru
public interface IChartGuruElementDataSource

Contract every data source implements when it wants to feed a ChartGuru.ChartGuruElement in the UI Toolkit pipeline.

Two responsibilities:

  1. `ChartGuru.IChartGuruElementDataSource.PopulateChart(ChartGuru.Chart%2cChartGuru.ChartType%2cChartGuru.ChartAuthoringStyleOptions)` — push the current data set into the supplied [ChartGuru.Chart](/tools/chartguru/api/chartguru-chart/), shaped for the given chart type and authoring style. Implementations should clear existing marks before adding new ones (the element doesn't.)
  2. `ChartGuru.IChartGuruElementDataSource.DataChanged` — raised whenever the source's data mutates (inspector edit, streaming tick, ViewModel notification…). The element subscribes to this and re-pulls data without further coordination.

Implemented by [ChartGuru.ChartDataSourceAsset](/tools/chartguru/api/chartguru-chartdatasourceasset/) (ScriptableObject path) and [ChartGuru.ChartDataSourceBase](/tools/chartguru/api/chartguru-chartdatasourcebase/) (MonoBehaviour path). Custom sources — streaming network feeds, ViewModels, etc. — can implement it directly.

PopulateChart(Chart, ChartType, ChartAuthoringStyleOptions)

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

Push the current data set onto chart. The data source is responsible for clearing existing marks and adding new ones that match chartType. The supplied style snapshot lets the source pick mark-level properties (line width, bar corner radius, stacking method, …) consistently with the element’s authoring state.

Parameters

Name Type Description
chart ChartGuru.Chart The element’s underlying chart instance.
chartType ChartGuru.ChartType The chart type currently authored on the element.
style ChartGuru.ChartAuthoringStyleOptions Authoring style snapshot from the element. Never null.

event Action DataChanged

Raised whenever the source’s data set changes and consumers should call ChartGuru.IChartGuruElementDataSource.PopulateChart(ChartGuru.Chart%2cChartGuru.ChartType%2cChartGuru.ChartAuthoringStyleOptions) again. May fire on any thread that mutates the source; implementations should ensure they only marshal back to the main thread before invoking it.

Returns

System.Action