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));
        }
예제 #2
0
        /// <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));
        }
예제 #3
0
        /// <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 = "Percentage Books Read by Country With Time Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Percentage Books Read by Country With Time Plot");
            SetupPercentageBooksReadKeyVsTimeAxes(newPlot);

            // get the countries (in order)
            BooksDelta.DeltaTally latestTally = BooksReadProvider.BookDeltas.Last().OverallTally;
            List <string>         countries   = (from item in latestTally.CountryTotals
                                                 orderby item.Item2 descending
                                                 select item.Item1).ToList();

            // create the series for the languages
            List <KeyValuePair <string, LineSeries> > countriesSeries =
                new List <KeyValuePair <string, LineSeries> >();

            for (int i = 0; i < countries.Count; i++)
            {
                LineSeries countrySeries;
                OxyPlotUtilities.CreateLongLineSeries(
                    out countrySeries,
                    ChartAxisKeys.DateKey,
                    ChartAxisKeys.PercentageBooksReadKey,
                    countries[i],
                    i);
                countriesSeries.Add(new KeyValuePair <string, LineSeries>(countries[i], countrySeries));
            }

            // loop through the deltas adding points for each of the items
            foreach (BooksDelta delta in BooksReadProvider.BookDeltas)
            {
                double date = DateTimeAxis.ToDouble(delta.Date);
                foreach (KeyValuePair <string, LineSeries> countryLine in countriesSeries)
                {
                    double percentage = 0.0;
                    foreach (Tuple <string, uint, double, uint, double> countryTotal in delta.OverallTally.CountryTotals)
                    {
                        if (countryTotal.Item1 == countryLine.Key)
                        {
                            percentage = countryTotal.Item3;
                        }
                    }

                    countryLine.Value.Points.Add(new DataPoint(date, percentage));
                }
            }

            // add them to the plot
            foreach (KeyValuePair <string, LineSeries> countryItems in countriesSeries)
            {
                newPlot.Series.Add(countryItems.Value);
            }

            // finally update the model with the new plot
            return(newPlot);
        }
        /// <summary>
        /// Sets up the plot model to be displayed.
        /// </summary>
        /// <returns>The plot model.</returns>
        protected override PlotModel SetupPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "Total Books Read by Language With Time Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Total Books Read by Language With Time Plot");
            SetupTotalBooksReadKeyVsTimeAxes(newPlot);

            // get the languages (in order)
            BooksDelta.DeltaTally latestTally = BooksReadProvider.BookDeltas.Last().OverallTally;
            List <string>         countries   = (from item in latestTally.CountryTotals
                                                 orderby item.Item2 descending
                                                 select item.Item1).ToList();

            // create the series for the languages
            List <KeyValuePair <string, LineSeries> > lineSeriesSet =
                new List <KeyValuePair <string, LineSeries> >();

            for (int i = 0; i < countries.Count; i++)
            {
                LineSeries series;
                OxyPlotUtilities.CreateLongLineSeries(out series,
                                                      ChartAxisKeys.DateKey, ChartAxisKeys.TotalBooksReadKey, countries[i], i, 128);
                lineSeriesSet.Add(
                    new KeyValuePair <string, LineSeries>(countries[i], series));
            }

            // loop through the deltas adding points for each of the items to the lines
            foreach (var delta in BooksReadProvider.BookDeltas)
            {
                var date = DateTimeAxis.ToDouble(delta.Date);
                foreach (var line in lineSeriesSet)
                {
                    double ttl = 0.0;
                    foreach (var langTotal in delta.OverallTally.CountryTotals)
                    {
                        if (langTotal.Item1 == line.Key)
                        {
                            ttl = langTotal.Item2;
                        }
                    }
                    line.Value.Points.Add(new DataPoint(date, ttl));
                }
            }

            IList <LineSeries> lineSeries =
                (from item in lineSeriesSet select item.Value).ToList();
            var stackSeries = OxyPlotUtilities.StackLineSeries(lineSeries);

            // add them to the plot
            foreach (var areaSeries in stackSeries)
            {
                newPlot.Series.Add(areaSeries);
            }

            // finally update the model with the new plot
            return(newPlot);
        }
