private static void AddLineSeriesForMonthlyTallies(PlotModel newPlot, 
            Dictionary<int, List<MonthOfYearTally>> bookListsByMonthOfYear)
        {
            int colourIndex = 1;
            var colours = OxyPlotUtilities.SetupStandardColourSet();
            foreach (var year in bookListsByMonthOfYear.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 bookListsByMonthOfYear[year])
                {
                    booksReadSeries.Points.Add(
                        new DataPoint(tally.MonthOfYear, tally.BooksReadThisMonth));
                    pagesReadSeries.Points.Add(
                        new DataPoint(tally.MonthOfYear, tally.PagesReadThisMonth));
                }

                // then add them to the model
                OxyPlotUtilities.AddLineSeriesToModel(newPlot, new[] { booksReadSeries, pagesReadSeries });
                colourIndex++;
            }
        }
コード例 #2
0
        private void SetupPagesByCountryModel()
        {
            Model3DGroup modelGroup = new Model3DGroup();

            // get the range of colours for the for the countries

            // set up lookups of the countries with numbers read
            int maxBooksPages;
            int maxBooksLogPages;
            Dictionary <string, long> countryToReadLookUp;
            Dictionary <string, uint> countryToPagesLookUp;
            Dictionary <string, uint> countryToLogPagesLookUp;

            SetupCountyPagesLookups(out maxBooksPages, out maxBooksLogPages,
                                    out countryToReadLookUp, out countryToPagesLookUp, out countryToLogPagesLookUp);
            _countryToLogPagesLookUp = countryToLogPagesLookUp;

            // set up a palette based on this
            List <OxyColor> colors;
            OxyPalette      faintPalette;
            uint            numColours = 1 + countryToLogPagesLookUp.Values.OrderByDescending(x => x).FirstOrDefault();

            OxyPlotUtilities.SetupFaintPaletteForRange((int)numColours, out colors, out faintPalette, 128);

            List <OxyColor> stdColors      = OxyPlotUtilities.SetupStandardColourSet();
            int             geographyIndex = 0;

            foreach (var authorCountry in _mainModel.AuthorCountries.OrderByDescending(x => x.TotalBooksReadFromCountry))
            {
                var name    = authorCountry.Country;
                var country = _mainModel.Nations.Where(w => w.Name == name).FirstOrDefault();
                if (country != null)
                {
                    AddNationPagesPins(modelGroup, colors, authorCountry, name, country);
                }

                if (_mainModel.Nations != null && _mainModel.Nations.Count > 0)
                {
                    geographyIndex = AddNationsCountryGeographyPlane(modelGroup, stdColors, geographyIndex, name);
                }
            }

            AddGeographiesForNationsWithoutBooksRead(modelGroup);

            PagesByCountryModel = modelGroup;
        }
        private void AddColumnSeriesForMonthlyTallies(PlotModel newPlot,
                                                      Dictionary <int, List <MonthOfYearTally> > bookListsByMonthOfYear)
        {
            int colourIndex = 1;
            var colours     = OxyPlotUtilities.SetupStandardColourSet();

            foreach (var year in bookListsByMonthOfYear.Keys.ToList().OrderBy(x => x))
            {
                int    index  = colourIndex % colours.Count;
                var    colour = colours[index];
                string title  = (_chartType == ChartType.PagesAsColumns)
                    ? "Pages read in " + year.ToString()
                    : "Books read in " + year.ToString();

                var yKey = (_chartType == ChartType.PagesAsColumns)
                    ? ChartAxisKeys.PagesReadKey
                    : ChartAxisKeys.BooksReadKey;

                ColumnSeries booksReadSeries = new ColumnSeries
                {
                    Title       = title,
                    XAxisKey    = ChartAxisKeys.MonthOfYearKey,
                    YAxisKey    = yKey,
                    FillColor   = colour,
                    ColumnWidth = 13,
                };

                var monthTallies = bookListsByMonthOfYear[year];
                foreach (var monthTally in monthTallies)
                {
                    booksReadSeries.Items.Add(
                        new ColumnItem()
                    {
                        CategoryIndex = monthTally.MonthOfYear - 1,
                        Value         = (_chartType == ChartType.PagesAsColumns)
                                ? monthTally.PagesReadThisMonth
                                : monthTally.BooksReadThisMonth
                    });
                }

                newPlot.Series.Add(booksReadSeries);
                colourIndex++;
            }
        }
        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);
        }
コード例 #5
0
        private void SetupBooksReadByCountryModel()
        {
            Model3DGroup modelGroup = new Model3DGroup();

            // get the range of colours for the for the countries
            int range = _mainModel.AuthorCountries.Count > 0 ?
                        _mainModel.AuthorCountries.Select(s => s.TotalBooksReadFromCountry).Max() : 5;
            OxyPalette      faintPalette;
            List <OxyColor> colors;

            OxyPlotUtilities.SetupFaintPaletteForRange(range, out colors, out faintPalette, 128);

            List <OxyColor> stdColors      = OxyPlotUtilities.SetupStandardColourSet();
            int             geographyIndex = 0;

            foreach (var authorCountry in _mainModel.AuthorCountries.OrderByDescending(x => x.TotalBooksReadFromCountry))
            {
                var name    = authorCountry.Country;
                var country = _mainModel.WorldCountries.Where(w => w.Country == name).FirstOrDefault();
                if (country != null)
                {
                    AddCountryBooksEllipsoid(modelGroup, colors, authorCountry, name, country);
                }

                if (_mainModel.CountryGeographies != null && _mainModel.CountryGeographies.Count > 0)
                {
                    geographyIndex = AddCountryGeographyPlane(modelGroup, stdColors, geographyIndex, name);
                }
            }

            AddGeographiesForCountriesWithoutBooksRead(modelGroup);

            double       maxHeight = Math.Log(range);
            TubeVisual3D path      = GetPathForMeanReadingLocation(maxHeight);

            modelGroup.Children.Add(path.Content);

            BooksReadByCountryModel = modelGroup;
        }