LINQPad can plot the line graph using anonymous arrays. I do have JSON content with datetime (entrytime) and numerical value (cumulative gains). How can I adapt LINQPad to chart the JSON content?
void Main()
{
// You can optionally specify a series type such as Pie, Area, Spline, etc.:
var customers = new[]
{
new { Name = "John", TotalOrders = 100 },
new { Name = "Mary", TotalOrders = 130 },
new { Name = "Sara", TotalOrders = 140 },
new { Name = "Paul", TotalOrders = 125 },
};
customers.Chart(c => c.Name, c => c.TotalOrders, Util.SeriesType.Line).Dump();
string json = "[\r\n {\r\n \"entryTime\": \"2019-01-08T00:00:01\",\r\n \"gains\": -0.00071,\r\n \"cumulativegains\": -0.00071\r\n },\r\n {\r\n \"entryTime\": \"2019-01-08T05:00:01\",\r\n \"gains\": -0.00102,\r\n \"cumulativegains\": -0.00102\r\n },\r\n {\r\n \"entryTime\": \"2019-01-08T09:00:01\",\r\n \"gains\": -0.00113,\r\n \"cumulativegains\": -0.00113\r\n },\r\n {\r\n \"entryTime\": \"2019-01-08T10:31:19\",\r\n \"gains\": -0.00236,\r\n \"cumulativegains\": -0.00236\r\n },\r\n {\r\n \"entryTime\": \"2019-01-09T20:21:34\",\r\n \"gains\": -0.00262,\r\n \"cumulativegains\": -0.00262\r\n },\r\n {\r\n \"entryTime\": \"2019-01-11T16:00:01\",\r\n \"gains\": -0.00075,\r\n \"cumulativegains\": -0.00075\r\n },\r\n ]";
json.Dump();
List<trades2plot> jsonData = JsonConvert.DeserializeObject<List<trades2plot>>(json);
jsonData.Dump();
}
public class trades2plot
{
//public int TradeNumber;
//public DateTime initializedTime;
public DateTime entryTime;
//public DateTime exitTime;
public double gains;
public double cumulativegains;
public trades2plot() { }
}
// You can define other methods, fields, classes and namespaces here
jsonData.Chart(c=>c.entryTime,c=>c.cumulativegains, Util.SeriesType.Line).Dump();
will enable plotting it as a line chart from JSON.