예제 #5
0
        private PlotModel SetupOverallBookAndPageTalliesPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "Overall Book And Pages Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Overall Book And Pages Plot");
            SetupOverallBookAndPagesVsTimeAxes(newPlot);

            // create series and add them to the plot
            LineSeries booksReadSeries;
            LineSeries booksReadTrendlineSeries;

            OxyPlotUtilities.CreateLineSeries(out booksReadSeries, ChartAxisKeys.DateKey, ChartAxisKeys.BooksReadKey, "Total Books Read", 1);
            OxyPlotUtilities.CreateLineSeries(out booksReadTrendlineSeries, ChartAxisKeys.DateKey, ChartAxisKeys.BooksReadKey, "Books Read Trendline", 4);
            double yinterceptBooks;
            double slopeBooks;

            GetBooksLinearTrendlineParameters(out yinterceptBooks, out slopeBooks);


            LineSeries pagesReadSeries;
            LineSeries pagesReadTrendlineSeries;

            OxyPlotUtilities.CreateLineSeries(out pagesReadSeries, ChartAxisKeys.DateKey, ChartAxisKeys.PagesReadKey, "Total Pages Read", 0);
            OxyPlotUtilities.CreateLineSeries(out pagesReadTrendlineSeries, ChartAxisKeys.DateKey, ChartAxisKeys.PagesReadKey, "Pages Read Trendline", 3
                                              );
            double yinterceptPages;
            double slopePages;

            GetPagesLinearTrendlineParameters(out yinterceptPages, out slopePages);


            foreach (var delta in _mainModel.BookDeltas)
            {
                double trendBooks = yinterceptBooks + (slopeBooks * delta.DaysSinceStart);
                double trendPages = yinterceptPages + (slopePages * delta.DaysSinceStart);

                booksReadSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), delta.OverallTally.TotalBooks));
                booksReadTrendlineSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), trendBooks));

                pagesReadSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), delta.OverallTally.TotalPages));
                pagesReadTrendlineSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), trendPages));
            }


            OxyPlotUtilities.AddLineSeriesToModel(newPlot,
                                                  new LineSeries[] { booksReadSeries, booksReadTrendlineSeries,
                                                                     pagesReadSeries, pagesReadTrendlineSeries }
                                                  );


            // finally update the model with the new plot
            return(newPlot);
        }
예제 #6
0
        private PlotModel SetupCountryLocationsBooksReadPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "Countries in Location with Books Read Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Countries in Location with Books Read Plot");
            SetupLatitudeAndLongitudeAxes(newPlot);

            // create series and add them to the plot
            ScatterSeries pointsSeries;

            OxyPlotUtilities.CreateScatterPointSeries(out pointsSeries,
                                                      ChartAxisKeys.LongitudeKey, ChartAxisKeys.LatitudeKey, "Countries");

            foreach (var authorCountry in _mainModel.AuthorCountries)
            {
                var name    = authorCountry.Country;
                var country = _mainModel.WorldCountries.Where(w => w.Country == name).FirstOrDefault();
                if (country != null)
                {
                    var pointSize = authorCountry.TotalBooksReadFromCountry;
                    if (pointSize < 5)
                    {
                        pointSize = 5;
                    }

                    ScatterPoint point =
                        new ScatterPoint(country.Longitude, country.Latitude, pointSize,
                                         authorCountry.TotalBooksReadFromCountry)
                    {
                        Tag = name
                    };
                    pointsSeries.Points.Add(point);
                }
            }

            pointsSeries.TrackerFormatString = "{Tag}\nLat/Long ( {4:0.###} ,{2:0.###} ) \nTotal Books {6}";
            newPlot.Series.Add(pointsSeries);

            List <OxyColor> colors = new List <OxyColor>();

            foreach (var color in OxyPalettes.Jet(200).Colors)
            {
                var faintColor = OxyColor.FromArgb(128, color.R, color.G, color.B);
                colors.Add(faintColor);
            }

            OxyPalette faintPalette = new OxyPalette(colors);

            newPlot.Axes.Add(new LinearColorAxis
            {
                Position = AxisPosition.Right, Palette = faintPalette, Title = "Books Read"
            });

            return(newPlot);
        }
        private PlotModel SetupPercentageBooksReadByLanguagePlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "Percentage Books Read by Language With Time Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Percentage Books Read by Language With Time Plot");
            SetupPercentageBooksReadKeyVsTimeAxes(newPlot);

            // get the languages (in order)
            BooksDelta.DeltaTally latestTally = _mainModel.BookDeltas.Last().OverallTally;
            List <string>         languages   = (from item in latestTally.LanguageTotals
                                                 orderby item.Item2 descending
                                                 select item.Item1).ToList();

            // create the series for the languages
            List <KeyValuePair <string, LineSeries> > languagesSeries =
                new List <KeyValuePair <string, LineSeries> >();

            for (int i = 0; i < languages.Count; i++)
            {
                LineSeries languageSeries;
                OxyPlotUtilities.CreateLongLineSeries(out languageSeries,
                                                      ChartAxisKeys.DateKey, ChartAxisKeys.PercentageBooksReadKey, languages[i], i);
                languagesSeries.Add(
                    new KeyValuePair <string, LineSeries>(languages[i], languageSeries));
            }

            // loop through the deltas adding points for each of the items
            foreach (var delta in _mainModel.BookDeltas)
            {
                var date = DateTimeAxis.ToDouble(delta.Date);
                foreach (var languageLine in languagesSeries)
                {
                    double percentage = 0.0;
                    foreach (var langTotal in delta.OverallTally.LanguageTotals)
                    {
                        if (langTotal.Item1 == languageLine.Key)
                        {
                            percentage = langTotal.Item3;
                        }
                    }
                    languageLine.Value.Points.Add(new DataPoint(date, percentage));
                }
            }

            // add them to the plot
            foreach (var languagesItems in languagesSeries)
            {
                newPlot.Series.Add(languagesItems.Value);
            }

            // finally update the model with the new plot
            return(newPlot);
        }
