public void RecreateData(Points points, IEnumerable <MapLogData> logrecords, IEnumerable <Exercise> exercises, DateTime date) { BindingContext = points; SelectedDate = date; for (int i = 0; i < groupedItems.Count; i++) { groupedItems[i].Clear(); } groupedItems.Clear(); Group group = new Group(Properties.LangResource.breakfast + ": " + points.Breakfast, "1", "lock.png"); groupedItems.Add(group); group = new Group(Properties.LangResource.lunch + ": " + points.Lunch, "2", "lock.png"); groupedItems.Add(group); group = new Group(Properties.LangResource.dinner + ": " + points.Dinner, "3", "lock.png"); groupedItems.Add(group); group = new Group(Properties.LangResource.snack + ": " + points.Snack, "4", "lock.png"); groupedItems.Add(group); group = new Group(Properties.LangResource.water + ": 0", "5", "lock.png"); groupedItems.Add(group); group = new Group(Properties.LangResource.exercise + ": " + points.Exercise, "6", "lock.png"); groupedItems.Add(group); foreach (MapLogData logrecord in logrecords) { Item item = new Item(logrecord.MealName, PointSystem.PointCalculate(logrecord.Calories).ToString(), logrecord.IDUserMeal, logrecord.IDCategory, false); groupedItems[logrecord.IDCategory - 1].Add(item); } foreach (Exercise exercise in exercises) { Item item = new Item(Properties.LangResource.exercise, PointSystem.PointExerciseCalculate(exercise.Minutes).ToString(), exercise.IDExercise, 6, false); groupedItems[5].Add(item); } }
private void MealDetails() { MapMealUnit mealUnitmap = (MapMealUnit)unitPicker.SelectedItem; double counter = ((Counter)counter1Picker.SelectedItem).Value + ((Counter)counter2Picker.SelectedItem).Value; Calories.Text = (counter * mealUnitmap.Calories).ToString(); Fats.Text = (counter * mealUnitmap.Fat).ToString(); UnSatFats.Text = (counter * mealUnitmap.UnSatFat).ToString(); SatFats.Text = (counter * mealUnitmap.UnSatFat).ToString(); SatFats.Text = (counter * mealUnitmap.UnSatFat).ToString(); Protein.Text = (counter * mealUnitmap.Protein).ToString(); Fiber.Text = (counter * mealUnitmap.Fiber).ToString(); Natrium.Text = (counter * mealUnitmap.Natrium).ToString(); Potassium.Text = (counter * mealUnitmap.Potassium).ToString(); Carbs.Text = (counter * mealUnitmap.UnSatFat).ToString(); Cholesterol.Text = (counter * mealUnitmap.Cholesterol).ToString(); Sugars.Text = (counter * mealUnitmap.Sugar).ToString(); Points.Text = PointSystem.PointCalculate(counter * mealUnitmap.Calories).ToString(); }
public void FillPieContent(Dictionary <int, double> DashboardDic, double Total, IEnumerable <MapLogData> maplogs) { string data = ""; string label = ""; foreach (KeyValuePair <int, Double> entry in DashboardDic) { data += PointSystem.PointCalculate(entry.Value) + ","; label += GetLabelCategory(entry.Key) + ","; } data = data.Remove(data.Length - 1); label = label.Remove(label.Length - 1); string Wdata = ""; string Wlabel = ""; foreach (MapLogData maplog in maplogs) { Wdata += PointSystem.PointCalculate(maplog.Calories) + ","; Wlabel += "\"" + maplog.MealDate.DayOfWeek + "\"" + ","; } if (Wdata.Length > 0) { Wdata = Wdata.Remove(Wdata.Length - 1); Wlabel = Wlabel.Remove(Wlabel.Length - 1); } string web1 = "<!doctype html>" + "<html>" + "<head> " + "<script src=\"file:///android_asset/Chart.bundle.js\"></script>" + "<script src=\"file:///android_asset/utils.js\"></script>" + "</head>" + "<body>" + "<div style=\"margin:0 auto;width: 70%\" id=\"canvas - holder\">" + "<canvas id=\"chart - area\" />" + "</div>" + "<div style=\"width: 100%; \">" + "<canvas id=\"canvas\"></canvas> " + "</div>" + "<script>" + "var data = [" + data + "];" + "var config = {" + " type: 'pie', data: { datasets: [{ " + " data: data, backgroundColor: [window.chartColors.blue, window.chartColors.yellow, window.chartColors.orange, window.chartColors.green], " + " label: " + " 'Calories' }]," + " labels: [" + label + "] }, options: {legend: {position: 'bottom'} ,title: {display: true, text: 'Points per meal' } }}; " + "var color = Chart.helpers.color; " + "var barChartData = { " + "labels: [" + Wlabel + "], " + "datasets: [{ type: \"bar\", label: \"Week Points\", backgroundColor: color(window.chartColors.blue).alpha(0.4).rgbString(), "; string web2 = "borderColor: window.chartColors.blue, data: [ " + Wdata + "]}] }; " + "window.onload = function() {" + "var ctx1 = document.getElementById(\"chart - area\").getContext(\"2d\"); " + "window.myPie = new Chart(ctx1, config); " + "var ctx = document.getElementById(\"canvas\").getContext(\"2d\"); " + "window.myBar = new Chart(ctx, { type: \"bar\", data: barChartData, options: {legend: {position: 'bottom'} ,title: {display: true, text: 'Points per day' } }}); }; " + "</script>" + "</body>" + "</html>"; webview.Html = web1 + web2; }