private void DrawPointChart(List <TaskStatistic> Statistic) { var entries = new List <Microcharts.Entry>(); var DayGroup = Statistic.GroupBy(u => u.FinishedTime.Day).ToDictionary(x => x.Key, x => x.ToList()); foreach (var group in DayGroup) { var value = group.Value.Count; var day = group.Value[0].FinishedTime.Day; var entry = new Microcharts.Entry(value) { Label = group.Key.ToString(), ValueLabel = value.ToString(), Color = SKColor.Parse(ColorPickService.NextReverse()) }; entries.Add(entry); } WeeklyPointChart = new Microcharts.PointChart() { IsAnimated = false, LabelTextSize = 25, LabelOrientation = Orientation.Horizontal, ValueLabelOrientation = Orientation.Horizontal, PointSize = 25, Entries = entries, BackgroundColor = SkiaSharp.SKColors.Transparent, Margin = 15, }; }
public NewTaskPageViewModel() { Id = Guid.NewGuid(); Title = "New Task"; Frequencies = new ObservableCollection <string>(Enum.GetNames(typeof(GoalFrequency)).ToList()); GoalFrequency = Frequencies.ElementAt(0); TaskColor = ColorPickService.GetRandom(); Colors = new ObservableCollection <string>(ColorPickService.Colors); SaveCommand = new Command( execute: async(o) => { if (IsBusy) { return; } IsBusy = true; var userTask = CreateUserTask(); if (userTask != null) { MessagingCenter.Send(this, AppMessages.SaveUserTaskMessage, userTask); await Page.Navigation.PopModalAsync(); } IsBusy = false; } ); }
public static UserTask CreateUserTask() { var userTaskVMList = new List <UserTaskViewModel>(); bool haveGoal = false; var intervals = Enum.GetValues(typeof(GoalFrequency)) .Cast <GoalFrequency>() .Select(v => v.ToString()) .ToList(); haveGoal = !haveGoal; int GoalPomodoroCount = 0; int frequncyIndex = Random.Next(0, intervals.Count - 1); int FinishedPomodoroCount = Random.Next(0, 5 * (frequncyIndex + 3)); if (haveGoal) { GoalPomodoroCount = Random.Next(5 * (frequncyIndex + 1), 5 * (frequncyIndex + 3)); } UserTask userTask = new UserTask() { Id = Guid.NewGuid(), TaskName = "Task" + ++createdTaskCount, TaskColor = ColorPickService.GetRandom(), TaskStatistic = new FinishedTaskStatistic() { DailyFinishedCount = FinishedPomodoroCount, MonthlyFinishedCount = FinishedPomodoroCount, WeeklyFinishedCount = FinishedPomodoroCount, YearlyFinishedCount = FinishedPomodoroCount, }, TaskGoal = new TaskGoal() { GoalInterval = (GoalFrequency)frequncyIndex, PomodoroCount = GoalPomodoroCount, }, }; return(userTask); }
private void DrawDonutChart(List <TaskStatistic> statistics) { var entries = new List <Microcharts.ChartEntry>(); Dictionary <Guid, (int count, string name)> taskDictionary = new Dictionary <Guid, (int count, string name)>(); foreach (var statistic in statistics) { if (!taskDictionary.ContainsKey(statistic.TaskId)) { taskDictionary[statistic.TaskId] = (count : 1, name : statistic.TaskName); } else { taskDictionary[statistic.TaskId] = (count : taskDictionary[statistic.TaskId].count + 1, name : taskDictionary[statistic.TaskId].name); } } foreach (var item in taskDictionary) { var entry = new Microcharts.ChartEntry(item.Value.count) { Label = item.Value.name, ValueLabel = item.Value.count.ToString(), Color = SKColor.Parse(ColorPickService.GetRandom()), }; entries.Add(entry); } TaskDonutChart = new Microcharts.DonutChart() { IsAnimated = true, AnimationDuration = TimeSpan.FromMilliseconds(300), LabelTextSize = 25, Entries = entries, BackgroundColor = SkiaSharp.SKColors.Transparent, Margin = 10, }; }
public static List <UserTaskViewModel> CreateUserTaskVM(int count) { var userTaskVMList = new List <UserTaskViewModel>(); bool haveGoal = false; var intervals = Enum.GetValues(typeof(GoalFrequency)) .Cast <GoalFrequency>() .Select(v => v.ToString()) .ToList(); var random = new Random(); for (int i = 1; i <= count; i++) { haveGoal = !haveGoal; int GoalPomodoroCount = 0; int frequncyIndex = random.Next(0, intervals.Count - 1); int FinishedPomodoroCount = random.Next(0, 5 * (frequncyIndex + 3)); if (haveGoal) { GoalPomodoroCount = random.Next(5 * (frequncyIndex + 1), 5 * (frequncyIndex + 3)); } var a = new UserTaskViewModel() { FinishedPomodoroCount = FinishedPomodoroCount, GoalPomodoroCount = GoalPomodoroCount, HaveGoal = haveGoal, GoalInterval = intervals[frequncyIndex], IsGaolAchived = FinishedPomodoroCount >= GoalPomodoroCount, TaskName = "Task" + i, TaskColor = ColorPickService.NextRandom(), }; userTaskVMList.Add(a); } return(userTaskVMList); }
private void DrawPointChart(List <TaskStatistic> statistics) { var dayGroup = statistics.GroupBy(u => u.FinishedTime.Day) .ToDictionary(x => x.Key, x => x.ToList().Count()); //fill zero for days that has no statistic for (int i = StartDay.Day; i <= FinishDay.Day; i++) { if (!dayGroup.ContainsKey(i)) { dayGroup[i] = 0; } } var entries = dayGroup.OrderBy(x => x.Key) .Select(x => { return(new Microcharts.ChartEntry(x.Value) { Label = x.Key.ToString(), ValueLabel = x.Value.ToString(), Color = SKColor.Parse(ColorPickService.GetByKey(x.Key)), TextColor = SKColor.Parse(ColorPickService.GetByKey(x.Key)) }); }); PointChart = new Microcharts.PointChart() { IsAnimated = false, LabelTextSize = 25, LabelOrientation = Orientation.Vertical, ValueLabelOrientation = Orientation.Vertical, PointSize = 25, Entries = entries, BackgroundColor = SkiaSharp.SKColors.Transparent, Margin = 15, }; }
public NewTaskPageViewModel() { Id = Guid.NewGuid(); Colors = new ObservableCollection <string> { "#0D47A1", "#1F77B4", "#AEC7E8", "#DD2C00", "#FF7F0E", "#FFBB78", "#1B5E20", "#2CA02C", "#98DF8A", "#C51162", "#D50000", "#D62728", "#FF9896", "#4A148C", "#9467BD", "#C5B0D5", "#8C564B", "#C49C94", "#3E2723", "#795548", "#E377C2", "#F7B6D2", "#7F7F7F", "#AEEA00", "#BCBD22", "#DBDB8D", "#17BECF", "#9EDAE5", "#78909C", }; Title = "New Task"; Frequencies = new ObservableCollection <string>(Enum.GetNames(typeof(GoalFrequency)).ToList()); GoalFrequency = Frequencies.ElementAt(0); TaskColor = ColorPickService.NextRandom(); SaveCommand = new Command( execute: async(o) => { if (IsBusy) { return; } IsBusy = true; var userTask = CreateUserTask(); if (userTask != null) { MessagingCenter.Send(this, AppMessages.SaveUserTaskMessage, userTask); await Page.Navigation.PopModalAsync(); } IsBusy = false; } ); }