예제 #8
0
        public override void UpdateModel(ref PlotModel newPlot)
        {
            OxyPlotUtilities.SetupPlotLegend(newPlot, PlotTitle);
            SetupTotalSeatsVsTimeAxes(newPlot);

            // if no data stop
            if (ElectionPredictions?.PollingPredictions == null ||
                !ElectionPredictions.PollingPredictions.Any())
            {
                return;
            }

            // Get the polls by date.
            List <KeyValuePair <DateTime, PartyPrediction> > pollValues =
                GetPartyPredictionsByDate();

            // Get the party names.
            string[] partiesNames = PartyPrediction.PartiesList;

            // Add a line and a scatter series per party
            List <KeyValuePair <string, LineSeries> > partiesLineSeries =
                new List <KeyValuePair <string, LineSeries> >();

            SetupPartiesSeries(partiesNames, partiesLineSeries);

            // loop through the polls adding points for each of the items to the lines
            AddValuesToSeries(pollValues, partiesLineSeries);

            // Get the area stack series
            IEnumerable <AreaSeries> stackedSeatsSeries =
                OxyPlotUtilities.StackLineSeries(partiesLineSeries.Select(x => x.Value).ToList());

            // add them to the plot
            foreach (AreaSeries series in stackedSeatsSeries)
            {
                newPlot.Series.Add(series);
            }

            // add a line annotation
            double X = 5D;
            double Y = 65D;

            LineAnnotation lineAnnotation = new LineAnnotation()
            {
                StrokeThickness = 3,
                Color           = OxyColors.Crimson,
                Type            = LineAnnotationType.Horizontal,
                Text            = "Majority",
                TextColor       = OxyColors.Crimson,
                X = X,
                Y = Y
            };

            newPlot.Annotations.Add(lineAnnotation);
        }
