/// <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);
        }
Ejemplo n.º 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 = "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);
        }
Ejemplo n.º 3
0
        private void BuildLanguageDeltasTable()
        {
            _languageDeltasTable = new DataTable("LanguageDeltasTable");
            if (!BookDeltas.Any())
            {
                return;
            }

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

            // add the date & total columns
            _languageDeltasTable.Columns.Add(
                new DataColumn("Date", _book.Date.GetType()));
            _languageDeltasTable.Columns.Add(
                new DataColumn("TotalBooks", latestTally.TotalBooks.GetType()));
            _languageDeltasTable.Columns.Add(
                new DataColumn("TotalPages", latestTally.TotalPages.GetType()));

            // add the 4 columns for each of languages: ttl books, % book, ttl pages, % pages
            foreach (var language in languages)
            {
                _languageDeltasTable.Columns.Add(
                    new DataColumn(language + "TotalBooks", typeof(UInt32)));
                _languageDeltasTable.Columns.Add(
                    new DataColumn(language + "PercentageBooks", typeof(double)));
                _languageDeltasTable.Columns.Add(
                    new DataColumn(language + "TotalPages", typeof(UInt32)));
                _languageDeltasTable.Columns.Add(
                    new DataColumn(language + "PercentagePages", typeof(double)));
            }

            // loop through the deltas adding rows foreach
            for (int row = 0; row < BookDeltas.Count; ++row)
            {
                var     delta  = BookDeltas[row];
                DataRow newRow = _languageDeltasTable.NewRow();
                newRow["Date"]       = delta.Date;
                newRow["TotalBooks"] = delta.OverallTally.TotalBooks;
                newRow["TotalPages"] = delta.OverallTally.TotalPages;

                foreach (var language in languages)
                {
                    UInt32 ttlBooks, ttlPages;
                    double pctBooks, pctPages;
                    GetLanguageTotalsForDelta(delta, language,
                                              out ttlBooks, out ttlPages, out pctBooks, out pctPages);

                    newRow[language + "TotalBooks"]      = ttlBooks;
                    newRow[language + "PercentageBooks"] = pctBooks;
                    newRow[language + "TotalPages"]      = ttlPages;
                    newRow[language + "PercentagePages"] = pctPages;
                }

                _languageDeltasTable.Rows.Add(newRow);
            }
        }
        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);
        }
 public MonthlyReportsTally(BooksDelta.DeltaTally overallTally)
 {
     DisplayTitle = "Overall";
     //TotalDays = talliedBook.;
     TotalDays           = overallTally.DaysInTally;
     TotalBooks          = overallTally.TotalBooks;
     TotalPagesRead      = overallTally.TotalPages;
     TotalBookFormat     = overallTally.TotalBookFormat;
     TotalComicFormat    = overallTally.TotalComicFormat;
     TotalAudioFormat    = overallTally.TotalAudioFormat;
     PercentageInEnglish = overallTally.PercentageInEnglish;
 }
Ejemplo n.º 6
0
        public TallyDelta(BooksDelta.DeltaTally talliedBook)
        {
            DaysInTally      = (int)talliedBook.DaysInTally;
            TotalPages       = (int)talliedBook.TotalPages;
            TotalBooks       = (int)talliedBook.TotalBooks;
            TotalBookFormat  = (int)talliedBook.TotalBookFormat;
            TotalComicFormat = (int)talliedBook.TotalComicFormat;
            TotalAudioFormat = (int)talliedBook.TotalAudioFormat;

            PercentageInEnglish     = (float)talliedBook.PercentageInEnglish;
            PercentageInTranslation = (float)talliedBook.PercentageInTranslation;
            PageRate     = (float)talliedBook.PageRate;
            DaysPerBook  = (float)talliedBook.DaysPerBook;
            PagesPerBook = (float)talliedBook.PagesPerBook;
            BooksPerYear = (float)talliedBook.BooksPerYear;
        }
        /// <summary>
        /// Gets up the country or language names for line chart series.
        /// </summary>
        /// <param name="isBooks">True if the chart is for books, false for pages.</param>
        /// <param name="isCountries">True if the chart is for countries, false for languages.</param>
        private List <string> GetCountriesOrLanguagesNames(bool isBooks, bool isCountries)
        {
            BooksDelta.DeltaTally latestTally = BooksReadProvider.BookDeltas.Last().OverallTally;
            List <string>         countriesOrLanguages;

            if (isCountries)
            {
                if (isBooks)
                {
                    countriesOrLanguages = (from item in latestTally.CountryTotals
                                            orderby item.Item2 descending
                                            select item.Item1).ToList();
                }
                else
                {
                    countriesOrLanguages = (from item in latestTally.CountryTotals
                                            orderby item.Item5 descending
                                            select item.Item1).ToList();
                }
            }
            else
            {
                if (isBooks)
                {
                    countriesOrLanguages = (from item in latestTally.LanguageTotals
                                            orderby item.Item2 descending
                                            select item.Item1).ToList();
                }
                else
                {
                    countriesOrLanguages = (from item in latestTally.LanguageTotals
                                            orderby item.Item5 descending
                                            select item.Item1).ToList();
                }
            }

            return(countriesOrLanguages);
        }