private async void GenerateDistressSuggestions() { //Bottom Half. Again most of the work is done in Database class DistressResponses = await App.database.GetDistressInterventions(DistressType); if (DistressType.Equals("Acute") && DistressExpressions.Any(p => p.Override != null && p.Override.Equals("LT-Acute"))) { DistressSuggestions = await App.database.GetDistressSuggestions("LT-Acute"); } else { DistressSuggestions = await App.database.GetDistressSuggestions(DistressType); } }
/* * private void ResetChart() { * List<ChartEntry> entries = new List<ChartEntry>(); * foreach (UserInputDistressLevel timestamp in FilteredHistory) { * Magnitude.TryGetValue(timestamp.DistressLevelType, out int value); * entries.Add(new ChartEntry(value) { * Label = "", * ValueLabel = timestamp.StartTime.ToString(), * Color = SKColor.Parse("#b455b6") * }); * } * LineChart = new LineChart() { Entries = entries }; * } */ /* * private void ResetChart() { * string level; * string entryDate; * string entryTime; * string labelEntry; * List<ChartEntry> entries = new List<ChartEntry>(); * foreach (UserInputDistressLevel timestamp in FilteredHistory) { * Magnitude.TryGetValue(timestamp.DistressLevelType, out int value); * //assign appropriate distress colour level to entry * switch (value) { * case 4: * //Acute Red * level = "#ff0000"; * break; * case 3: * //Moderate Orange * //level = "#f05828"; * level = "#ffa500"; * break; * case 2: * //Mild Yellow * //level = "f8d90f"; * level = "#ffff00"; * break; * case 1: * //calm - does not have a magniture but color is light green (Neon) * //level = "#8dc63f"; * //level = "#32cd32"; * level = "#39ff14"; * break; * default: * level = "#b455b6"; * break; * } * entryTime = timestamp.StartTime.ToString("hh:mm tt"); * entryDate = timestamp.StartTime.ToString("dd MMM"); //Gets short Date * labelEntry = entryTime + " " + entryDate; * entries.Add(new ChartEntry(value) { * //Label = "", Label appears underneath Bar Chart as the magnitude of the Bar * Label = value.ToString(), * TextColor = SKColor.Parse("#ffffff"), * //ValueLabel = timestamp.StartTime.ToString(), * //ValueLabel appears on top of the Bar as timestamp * ValueLabel = labelEntry, * ValueLabelColor = SKColor.Parse("#ffffff"), * //Color = SKColor.Parse("#b455b6") * Color = SKColor.Parse(level) * }); * } * //LineChart = new LineChart() { Entries = entries, MaxValue = 4, MinValue = 1, LineAreaAlpha = 1, BackgroundColor =SKColor.Parse("#FF90EE90") }; * BarChart = new BarChart() { Entries = entries, MaxValue = 4, MinValue = 1, LabelOrientation = Orientation.Horizontal, ValueLabelOrientation = Orientation.Vertical, BackgroundColor = SKColor.Parse("#006738"), LabelColor = SKColor.Parse("#ffffff"), LabelTextSize = 25f }; * * } */ public void ResetChart() { /* * PlotModel -> PlotModel Series -> List of Plot Items * https://oxyplot.readthedocs.io/en/latest/ */ PlotModel newModel = new PlotModel() //Instantiates the PlotModel, you can define metadata such as Background or Title here { Background = OxyColor.Parse("#006738"), }; //Instantiates the barseries, which will be added to the model after the items are added to the series var barSeries = new ColumnSeries(); // List <ColumnItem> columnItems = new List <ColumnItem>(); foreach (UserInputDistressLevel timestamp in FilteredHistory) { ColumnItem columnItem = new ColumnItem() { Color = OxyColor.Parse(DistressType.DistressTypeColour(DistressType.DistressTypeValue(timestamp.DistressLevelType))), Value = DistressType.DistressTypeValue(timestamp.DistressLevelType), }; columnItems.Add(columnItem); } barSeries.ItemsSource = columnItems; //Sets barseries ItemSource newModel.Series.Add(barSeries); //Sets the barseries var yAxis = new LinearAxis() { Position = AxisPosition.Left, MajorStep = 1, MinorStep = 1, Maximum = 4, }; var xAxis = new CategoryAxis() { Position = AxisPosition.Bottom, }; newModel.Axes.Add(yAxis); newModel.Axes.Add(xAxis); if (columnItems.Count > 0) { //Also, if the user has a lot of recorded items, it would be difficult to see these in detail. /* * if(columnItems.Count > 10){ * //More than 10 items, Graph will be 500px + (50 * number of extra records) * GraphWidth = 500 + ((columnItems.Count - 10) * 50); * } */ Model = newModel; } else { //No Items in Filtered history, set Model to null so axis don't show Model = null; } }