예제 #9
0
        private PlotModel SetupAverageDaysPerBookPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "Average Days Per Book Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Average Days Per Book Plot");
            SetupDaysPerBookVsTimeAxes(newPlot);

            // create series and add them to the plot
            LineSeries overallSeries;
            LineSeries lastTenSeries;
            LineSeries overallTrendlineSeries;
            LineSeries lastTenTrendlineSeries;

            OxyPlotUtilities.CreateLineSeries(out overallSeries, ChartAxisKeys.DateKey, ChartAxisKeys.DaysPerBookKey, "Overall", 1);
            OxyPlotUtilities.CreateLineSeries(out overallTrendlineSeries, ChartAxisKeys.DateKey, ChartAxisKeys.DaysPerBookKey, "Overall Trendline", 4);
            OxyPlotUtilities.CreateLineSeries(out lastTenSeries, ChartAxisKeys.DateKey, ChartAxisKeys.DaysPerBookKey, "Last 10", 0);
            OxyPlotUtilities.CreateLineSeries(out lastTenTrendlineSeries, ChartAxisKeys.DateKey, ChartAxisKeys.DaysPerBookKey, "Last 10 Trendline", 3);

            ICurveFitter lastTenCurveFitter;
            ICurveFitter overallCurveFitter;

            GetAverageDaysPerBookCurveFitters(out lastTenCurveFitter, out overallCurveFitter);


            foreach (var delta in _mainModel.BookDeltas)
            {
                double trendOverallDaysPerBook =
                    overallCurveFitter.EvaluateYValueAtPoint(delta.DaysSinceStart);
                double trendLastTenDaysPerBook =
                    lastTenCurveFitter.EvaluateYValueAtPoint(delta.DaysSinceStart);

                overallSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), delta.OverallTally.DaysPerBook));
                lastTenSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), delta.LastTenTally.DaysPerBook));

                overallTrendlineSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), trendOverallDaysPerBook));
                lastTenTrendlineSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), trendLastTenDaysPerBook));
            }


            OxyPlotUtilities.AddLineSeriesToModel(newPlot,
                                                  new LineSeries[] { overallSeries, lastTenSeries, overallTrendlineSeries, lastTenTrendlineSeries }
                                                  );


            // finally update the model with the new plot
            return(newPlot);
        }
예제 #10
0
        /// <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 = "Countries in Location with Books Read Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Countries in Location with Books Read Plot");
            SetupLatitudeAndLongitudeAxes(newPlot);

            // create series and add them to the plot
            ScatterSeries pointsSeries;

            OxyPlotUtilities.CreateScatterPointSeries(out pointsSeries,
                                                      ChartAxisKeys.LongitudeKey, ChartAxisKeys.LatitudeKey, "Countries");

            foreach (AuthorCountry authorCountry in BooksReadProvider.AuthorCountries)
            {
                string       name    = authorCountry.Country;
                WorldCountry country = GeographyProvider.WorldCountries.FirstOrDefault(w => w.Country == name);
                if (country != null)
                {
                    var pointSize = authorCountry.TotalBooksReadFromCountry;
                    if (pointSize < 5)
                    {
                        pointSize = 5;
                    }

                    ScatterPoint point =
                        new ScatterPoint(country.Longitude, country.Latitude, pointSize,
                                         authorCountry.TotalBooksReadFromCountry)
                    {
                        Tag = name
                    };
                    pointsSeries.Points.Add(point);
                }
            }

            pointsSeries.TrackerFormatString = "{Tag}\nLat/Long ( {4:0.###} ,{2:0.###} ) \nTotal Books {6}";
            newPlot.Series.Add(pointsSeries);

            List <OxyColor> colors =
                OxyPalettes.Jet(200).Colors.Select(color => OxyColor.FromArgb(128, color.R, color.G, color.B)).ToList();

            OxyPalette faintPalette = new OxyPalette(colors);

            newPlot.Axes.Add(new LinearColorAxis
            {
                Position = AxisPosition.Right, Palette = faintPalette, Title = "Books Read"
            });

            return(newPlot);
        }
