Getting Data to Point in DotNet HighChart

Oct 23, 2014 at 12:23 PM
Edited Oct 23, 2014 at 12:39 PM
Please this is my first time of implementing high chart in Mvc5 application and I have been able to do it to this extend, please check this is going to work as expected thank you for your and will really appreciate any suggestions.
public ActionResult Chart()
        {
            
            // Quering all Newly Registered Users by Day
            //var queryUsersData = _appUserService.GetAllUsers()
            //    .Where(w => w.SignupDate.Month == DateTime.Now.Month)
            //    .GroupBy(g => g.SignupDate.Day)
            //    .OrderBy(o => o.Key)
            //    .Select(grp => grp.Key)
            //    .ToArray();
                
            //int[] UserCategories = queryUsersData;
            //int[] UserData = queryUsersData.Count();

            //// Querying all Sent messages by day
            //var queryMessageData = _messageService.GetAllOutboxMessage()
            //    .Where(w => w.DateSent.Value.Month == DateTime.Now.Month)
            //    .GroupBy(g => g.DateSent.Value.Day)
            //    .OrderBy(o => o.Key)
            //    .Select(grp => grp.Key)
            //    .Count();

             var queryUsers = _appUserService.GetAllUsers();
            var queryMessage = _messageService.GetAllOutboxMessage();

            // Quering all Newly Registered Users by Day
            var users = from r in queryUsers
                        where r.SignupDate.Month == DateTime.Now.Month
                        group r by r.SignupDate.Day into gd
                        orderby gd.Key
                        select new {Day = gd.Key, Count = gd.Count()};

            int[] Categories = (from d in users select d.Day).ToArray();
            string[] resultCategories = Categories.Select(x => x.ToString()).ToArray();

            int[] userData = users.Select(x => x.Count).ToArray();
            object[] userObjArry = userData.Cast<object>().ToArray();

            // Querying all Sent messages by day
            var messages = from r in queryMessage
                        where r.DateSent.Value.Month == DateTime.Now.Month
                           group r by r.DateSent.Value.Day into gd
                        orderby gd.Key
                        select new { Day = gd.Key, Count = gd.Count() };

            //int[] messageCategories = (from d in messages select d.Day).ToArray();
            int[] messageData = messages.Select(x => x.Count).ToArray();
            object[] messageObjArry = messageData.Cast<object>().ToArray();

            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")

            .SetXAxis(new XAxis
            {
                Categories = resultCategories
            })
            .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line })
            .SetTitle(new Title { Text = "User Registration / Sent Messages Daily Record" })
            .SetSubtitle(new Subtitle { Text = "Total Count" })
            .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Approximate Count" } })

            .SetSeries(new[]{
            new Series
            {
                Name = Convert.ToString("Number of New Users"),
                Data = new Data(userObjArry)
            },
            new Series
            {
                Name = Convert.ToString("Number of messages"),
                Data = new Data(messageObjArry)
            }
            });

               return View(chart);
        }
this is it
Nov 12, 2014 at 7:39 PM
What happened when you ran the code?