예제 #1
0
        /// <summary>
        /// Sets up the pie chart series.
        /// </summary>
        protected override void SetupSeries()
        {
            // If no books return the default.
            if (BooksReadProvider == null)
            {
                base.SetupSeries();
                return;
            }

            // Get the sorted books.
            List <KeyValuePair <string, int> > sortedCountryTotals =
                BookTotalsUtilities.SortedSortedBooksReadByCountryTotals(BooksReadProvider);

            // Set up the series per county.
            Series = new SeriesCollection();
            List <ISeriesView> seriesViews = new List <ISeriesView>();
            List <Color>       colors      = ColorUtilities.SetupStandardColourSet();

            for (int i = 0; i < sortedCountryTotals.Count; i++)
            {
                KeyValuePair <string, int> countryTotal = sortedCountryTotals[i];
                Color color = colors[i % colors.Count];
                seriesViews.Add(CreatePieSeries(countryTotal.Key, countryTotal.Value, color));
            }

            Series.AddRange(seriesViews);
            SeriesCollection = Series;
        }
        /// <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));
        }