XData to Chart

Hello I have been experimenting on charting some data from a database to a web form but have run into issues.


First, reading the documentation the 'Addressing Single Entity' does not seem to work. Accordingly the URL should work: https://app.devgems.com/music/Artist(3). Also the online TMS demo single entity returns null as well.

Using the XData guides I've managed to get data in the form of:
{"@xdata.type":"XData.Default.SeriesData","SeriesNo":705,"SeriesDate":41820,"SeriesValue":2829.5}

Which is the first element of a TJSArray. Is there a way I can easily extract all the "SeriesDate" and "SeriesValue" of this TJSArray and plot it in FNCChart/Any other charting packages?

Addressing Single Entity works as expected. If there is not artist with the specific id ("3" in this case), it will return null. If you change "3" by "50" for example, it returns a value (at the time I'm writing this answer - it might change if someone deletes it).


Regarding series, you just need to return a json array and set it to the chart or any other control. How you have managed to return the SeriesData? If you are using entity publishing, just use the endpoint that returns array of SeriesData. If you are using service operations, return a List<TSeriesData>.

Thank you, I confused $id with the key 'Id'.


I'm now looking through the XDataWebClientDemo source code and documentation and it seems entity publishing seems the easiest method for my uses. However I'm not quite sure how to get the endpoint from for example (https://app.devgems.com/music/Artist(6)/Name/$value) into Delphi using XDataWebClient or must I go through Response.Result.

Having discovered WebHttpRequest this answers my previous question in a simple way of accessing data and inserting it into a FNC Chart.


procedure TForm2.WebButton1Click(Sender: TObject);
begin
WebHttpRequest1.Execute;
end;

procedure TForm2.WebHttpRequest1Response(Sender: TObject; AResponse: string);
begin
  TMSFNCChart1.Series.Items[0].AddPoint(strtofloat(AResponse));
end;


As you can see above I have hard coded a date to get a single SeriesValue for now, could you point me towards some solutions to get a full plot going. I am thinking obtaining arrays of SeriesDate and SeriesValue only but unsure of how to implement that. Furthermore is it possible to index through rather than specify the key?
The endpoint http://localhost:8000/tms/xdata/SeriesData holds all values for all series. You can use filters to get what you want, e.g.:


http://localhost:8000/tms/xdata/SeriesData?$filter=(SeriesNo eq 705) and (SeriesData ge 2019-01-31) and (SeriesData lt 2019-02-01)


The above URL will retrieve all data from series number 705 between 01 Jan 2019 and 31 Jan 2019.
The AResponse will have a string with a JSON array of all values:


var
  Data: TJSArray;
begin
  Data := TJSArray(TJSJson.parse(AResponse));
end;