예제 #11
0
        public override void UpdateModel(ref PlotModel newPlot)
        {
            OxyPlotUtilities.SetupPlotLegend(newPlot, PlotTitle);
            SetupListVotesVsTimeAxes(newPlot);

            // if no data stop
            if (PollingPredictions == null || !PollingPredictions.Any())
            {
                return;
            }

            // Get the data vales by date.
            List <KeyValuePair <DateTime, PartyPrediction> > pollValues =
                GetPartyPredictionsByDate();

            List <KeyValuePair <DateTime, PartyPrediction> > interpolationValues =
                GetPartyPredictionsByDate(false);

            // Get the party names.
            string[] partiesNames = PartyPrediction.PartiesList;

            // Add a line and a scatter series per party
            List <KeyValuePair <string, LineSeries> > partiesLineSeries =
                new List <KeyValuePair <string, LineSeries> >();
            List <KeyValuePair <string, LineSeries> > partiesLineInterpolationSeries =
                new List <KeyValuePair <string, LineSeries> >();
            List <KeyValuePair <string, ScatterSeries> > partiesScatterSeries =
                new List <KeyValuePair <string, ScatterSeries> >();

            SetupPartiesSeries(partiesNames, partiesLineSeries, partiesScatterSeries);
            SetupPartiesLineSeries(partiesNames, partiesLineInterpolationSeries);

            // loop through the polls adding points for each of the items to the lines
            AddPercentageValuesToSeries(pollValues, partiesLineSeries, partiesScatterSeries);
            AddPercentageValuesToSeries(interpolationValues, partiesLineInterpolationSeries);

            // add the series to the plot
            foreach (KeyValuePair <string, LineSeries> partyLines in partiesLineInterpolationSeries)
            {
                newPlot.Series.Add(partyLines.Value);
            }

            //foreach (KeyValuePair<string, LineSeries> partyLines in partiesLineSeries)
            //{
            //    newPlot.Series.Add(partyLines.Value);
            //}

            foreach (KeyValuePair <string, ScatterSeries> partyScatters in partiesScatterSeries)
            {
                newPlot.Series.Add(partyScatters.Value);
            }
        }
예제 #12
0
        private PlotModel SetupBooksAndPagesLastTenPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "Last 10 Books Time vs Pages Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Last 10 Books Time vs Pages Plot");
            SetupPagesPerDayWithTimeVsTimeAxes(newPlot);

            // create series and add them to the plot
            ScatterSeries pointsSeries;

            OxyPlotUtilities.CreateScatterPointSeries(out pointsSeries,
                                                      ChartAxisKeys.DaysTakenKey, ChartAxisKeys.TotalPagesReadKey, "Time Taken Vs Pages");

            List <BooksDelta> deltasSet = new List <BooksDelta>();

            foreach (var delta in _mainModel.BookDeltas)
            {
                deltasSet.Add(delta);
                if (deltasSet.Count < 10)
                {
                    continue;
                }

                BooksDelta end = deltasSet.Last();

                double daysTaken = end.LastTenTally.DaysInTally;
                double pagesRead = end.LastTenTally.TotalPages;

                double translated = end.LastTenTally.PercentageInTranslation;

                ScatterPoint point =
                    new ScatterPoint(daysTaken, pagesRead, 5, translated)
                {
                    Tag = end.Date.ToString("ddd d MMM yyy")
                };
                pointsSeries.Points.Add(point);

                deltasSet.RemoveAt(0);
            }
            pointsSeries.TrackerFormatString = "{Tag}\n{1}: {2:0.###}\n{3}: {4:0.###}\nTranslated % {6}";
            newPlot.Series.Add(pointsSeries);
            newPlot.Axes.Add(new LinearColorAxis
            {
                Position = AxisPosition.Right, Palette = OxyPalettes.Jet(200), Title = "Percentage Translated"
            });

            // finally update the model with the new plot
            return(newPlot);
        }
예제 #13
0
        /// <summary>
        /// Sets up the plot model to be displayed.
        /// </summary>
        /// <returns>The plot model.</returns>
        protected override PlotModel SetupPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "Countries in Location with Books and Pages Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Countries in Location with Books and Pages Plot");
            SetupLatitudeAndLongitudeAxes(newPlot);

            // create series and add them to the plot
            AddBooksAndPagesScatterSeries(newPlot);

            return(newPlot);
        }
        /// <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));
        }
