Skip to content

CsvChartDataSource

ClassChartGuruChartGuru
[AddComponentMenu("ChartGuru/Data Sources/CSV Chart Data Source")]
[DisallowMultipleComponent]
public sealed class CsvChartDataSource : ChartFileDataSourceBase, IChartGuruElementDataSource, IChartDataSource

Reads CSV (or any separated-values text) from a TextAsset, project file, absolute path, StreamingAssets file, or inline string and pushes it to one or more target charts. Auto-detects delimiter, header row, and column types — but everything is overridable in the inspector.

Optionally watches the source file with a FileSystemWatcher (Editor-only by default; opt-in at runtime via `ChartGuru.CsvChartDataSource.WatchFileAtRuntime`).

protected override string LoadText()

Subclasses override to obtain the raw text payload synchronously. Return an empty string to signal “no data”.

Returns

System.String

protected override ChartTabularData ParseToTabular(string rawText)

Convert raw text to a ChartGuru.ChartTabularData. Implemented per source (CSV vs JSON).

Parameters

Name Type
rawText System.String

Returns

ChartGuru.ChartTabularData

public void LoadFromText(string csvText)

Set inline CSV text and immediately refresh. Convenience shortcut for SourceMode = InlineText; InlineText = …; Refresh();.

Parameters

Name Type
csvText System.String
public void LoadAsset(TextAsset asset)

Set a TextAsset source and immediately refresh. Convenience shortcut for SourceMode = TextAsset; TextAsset = …; Refresh();.

Parameters

Name Type
asset UnityEngine.TextAsset
public bool AutoDetectFormat()

Read the configured source, auto-detect a sensible delimiter and header mode, and write the results into _delimiterOverride / _headerMode. Designed for the inspector “Auto Detect Format” button — call once after picking a file to lock in explicit values instead of relying on per-parse auto-detection (which can flip between commits when data changes).

Returns

System.Boolean: True when detection succeeded and at least one field was updated.

public CsvChartDataSource()

public ChartFileSourceMode SourceMode { get; set; }

Returns

ChartGuru.ChartFileSourceMode

public TextAsset TextAsset { get; set; }

Returns

UnityEngine.TextAsset

public string ProjectPath { get; set; }

Returns

System.String

public string AbsolutePath { get; set; }

Returns

System.String

public string StreamingAssetsPath { get; set; }

Returns

System.String

public string InlineText { get; set; }

Returns

System.String

public bool WatchFileAtRuntime { get; set; }

Toggle runtime file watching. Disposes the watcher when set to false.

Returns

System.Boolean