private ActionResult SimplePieChart(string title, string seriesName, ICollection <Tuple <string, int> > points) { Response.Cache.SetCacheability(HttpCacheability.Public); Response.Cache.SetMaxAge(TimeSpan.FromDays(1)); Response.Cache.SetSlidingExpiration(true); return(LowercaseJson(HighchartsHelper.SimplePieChart(title, seriesName, points, false))); }
private ActionResult DateLineChartWithAverage(string title, string pointsTitle, string yAxisTitle, ICollection <Tuple <DateTime, int> > points, bool average = true) { Response.Cache.SetCacheability(HttpCacheability.Public); Response.Cache.SetMaxAge(TimeSpan.FromDays(1)); Response.Cache.SetSlidingExpiration(true); return(LowercaseJson(HighchartsHelper.DateLineChartWithAverage(title, pointsTitle, yAxisTitle, points, average))); }
public ActionResult ScorePerSongOverTime(DateTime?cutoff) { var data = queries.ScorePerSongOverTime(cutoff); var dataSeries = data.Select(ser => new Series { Name = ser.Entry.Name.English, Data = Series.DateData(ser.Data.CumulativeSumContract()) }).ToArray(); return(LowercaseJson(HighchartsHelper.DateLineChart("Score per song over time", "Songs", "Score", dataSeries))); }
private ActionResult SimplePieChart(string title, string seriesName, ICollection <Tuple <string, int> > points) { Response.GetTypedHeaders().CacheControl = new CacheControlHeaderValue { Public = true, MaxAge = TimeSpan.FromDays(1), }; // TODO: implement Response.Cache.SetSlidingExpiration(true); return(LowercaseJson(HighchartsHelper.SimplePieChart(title, seriesName, points, false))); }
private ActionResult DateLineChartWithAverage(string title, string pointsTitle, string yAxisTitle, ICollection <Tuple <DateTime, int> > points, bool average = true) { Response.GetTypedHeaders().CacheControl = new CacheControlHeaderValue { Public = true, MaxAge = TimeSpan.FromDays(1), }; // TODO: implement Response.Cache.SetSlidingExpiration(true); return(LowercaseJson(HighchartsHelper.DateLineChartWithAverage(title, pointsTitle, yAxisTitle, points, average))); }
public ActionResult Index() { var helper = new HighchartsHelper(); var model = new HomeIndexViewModel(); model.Chart = new[] { helper.GetTemperatureChart(), helper.GetEnergyChart(), helper.GetLightChart(), helper.GetHumidityChart() }; return(View(model)); }
public ActionResult Index() { var helper = new HighchartsHelper(); var model = new HomeIndexViewModel(); model.Chart =new[] { helper.GetTemperatureChart(), helper.GetEnergyChart(), helper.GetLightChart(), helper.GetHumidityChart() }; return View(model); }
public static object[][] DateData <T>(IEnumerable <T> source, Func <T, DateTime> dateSelector, Func <T, int> valSelector) { return(source.Select(p => new object[] { HighchartsHelper.ToEpochTime(dateSelector(p)), valSelector(p) }).ToArray()); }
public ActionResult Stats_EditsPerDay(int id) { var points = new ActivityEntryQueries(repository).GetEditsPerDay(id, null); return(LowercaseJson(HighchartsHelper.DateLineChartWithAverage("Edits per day", "Edits", "Number of edits", points))); }
public ActionResult ScorePerSongOverTime(DateTime?cutoff) { var data = repository.HandleQuery(ctx => { var topSongIds = ctx.Query <FavoriteSongForUser>() .Where(s => !s.Song.Deleted && s.Song.PublishDate.DateTime != null) .FilterIfNotNull(cutoff, s => s.Song.PublishDate.DateTime > cutoff) .GroupBy(s => new { SongId = s.Song.Id, }) .Select(s => new { s.Key.SongId, TotalCount = s.Sum(s2 => (int)s2.Rating) }) .OrderByDescending(s => s.TotalCount) .Take(20) .ToArray() .Select(s => s.SongId) .ToArray(); // Note: the same song may be included multiple times for different artists var points = ctx.Query <FavoriteSongForUser>() .Where(s => topSongIds.Contains(s.Song.Id)) .OrderBy(a => a.Date.Year) .ThenBy(a => a.Date.Month) .ThenBy(a => a.Date.Day) .GroupBy(s => new { Year = s.Date.Year, Month = s.Date.Month, Day = s.Date.Day, SongId = s.Song.Id, }) .Select(s => new { s.Key.Year, s.Key.Month, s.Key.Day, s.Key.SongId, Count = s.Sum(s2 => (int)s2.Rating) }) .ToArray() .Select(s => new { s.SongId, Data = new CountPerDayContract(s.Year, s.Month, s.Day, s.Count), }) .ToArray(); var songs = GetSongsWithNames(ctx, topSongIds); var bySong = points.GroupBy(p => p.SongId).Select(p => new EntryWithIdAndData <LocalizedValue> { Id = p.Key, Entry = songs[p.Key], Data = p.Select(d => d.Data).ToArray().AddPreviousValues(true, TimeUnit.Day, DateTime.Now).ToArray() }).OrderByIds(topSongIds); return(bySong); }); var dataSeries = data.Select(ser => new Series { Name = ser.Entry.Name.English, Data = Series.DateData(ser.Data.CumulativeSumContract()) }).ToArray(); return(LowercaseJson(HighchartsHelper.DateLineChart("Score per song over time", "Songs", "Score", dataSeries))); }