예제 #15
0
        /// <summary>
        /// Sets up the plot model to be displayed.
        /// </summary>
        /// <returns>The plot model.</returns>
        protected override PlotModel SetupPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "% Books In Translation"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "% Books In Translation");
            SetupBooksInTranslationVsTimeAxes(newPlot);

            // create series and add them to the plot
            LineSeries overallSeries;
            LineSeries lastTenSeries;
            LineSeries overallTrendlineSeries;

            OxyPlotUtilities.CreateLineSeries(out overallSeries, ChartAxisKeys.DateKey, ChartAxisKeys.BooksInTranslationKey, "Overall", 1);
            OxyPlotUtilities.CreateLineSeries(out lastTenSeries, ChartAxisKeys.DateKey, ChartAxisKeys.BooksInTranslationKey, "Last 10", 0);
            OxyPlotUtilities.CreateLineSeries(out overallTrendlineSeries, ChartAxisKeys.DateKey, ChartAxisKeys.BooksInTranslationKey, "Overall Trendline", 4);
            double yintercept;
            double slope;

            GetBooksInTranslationLinearTrendlineParameters(out yintercept, out slope);


            foreach (var delta in BooksReadProvider.BookDeltas)
            {
                double trendDaysPerBook = yintercept + (slope * delta.DaysSinceStart);

                overallSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), delta.OverallTally.PercentageInTranslation));
                lastTenSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), delta.LastTenTally.PercentageInTranslation));
                overallTrendlineSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), trendDaysPerBook));
            }


            OxyPlotUtilities.AddLineSeriesToModel(newPlot,
                                                  new[] { overallSeries, lastTenSeries, overallTrendlineSeries }
                                                  );


            // finally update the model with the new plot
            return(newPlot);
        }
예제 #16
0
        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));
        }
        private PlotModel SetupPagesPerBookPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "Pages Per Book Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Pages Per Book Plot");
            SetupPagesPerBookVsTimeAxes(newPlot);

            // create series and add them to the plot
            LineSeries overallSeries;
            LineSeries lastTenSeries;
            LineSeries overallTrendlineSeries;

            OxyPlotUtilities.CreateLineSeries(out overallSeries, ChartAxisKeys.DateKey, ChartAxisKeys.PagesPerBookKey, "Overall", 1);
            OxyPlotUtilities.CreateLineSeries(out lastTenSeries, ChartAxisKeys.DateKey, ChartAxisKeys.PagesPerBookKey, "Last 10", 0);
            OxyPlotUtilities.CreateLineSeries(out overallTrendlineSeries, ChartAxisKeys.DateKey, ChartAxisKeys.PagesPerBookKey, "Overall Trendline", 4);

            double yintercept;
            double slope;

            GetPagesPerBookLinearTrendlineParameters(out yintercept, out slope);

            foreach (var delta in _mainModel.BookDeltas)
            {
                double trendPageRate = yintercept + (slope * delta.DaysSinceStart);

                overallSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), delta.OverallTally.PagesPerBook));
                lastTenSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), delta.LastTenTally.PagesPerBook));
                overallTrendlineSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), trendPageRate));
            }


            OxyPlotUtilities.AddLineSeriesToModel(newPlot,
                                                  new LineSeries[] { overallSeries, lastTenSeries, overallTrendlineSeries }
                                                  );


            // finally update the model with the new plot
            return(newPlot);
        }
