protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.BarPage); plotViewModel = FindViewById <PlotView>(Resource.Id.plotViewModel); mLLayoutModel = FindViewById <LinearLayout>(Resource.Id.linearLayoutModel); AdaptedList <BikeContainer> FietsTrommels = DataFactory.GetBikeContainers(); string[] neighbourhoods = new string[] { "noord", "delfshaven", "centrum", "feijenoord", "kralingen" }; int[] CountsPerNeighbourhood = new int[5]; for (int i = 0; i < neighbourhoods.Length; i++) { CountsPerNeighbourhood[i] = FietsTrommels.Filter( item => item.Deelgemeente == neighbourhoods[i] ).Count; neighbourhoods[i] = Extensions.FirstCharToUpper(neighbourhoods[i]); } plotModel = Core.GraphMaker.Barchartmaker(CountsPerNeighbourhood, colors); //Makes the axes unscrollable. Do not use with pie-chart! plotModel = Core.GraphMaker.Axisdecorator(plotModel, neighbourhoods, false); //Adding a legend (Optional) Best use with Pie chart. //mLLayoutModel = Core.GraphMaker.Legendamaker(colors, this, modelAllocations, mLLayoutModel, 150); //Adding the model to the view MyModel = plotModel; plotViewModel.Model = MyModel; }
// Method for making the chart based on the data and user input private PlotModel Chartmaker(string inhoud, int maand, string mastr) { new Thread(new ThreadStart(Getdata)).Start(); // Filtering the Bike containers AdaptedList <BikeContainer> Fietstrommels2 = FietsTrommels.Filter(element => element.Deelgemeente == inhoud.ToLower()); // Filtering the Theft AdaptedList <Theft> FietsDiefstal2 = FietsDiefstal.Filter(element => element.Neighbourhood == inhoud.ToLower()); AdaptedList <Month> months = this.dataFactory.CreateMonths(new AdaptedList <DateTime>(FietsDiefstal2.Map <DateTime>(e => e.Date).OrderBy(e => e.Date).ToList()), false); months = months.Filter(item => item.GetMonth == maand); //Making arrays int[] bak = new int[] { Fietstrommels2.Count }; int[] thefts = new[] { months[0].EventsThisMonth }; string[] xas = new[] { Extensions.FirstCharToUpper("Bike thefts in " + Fietstrommels2[0].Deelgemeente + " for the month " + mastr) }; //Making a chart PlotModel model = GraphMaker.Mutiplebarschartmaker(bak, thefts, "Fietstrommels", "Diefstallen"); model = GraphMaker.Axisdecorator(model, xas, false); return(model); }
public PieChartActivity() { this.data = new DataFactory().GetBikeThefts(); var PartialSelectedList = this.data.GroupBy(i => i.Brand); SelectData(PartialSelectedList); }
public AdaptedList <Month> CreateMonths(AdaptedList <DateTime> Dates, bool splitYears) { AdaptedList <Month> SortedMonths = new AdaptedList <Month>(); Predicate <Month> Predicate; //e => (e.GetYear == date.Year) && (e.GetMonth == date.Month) foreach (DateTime date in Dates) { if (splitYears) { Predicate = e => (e.GetYear == date.Year) && (e.GetMonth == date.Month); } else { Predicate = e => (e.GetMonth == date.Month); } // Temporary filtered list to check if the month already exists. AdaptedList <Month> PredicateMonthList = SortedMonths.Filter(Predicate); if (PredicateMonthList.Count == 0) { SortedMonths.Add(new Month(date, 1)); } else if (PredicateMonthList.Count == 1) { PredicateMonthList[0].EventsThisMonth += 1; } else { break; } } return(SortedMonths); }
public override AdaptedList <BikeContainer> GetProcessedData() { string RawJsonContent = base.Dec_DataProcessor.GetProcessedData(); List <BikeContainer> BikeList = JsonConvert.DeserializeObject <List <BikeContainer> >(RawJsonContent); var Bikes = new AdaptedList <BikeContainer>(BikeList); return(Bikes); }
public override AdaptedList <Theft> GetProcessedData() { string RawJsonContent = base.Dec_DataProcessor.GetProcessedData(); List <Theft> TheftList = JsonConvert.DeserializeObject <List <Theft> >(RawJsonContent); var Thefts = new AdaptedList <Theft>(TheftList); return(Thefts); }
public AdaptedList <Theft> GetBikeThefts() { if (SavedBikeThefts == null) { SavedBikeThefts = new JsonToTheft(new WebReader(BikeTheftUrl)).GetProcessedData(); } return(SavedBikeThefts); }
public AdaptedList <BikeContainer> GetBikeContainers() { if (SavedBikeContainers == null) { SavedBikeContainers = new JsonToBikeContainers(new WebReader(BikeContainerUrl)).GetProcessedData(); } return(SavedBikeContainers); }
public AdaptedList <Z> Map <Z>(Func <R, Z> Func) { AdaptedList <Z> MappedList = new AdaptedList <Z>(); foreach (R value in this) { MappedList.Add(Func(value)); } return(MappedList); }
public override ConLocation GetProcessedData() { var BikeContainers = base.Dec_DataProcessor.GetProcessedData().Filter(item => item.GetLatitude() != 0 || item.GetLongitude() != 0); AdaptedList <ConLocation> Locations = BikeContainers.Map <ConLocation>(item => new ConLocation(item, Extensions.Distance(item.GetLatitude(), item.GetLongitude(), UserLat, UserLon))); var filtered = Locations.OrderBy(e => e.Dist).ToList(); return(filtered[0]); }
/// <summary> /// Create-method which handles all the logic to create a specific linechart. /// </summary> /// <returns> /// Plotmodel, containing the lineseries. Ready for use. /// </returns> public PlotModel GetProcessedData() { LineSeries lineSerie = new LineSeries() { DataFieldX = "Date", DataFieldY = "Amount", LineStyle = LineStyle.Solid, Color = OxyColor.FromRgb(255, 0, 0) }; PlotModel model = new PlotModel() { Title = "Thefts per month" }; // Defining the X-Axis as a DateTimeAxis. DateTimeAxis date_Axis = new DateTimeAxis() { StringFormat = "MM/yyyy", Position = AxisPosition.Bottom, IntervalLength = 75, MinorIntervalType = DateTimeIntervalType.Months, IntervalType = DateTimeIntervalType.Months, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.None, IsPanEnabled = false, IsZoomEnabled = false }; // Defining the Y-Axis. LinearAxis YAxis = new LinearAxis() { IsPanEnabled = false, IsZoomEnabled = false, AxislineThickness = 5 }; lineSerie.Smooth = true; AdaptedList <Month> Months = this.SortDateTimesByMonth(); // Assigning datapoints to the lineseries. foreach (Month month in Months) { lineSerie.Points.Add(new DataPoint(DateTimeAxis.ToDouble(month.ThisMonth), month.EventsThisMonth)); } // Adding axes to the plotmodel. model.Axes.Add(date_Axis); model.Axes.Add(YAxis); model.Series.Add(lineSerie); this.OnDataCompleted(); return(model); }
private void GetData() { // Getting BikeTheft data from the database. if (TheftDates == null) { InvokeUI(() => Toast.MakeText(Application.Context, "Graph is loading...", ToastLength.Long).Show()); TheftDates = dataFactory.GetBikeThefts().Map <DateTime>(e => new DateTime(e.Date.Year, e.Date.Month, 1)); TheftDates = TheftDates.Filter(e => e > new DateTime(2011, 1, 1) && e < DateTime.Now); } // For sparing memory, we clear the Theftlist. IDataProcessor <PlotModel> LineChart = new LineChartBuilder(ref TheftDates); Model = LineChart.GetProcessedData(); InvokeUI(() => this.plotView.Model = Model); }
// Method for getting data private void Getdata() { if (FietsTrommels == null && FietsDiefstal == null) { InvokeUI(() => Toast.MakeText(Application.Context, "Data is loading...", ToastLength.Long).Show()); // Getting the data FietsTrommels = this.dataFactory.GetBikeContainers(); FietsDiefstal = this.dataFactory.GetBikeThefts(); } //Display message if (this.r) { InvokeUI( () => Toast.MakeText(Application.Context, "Please choose a Neighbourhood", ToastLength.Long).Show()); InvokeUI(() => spin.Enabled = true); this.r = false; } }
public LineChartBuilder(ref AdaptedList <DateTime> Dates) { this.Dates = Dates; }
/// <summary> /// Method for creating Month-objects in an Adaptedlist. /// The method filters the list to check if the month already exists. /// If it already exists, the amount of events in that specifc month is increased by 1. /// Else, the month will be added to the SortedDatesList and the amount of events in that month is also increased by 1. /// </summary> /// <returns>AdaptedList with Month-objects, containing only distinct months. (The same month as another will never be in this list twice or more)</returns> private AdaptedList <Month> SortDateTimesByMonth() { this.Dates = new AdaptedList <DateTime>(this.Dates.OrderBy(e => e.Date).ToList <DateTime>()); return(new DataFactory().CreateMonths(this.Dates, true)); }