/// <summary> /// Sets up the plot model to be displayed. /// </summary> /// <returns>The plot model.</returns> protected override PlotModel SetupPlot() { // Create the plot model PlotModel newPlot = new PlotModel { Title = "Current Month Pages Read by Author Nationality", TitlePadding = 15 }; OxyPlotUtilities.SetupPlotLegend(newPlot, "Current Month Pages Read by Author Nationality"); Dictionary <string, int> pagesPerCountry = new Dictionary <string, int>(); foreach (var book in BooksReadProvider.SelectedMonthTally.BooksRead) { if (pagesPerCountry.ContainsKey(book.Nationality)) { pagesPerCountry[book.Nationality] += book.Pages; } else { pagesPerCountry.Add(book.Nationality, book.Pages); } } List <KeyValuePair <string, int> > sortedCountryTotals = pagesPerCountry.OrderByDescending(x => x.Value).ToList(); return(OxyPlotUtilities.CreatePieSeriesModelForResultsSet( sortedCountryTotals, "Current Month Pages Read by Author Nationality", 128)); }
private PlotModel SetupCurrentPagesReadByCountryPlot() { // Create the plot model var newPlot = new PlotModel { Title = "Current Month Pages Read By Language" }; OxyPlotUtilities.SetupPlotLegend(newPlot, "Current Month Pages Read By Language"); Dictionary <string, int> pagesPerLanguage = new Dictionary <string, int>(); foreach (var book in _mainModel.SelectedMonthTally.BooksRead) { if (pagesPerLanguage.ContainsKey(book.OriginalLanguage)) { pagesPerLanguage[book.OriginalLanguage] += book.Pages; } else { pagesPerLanguage.Add(book.OriginalLanguage, book.Pages); } } var sortedCountryTotals = pagesPerLanguage.OrderByDescending(x => x.Value).ToList(); return(OxyPlotUtilities.CreatePieSeriesModelForResultsSet( sortedCountryTotals, "Current Month Pages Read By Language", 128)); }
/// <summary> /// Sets up the plot model to be displayed. /// </summary> /// <returns>The plot model.</returns> protected override PlotModel SetupPlot() { // Create the plot model PlotModel newPlot = new PlotModel { Title = "Current Books Read by Country" }; OxyPlotUtilities.SetupPlotLegend(newPlot, "Current Books Read by Country"); List <KeyValuePair <string, int> > sortedCountryTotals = BookTotalsUtilities.SortedSortedBooksReadByCountryTotals(BooksReadProvider); return(OxyPlotUtilities.CreatePieSeriesModelForResultsSet( sortedCountryTotals, "Current Books Read by Country", 128)); }
private PlotModel SetupCurrentBooksReadByCountryPlot() { // Create the plot model var newPlot = new PlotModel { Title = "Current Books Read by Country" }; OxyPlotUtilities.SetupPlotLegend(newPlot, "Current Books Read by Country"); var currentResults = _mainModel.BookDeltas.Last(); List <KeyValuePair <string, int> > countryTotals = new List <KeyValuePair <string, int> >(); // Country, ttl books, ttl books %, ttl pages, ttl pages% //Tuple<string, UInt32, double, UInt32, double> int ttlOtherBooks = 0; double ttlOtherPercentage = 0; foreach (var country in currentResults.OverallTally.CountryTotals) { string countryName = country.Item1; int ttlBooks = (int)country.Item2; double countryPercentage = country.Item3; if (countryPercentage > 1.0) { countryTotals.Add(new KeyValuePair <string, int>(countryName, ttlBooks)); } else { ttlOtherPercentage += countryPercentage; ttlOtherBooks += ttlBooks; } } var sortedCountryTotals = countryTotals.OrderByDescending(x => x.Value).ToList(); if (ttlOtherPercentage > 1.0) { sortedCountryTotals.Add(new KeyValuePair <string, int>("Other", ttlOtherBooks)); } return(OxyPlotUtilities.CreatePieSeriesModelForResultsSet( sortedCountryTotals, "Current Books Read by Country", 128)); }