예제 #18
0
        /// <summary>
        /// Sets up the plot model to be displayed.
        /// </summary>
        /// <returns>The plot model.</returns>
        protected override PlotModel SetupPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "Longitude With Time Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Longitude With Time Plot");
            SetupLongitudeVsTimeAxes(newPlot);

            // create series and add them to the plot
            LineSeries overallSeries;
            LineSeries lastTenSeries;
            LineSeries overallTrendlineSeries;

            OxyPlotUtilities.CreateLineSeries(out overallSeries, ChartAxisKeys.DateKey, ChartAxisKeys.LongitudeKey, "Overall", 1);
            OxyPlotUtilities.CreateLineSeries(out lastTenSeries, ChartAxisKeys.DateKey, ChartAxisKeys.LongitudeKey, "Last 10", 0);
            OxyPlotUtilities.CreateLineSeries(out overallTrendlineSeries, ChartAxisKeys.DateKey, ChartAxisKeys.LongitudeKey, "Overall Trendline", 4);

            double yintercept;
            double slope;

            GetLongitudeLinearTrendlineParameters(out yintercept, out slope);

            foreach (var delta in BooksReadProvider.BookLocationDeltas)
            {
                double trendPageRate = yintercept + (slope * delta.DaysSinceStart);

                overallSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), delta.AverageLongitude));
                lastTenSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), delta.AverageLongitudeLastTen));
                overallTrendlineSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), trendPageRate));
            }


            OxyPlotUtilities.AddLineSeriesToModel(newPlot, new[] { overallSeries, lastTenSeries, overallTrendlineSeries });


            // finally update the model with the new plot
            return(newPlot);
        }
        private PlotModel SetupTalliesPerCalendarYearPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "Tallies Per Calendar Year Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Tallies Per Calendar Year Plot");
            SetupBookAndPagesVsDayOfYearAxes(newPlot);

            // get the books & pages read for each calendar year
            Dictionary <int, List <DayOfYearTally> > bookListsByDayandYear = GetBookListsByDayAndYear();

            // add a series for each year (in order)
            int colourIndex = 1;
            var colours     = OxyPlotUtilities.SetupStandardColourSet();

            foreach (var year in bookListsByDayandYear.Keys.ToList().OrderBy(x => x))
            {
                LineSeries booksReadSeries;
                LineSeries pagesReadSeries;
                GetBooksAndPagesReadLineSeries(colourIndex, colours, year, out booksReadSeries, out pagesReadSeries);

                // add the points for the days of this year
                foreach (var tally in bookListsByDayandYear[year])
                {
                    booksReadSeries.Points.Add(
                        new DataPoint(tally.DayOfYear, tally.BooksReadThisYearOnThisDay));
                    pagesReadSeries.Points.Add(
                        new DataPoint(tally.DayOfYear, tally.PagesReadThisYearOnThisDay));
                }

                // then add them to the model
                OxyPlotUtilities.AddLineSeriesToModel(newPlot, new
                                                      LineSeries[] { booksReadSeries, pagesReadSeries });
                colourIndex++;
            }

            // finally update the model with the new plot
            return(newPlot);
        }
        /// <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 = "Days Per Book With Time Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Days Per Book With Time Plot");
            SetupDaysPerBookWithTimeVsTimeAxes(newPlot);

            // create series and add them to the plot
            LineSeries overallSeries;
            LineSeries overallTrendlineSeries;

            OxyPlotUtilities.CreateLineSeries(
                out overallSeries, ChartAxisKeys.DateKey, ChartAxisKeys.DaysKey, "Overall", 1);
            OxyPlotUtilities.CreateLineSeries(
                out overallTrendlineSeries, ChartAxisKeys.DateKey, ChartAxisKeys.DaysKey, "Overall Trendline", 0);

            ICurveFitter curveFitter;

            GetDaysPerBookWithTimeCurveFitter(out curveFitter);

            foreach (var delta in BooksReadProvider.BookDeltas)
            {
                double trendPageRate = curveFitter.EvaluateYValueAtPoint(delta.DaysSinceStart);

                overallSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), delta.OverallTally.DaysPerBook));
                overallTrendlineSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), trendPageRate));
            }

            OxyPlotUtilities.AddLineSeriesToModel(newPlot, new[] { overallSeries, overallTrendlineSeries });

            // finally update the model with the new plot
            return(newPlot);
        }
        private PlotModel SetupTalliesPerCalendarYearPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "Tallies Per Month for each Calendar Year"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Tallies Per Month for each Calendar Year");
            if (_chartType == ChartType.BothAsLines)
            {
                SetupBookAndPagesVsMonthOfYearAxes(newPlot);
            }
            else if (_chartType == ChartType.PagesAsColumns)
            {
                SetupPagesVsMonthOfYearCalegoryAxes(newPlot);
            }
            else
            {
                SetupBookVsMonthOfYearCalegoryAxes(newPlot);
            }

            // get the books & pages read for each calendar year
            Dictionary <int, List <MonthOfYearTally> > bookListsByMonthOfYear = GetBookListsByMonthOfYear();

            // add a series for each year (in order)
            if (_chartType == ChartType.BothAsLines)
            {
                AddLineSeriesForMonthlyTallies(newPlot, bookListsByMonthOfYear);
            }
            else
            {
                AddColumnSeriesForMonthlyTallies(newPlot, bookListsByMonthOfYear);
            }

            // finally update the model with the new plot
            return(newPlot);
        }
        /// <summary>
        /// Sets up the plot model to be displayed.
        /// </summary>
        /// <returns>The plot model.</returns>
        protected override PlotModel SetupPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "Last 10 Books Time vs Pages Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Last 10 Books Time vs Pages Plot");
            SetupPagesPerDayWithTimeVsTimeAxes(newPlot);

            // create series and add them to the plot
            ScatterSeries pointsSeries;

            OxyPlotUtilities.CreateScatterPointSeries(
                out pointsSeries,
                ChartAxisKeys.DaysTakenKey,
                ChartAxisKeys.TotalPagesReadKey,
                "Time Taken Vs Pages");

            List <BooksDelta> deltasSet = new List <BooksDelta>();

            double minRate = 1e16;
            double maxRate = 0.0;

            foreach (var delta in BooksReadProvider.BookDeltas)
            {
                deltasSet.Add(delta);
                if (deltasSet.Count < 10)
                {
                    continue;
                }

                BooksDelta end = deltasSet.Last();

                double daysTaken = end.LastTenTally.DaysInTally;
                double pagesRead = end.LastTenTally.TotalPages;
                if (daysTaken < 1.0)
                {
                    daysTaken = 1.0;
                }
                double       rate  = pagesRead / daysTaken;
                ScatterPoint point =
                    new ScatterPoint(daysTaken, pagesRead, 5, rate)
                {
                    Tag = end.Date.ToString("ddd d MMM yyy")
                };
                pointsSeries.Points.Add(point);

                if (minRate > rate)
                {
                    minRate = rate;
                }
                if (maxRate < rate)
                {
                    maxRate = rate;
                }

                deltasSet.RemoveAt(0);
            }
            pointsSeries.TrackerFormatString = "{Tag}\n{1}: {2:0.###}\n{3}: {4:0.###}";
            newPlot.Series.Add(pointsSeries);
            newPlot.Axes.Add(new LinearColorAxis {
                Position = AxisPosition.Right, Palette = OxyPalettes.Jet(200), Title = "Page Rate"
            });

            // finally update the model with the new plot
            return(newPlot);
        }
        /// <summary>
        /// Sets up the plot model to be displayed.
        /// </summary>
        /// <returns>The plot model.</returns>
        protected override PlotModel SetupPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "Books and Pages per Year Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Books and Pages per Year Plot");
            SetupBookAndPagesPerYearVsTimeAxes(newPlot);

            if (BooksReadProvider.BookPerYearDeltas.Count < 1)
            {
                return(newPlot);
            }

            // create series and add them to the plot
            LineSeries booksReadSeries;
            LineSeries booksReadTrendlineSeries;

            OxyPlotUtilities.CreateLineSeries(out booksReadSeries, ChartAxisKeys.DateKey, ChartAxisKeys.BooksReadKey, "Books Read", 1);
            OxyPlotUtilities.CreateLineSeries(out booksReadTrendlineSeries, ChartAxisKeys.DateKey, ChartAxisKeys.BooksReadKey, "Books Read Trendline", 4);

            ICurveFitter curveFitterBooks;

            GetBooksReadWithTimeCurveFitter(out curveFitterBooks);


            LineSeries pagesReadSeries;
            LineSeries pagesReadTrendlineSeries;

            OxyPlotUtilities.CreateLineSeries(out pagesReadSeries, ChartAxisKeys.DateKey, ChartAxisKeys.PagesPerDayKey, "Pages Read", 0);
            OxyPlotUtilities.CreateLineSeries(out pagesReadTrendlineSeries, ChartAxisKeys.DateKey, ChartAxisKeys.PagesPerDayKey, "Pages Read Trendline", 3);

            ICurveFitter curveFitterPages;

            GetPagesReadWithTimeCurveFitter(out curveFitterPages);


            DateTime start = BooksReadProvider.BookPerYearDeltas[0].Date;

            foreach (var delta in BooksReadProvider.BookPerYearDeltas)
            {
                int daysSinceStart = (delta.Date - start).Days;

                double trendBooks = curveFitterBooks.EvaluateYValueAtPoint(daysSinceStart);
                double trendPages = curveFitterPages.EvaluateYValueAtPoint(daysSinceStart);

                booksReadSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), delta.OverallTally.TotalBooks));
                booksReadTrendlineSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), trendBooks));

                pagesReadSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), delta.OverallTally.PageRate));
                pagesReadTrendlineSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), trendPages));
            }

            OxyPlotUtilities.AddLineSeriesToModel(
                newPlot,
                new[] { booksReadSeries, booksReadTrendlineSeries, pagesReadSeries, pagesReadTrendlineSeries });


            // finally update the model with the new plot
            return(newPlot);
        }