Skip to content

JsonChartDataSource

ClassChartGuruChartGuru
public sealed class JsonChartDataSource : ChartFileDataSource

Reads JSON from a TextAsset, project file, absolute path, StreamingAssets file, or an inline string and converts it to chart marks. Supports a JSONPath 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

NameType
jsonTextSystem.String
public void LoadAsset(TextAsset asset)

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

Parameters

NameType
assetUnityEngine.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 ChartTabularData. Implemented per source (CSV vs JSON).

Parameters

NameType
rawTextSystem.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