I am trying to do some charting in LinqPad. I have some logs from an api and i know, what api was called and if the request was cached (in our real case we resolve address with coordinates from bing api or we get addres from cache table if we have cached it)
i use this linqpad script:
var startDate = new DateTime(2019, 1,1);
var Requests = new[]
{
new {Date=startDate, Name = "Api1", Cached=true },
new {Date=startDate, Name = "Api2", Cached=true },
new {Date=startDate, Name = "Api3", Cached=true },
new {Date=startDate, Name = "Api1", Cached=true },
new {Date=startDate, Name = "Api1", Cached=false },
new {Date=startDate, Name = "Api2", Cached=false },
new {Date=startDate, Name = "Api3", Cached=false },
new {Date=startDate, Name = "Api1", Cached=false },
new {Date=startDate.AddDays(1), Name = "Api3", Cached=true },
new {Date=startDate.AddDays(1), Name = "Api1", Cached=false },
new {Date=startDate.AddDays(1), Name = "Api2", Cached=true },
new {Date=startDate.AddDays(1), Name = "Api2", Cached=false },
new {Date=startDate.AddDays(1), Name = "Api1", Cached=true },
new {Date=startDate.AddDays(1), Name = "Api1", Cached=false },
new {Date=startDate.AddDays(1), Name = "Api3", Cached=true },
};
Requests.GroupBy(x=>x.Date).Chart (c => c.Key)
.AddYSeries (c => c.Count(x=>x.Name=="Api1"),name:"Api1")
.AddYSeries (c => c.Count(x=>x.Name=="Api2"),name:"Api2")
.AddYSeries (c => c.Count(x=>x.Name=="Api3"),name:"Api3")
.AddYSeries (c => c.Count(x=>x.Name=="Api1" && x.Cached),name: "Api1 Cached")
.AddYSeries (c => c.Count(x=>x.Name=="Api2" && x.Cached),name: "Api2 Cached")
.AddYSeries (c => c.Count(x=>x.Name=="Api3" && x.Cached),name: "Api3 Cached")
.Dump();
That is the result:
Actually i want to have only 3, columns per day but they have to be slacked (to show in one column both total and cached values)
if i switch to SlackedColumns i have all values in one column together and is not what i want:
Any ideas, how to do it?
Update:
What i want is something like this (but i prefer, that it is grouped on date, like linqpad is doing that):