Skip to content

WebChartDataSource

ClassChartGuruChartGuru
public class WebChartDataSource : ChartFileDataSource

Polls an HTTP/HTTPS endpoint on a configurable interval, decodes the response as CSV or JSON, and pushes the result through the standard mapping pipeline. Includes:

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 Task<ChartFileDataSource.ChartTextPayload> LoadPayloadAsync(CancellationToken ct)

Loads one immutable response payload. Network sources can attach response metadata here.

Parameters

NameType
ctSystem.Threading.CancellationToken

Returns

System.Threading.Tasks.Task{ChartGuru.ChartFileDataSource.ChartTextPayload}

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

protected override ChartTabularData ParsePayloadToTabular(ChartFileDataSource.ChartTextPayload payload)

Parses one response payload without relying on mutable shared response state.

Parameters

NameType
payloadChartGuru.ChartFileDataSource.ChartTextPayload

Returns

ChartGuru.ChartTabularData

protected virtual ChartTabularData ParseResponse(string rawText, string contentType)

Parses one immutable HTTP response and its matching content type.

Parameters

NameType
rawTextSystem.String
contentTypeSystem.String

Returns

ChartGuru.ChartTabularData

public override void Refresh()

Queues an asynchronous fetch, because WebChartDataSource.LoadText() cannot return a network body synchronously. In edit mode nothing is fetched unless edit-mode polling is enabled, so saving or reloading a scene never triggers silent requests.

public void Load(string url)

Set a URL and immediately fetch. Convenience shortcut for Url = …; Refresh();.

Parameters

NameType
urlSystem.String
public void ForceFetch()

Unconditional fetch — bypasses the WebChartDataSource.RunInEditMode guard. Used by the inspector “Fetch Now” button so the user can always pull fresh data on demand.

public void SetRuntimeHeader(string headerName, string value)

Adds or updates a header whose value exists only in memory for this component instance.

Parameters

NameType
headerNameSystem.String
valueSystem.String
public void ClearRuntimeHeaderValues()

Clears all nonserialized runtime header values.

protected override void OnRefreshSucceeded()

Called on the Unity thread after a successful refresh.

protected override void OnRefreshFailed(Exception exception)

Called on the Unity thread after a failed refresh.

Parameters

NameType
exceptionSystem.Exception

public WebChartDataSource()

public string Url { get; set; }

Returns

System.String

public List<WebChartDataSource.HttpHeader> Headers { get; }

Returns

System.Collections.Generic.List{ChartGuru.WebChartDataSource.HttpHeader}

public WebDataFormat Format { get; set; }

Returns

ChartGuru.WebDataFormat

public string JsonRootSelector { get; set; }

Returns

System.String

public float PollIntervalSeconds { get; set; }

Returns

System.Single

public bool RunInEditMode { get; set; }

Returns

System.Boolean

protected override bool AutoApplyInEditMode { get; }

Whether this source should populate an edit-mode preview when enabled.

Returns

System.Boolean