Beispiel #1
0
        public void SetUp()
        {
            _axisTicksDefault = new AxisTicks();
            var ticksValues = Generate.LinearRange(-2, 0.5, 2);

            _axisTicksCompleteCttr = new AxisTicks(ticksValues, AxisName.Z);
        }
Beispiel #2
0
    /// <summary>
    /// Participation points overview
    /// </summary>
    /// <param name="commandContext">Command context</param>
    /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
    public async Task PostParticipationOverview(CommandContextContainer commandContext)
    {
        using (var dbFactory = RepositoryFactory.CreateInstance())
        {
            var users = dbFactory.GetRepository <RaidCurrentUserPointsRepository>()
                        .GetQuery()
                        .OrderByDescending(obj => obj.Points)
                        .Select(obj => new
            {
                UserId = obj.User
                         .DiscordAccounts
                         .Select(obj2 => obj2.Id)
                         .FirstOrDefault(),
                Points = obj.Points * 100.0
            })
                        .ToList();

            if (users.Count > 0)
            {
                var embedBuilder   = new DiscordEmbedBuilder();
                var messageBuilder = new DiscordMessageBuilder();
                embedBuilder.WithTitle(LocalizationGroup.GetText("ParticipationOverview", "Participation points overview"));
                embedBuilder.WithColor(DiscordColor.DarkBlue);
                embedBuilder.WithImageUrl("attachment://chart.png");

                var userNames = new List <string>();
                foreach (var user in users)
                {
                    var member = await commandContext.Guild
                                 .GetMemberAsync(user.UserId)
                                 .ConfigureAwait(false);

                    userNames.Add($"{(string.IsNullOrWhiteSpace(member.Nickname) ? string.IsNullOrWhiteSpace(member.DisplayName) ? member.Username : member.DisplayName : member.Nickname)} [{user.Points:0.00}]");
                }

                var chartConfiguration = new ChartConfigurationData
                {
                    Type = "horizontalBar",
                    Data = new Data.Json.QuickChart.Data
                    {
                        DataSets = new List <DataSet>
                        {
                            new DataSet <double>
                            {
                                BackgroundColor = users.Select(obj => "#316ed5")
                                                  .ToList(),
                                BorderColor = "#274d85",
                                Data        = users.Select(obj => obj.Points)
                                              .ToList()
                            }
                        },
                        Labels = userNames
                    },
                    Options = new OptionsCollection
                    {
                        Scales = new ScalesCollection
                        {
                            XAxes = new List <XAxis>
                            {
                                new ()
                                {
                                    Ticks = new AxisTicks <double>
                                    {
                                        MinValue  = 0,
                                        MaxValue  = Math.Ceiling(((users.Max(obj => obj.Points) / 10) + 1) * 10),
                                        FontColor = "#b3b3b3"
                                    }
                                }
                            },
Beispiel #3
0
    /// <summary>
    /// Post worlds overview
    /// </summary>
    /// <param name="commandContext">Command context</param>
    /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
    public async Task PostWorldsOverview(CommandContextContainer commandContext)
    {
        using (var dbFactory = RepositoryFactory.CreateInstance())
        {
            var worldsQuery = dbFactory.GetRepository <GuildWarsWorldRepository>()
                              .GetQuery()
                              .Select(obj => obj);

            var worlds = dbFactory.GetRepository <AccountRepository>()
                         .GetQuery()
                         .Where(obj => obj.WorldId != null)
                         .GroupBy(obj => obj.WorldId)
                         .Select(obj => new
            {
                WorldId = obj.Key,
                Count   = obj.Count(),
                Name    = worldsQuery.Where(obj2 => obj2.Id == obj.Key)
                          .Select(obj2 => obj2.Name)
                          .FirstOrDefault()
            })
                         .ToList();

            if (worlds.Count > 0)
            {
                var embedBuilder   = new DiscordEmbedBuilder();
                var messageBuilder = new DiscordMessageBuilder();

                embedBuilder.WithTitle(LocalizationGroup.GetText("Overview", "Worlds overview"));
                embedBuilder.WithColor(DiscordColor.DarkBlue);
                embedBuilder.WithImageUrl("attachment://chart.png");

                var chartConfiguration = new ChartConfigurationData
                {
                    Type = "bar",
                    Data = new Data.Json.QuickChart.Data
                    {
                        DataSets = new List <DataSet>
                        {
                            new DataSet <int>
                            {
                                BackgroundColor = worlds.Select(obj => "#316ed5")
                                                  .ToList(),
                                BorderColor = "#274d85",
                                Data        = worlds.OrderByDescending(obj => obj.Count)
                                              .ThenBy(obj => obj.Name)
                                              .Select(obj => obj.Count)
                                              .ToList()
                            }
                        },
                        Labels = worlds.OrderByDescending(obj => obj.Count)
                                 .ThenBy(obj => obj.Name)
                                 .Select(obj => obj.Name)
                                 .ToList()
                    },
                    Options = new OptionsCollection
                    {
                        Scales = new ScalesCollection
                        {
                            XAxes = new List <XAxis>
                            {
                                new ()
                                {
                                    Ticks = new AxisTicks
                                    {
                                        FontColor = "#b3b3b3"
                                    }
                                }
                            },