Skip to content

JsonChartDataSource

ClassChartGuruChartGuru
public sealed class JsonChartDataSource : ChartFileDataSourceBase, IChartGuruElementDataSource, IChartDataSource

Reads JSON from a TextAsset, project file, absolute path, StreamingAssets file, or an inline string and converts it to chart marks. Supports a JSONPath ChartGuru.JsonChartDataSource.RootSelector so deeply nested API responses (eg. $.data.timeseries[*]) can target the array of records directly.

Backed by Newtonsoft.Json (already shipped with Unity via com.unity.nuget.newtonsoft-json). Nested objects flatten one level with dot notation (ohlc.open), so financial-style payloads do not need pre-processing.

public void LoadFromText(string jsonText)

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

Parameters

Name Type
jsonText 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
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 JsonChartDataSource()

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 string RootSelector { get; set; }

Returns

System.String