protected void BuildBookAmountModel(NameAmountDelegate entityNameBookAmountDelegate) { // gets entities' names and amount of book for each entity IEnumerable <KeyValuePair <string, int> > bookAmountForEntities = entityNameBookAmountDelegate(); // create plane PlotModel bookAmountModel = new PlotModel(); // add axes // add bottom axis with entities' names bookAmountModel.Axes.Add(new CategoryAxis { Position = AxisPosition.Bottom, ItemsSource = bookAmountForEntities.Select(x => new { Name = x.Key }), // select names LabelField = "Name", // sets name label Angle = 15, Maximum = bookAmountForEntities.Count() >= 8 ? 8 : double.NaN, IsPanEnabled = true, }); // add left axis, no scrolling bookAmountModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, IsPanEnabled = false }); // add column series bookAmountModel.Series.Add(new ColumnSeries { FillColor = GraphColor, ItemsSource = bookAmountForEntities.Select(x => new ColumnItem(x.Value)) }); // initialize fields this.bookAmountModel = bookAmountModel; }
protected void BuildBestEntityModel(NameAmountDelegate entityNameTakenBookAmountDelegate) { // gets entities' name and amount of abonnements of current entities IEnumerable <KeyValuePair <string, int> > entityPopularity = entityNameTakenBookAmountDelegate(); // create plane PlotModel entityPopularitytModel = new PlotModel(); // add axes // add bottom axis with entitys' names entityPopularitytModel.Axes.Add(new CategoryAxis { Position = AxisPosition.Bottom, ItemsSource = entityPopularity.Select(x => new { Name = x.Key }), // select names LabelField = "Name", // sets name label Angle = 15, Maximum = entityPopularity.Count() >= 8 ? 8 : double.NaN }); // add left axis, no scrolling entityPopularitytModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, IsPanEnabled = false }); // add column series entityPopularitytModel.Series.Add(new ColumnSeries { FillColor = GraphColor, ItemsSource = entityPopularity.Select(x => new ColumnItem(x.Value)) }); // initialize fields this.bestEntityPerBook = entityPopularitytModel; }