Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6189975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:30:21+00:00 2026-05-24T02:30:21+00:00

Hi i’m passing a List object from my controller to Javascript where it is

  • 0

Hi i’m passing a List object from my controller to Javascript where it is put back into an array and used as a data source for HighChart bar graph.

In my code below if i comment back in the raw data it WORKS. If I use my array variable called ‘result’ I get nothing

If I step into Javascript with debugger and output result to immediate window it looks like:

?result[0]
{…}
[0]: “2”
[1]: {…}

?result[0][1]
{…}
[0]: 0
[1]: 0
[2]: 0
[3]: 0
[4]: 0
[5]: 0
[6]: 1
[7]: 0
[8]: 0
[9]: 0
[10]: 0
[11]: 0

HERE IS THE CODE :

function CreateChart3(surl) {

    // Code block for fetching Array as jsonResult (js)
    var url = $("#AbsolutePath").val() + "Complaint.mvc/GetChartData_MonthlyByType/" + surl;

    var chart;

    $.getJSON(url, null, function(data) {

        var result = [];
        jQuery.each(data, function(i, val) {
            result[i] = [val.Type, val.Count];
        });

        //            var seriesData = [];
        //            for (var i = 0; i < result.length; i++) {
        //                seriesData.push({ data: result[i][1] ,name: result[i][0]});
        //            }

        debugger;
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'chart3',
                defaultSeriesType: 'column',
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            },
            title: {
                text: 'Stacked Bar Monthly By Type'
            },
            yAxis: {
                min: 0,
                title: {
                    text: 'Total No Of Complaints'
                },
                xAxis: {
                    categories: ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'],
                    title: 'Month'
                },
                stackLabels: {
                    enabled: true,
                    style: {
                        fontWeight: 'bold',
                        color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
                    }
                }
            },
            legend: {
                backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
                borderColor: '#CCC',
                borderWidth: 1,
                shadow: false
            },
            tooltip: {
                formatter: function() {
                    return '<b>' + this.x + '</b><br/>' +
            this.series.name + ': ' + this.y + '<br/>' +
            'Total: ' + this.point.stackTotal;
                }
            },
            plotOptions: {
                column: {
                    stacking: 'normal',
                    dataLabels: {
                        enabled: true,
                        color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
                    }
                }
            },
            //                            series:
            //                                 [{
            //                                    name: "2",
            //                                    data: [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
            //                                        }, {
            //                                    name: "3",
            //                                    data: [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 3, 0]

            //                                    }]
            series: [{
                data: result
                }]
            });
        });
    };

EXTRACT FROM CONTROLLER CODE IF IT HELPS……

         var qry = from i in _db.Complaints
                  where i.Site.SiteDescription.Contains(searchTextSite)
                       && (i.Raised >= startDate && i.Raised <= endDate)
                  group i by i.ComplaintNatureTypeId.ToString()
                      into grp
                      select new
                          {
                              Type = grp.Key,
                              Count = new int[] { 
                                  grp.Where(c => c.Raised.Month == 1).Count(),
                                      grp.Where(c => c.Raised.Month == 2).Count(),
                                      grp.Where(c => c.Raised.Month == 3).Count(),
                                      grp.Where(c => c.Raised.Month == 4).Count(),
                                      grp.Where(c => c.Raised.Month == 5).Count(),
                                      grp.Where(c => c.Raised.Month == 6).Count(),
                                      grp.Where(c => c.Raised.Month == 7).Count(),
                                      grp.Where(c => c.Raised.Month == 8).Count(),
                                      grp.Where(c => c.Raised.Month == 9).Count() ,
                                      grp.Where(c => c.Raised.Month == 10).Count() ,
                                      grp.Where(c => c.Raised.Month == 11).Count(),
                                      grp.Where(c => c.Raised.Month == 12).Count() }

                          };


        return Json(qry.ToArray(), JsonRequestBehavior.AllowGet);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:30:22+00:00Added an answer on May 24, 2026 at 2:30 am

    As I remember data property of series is array of

    1. y-values
    2. pair of x-y values
    3. point objects

    As I understand every element of your array is array where element[0] is name and element[1] is array of y-values. So you have some number of series. You have to convert manually you result into array of { name: ..., data: ...} objects and pass it to HighCharts constructor. Use for loop:

    var seriesData = [];
    for (var i = 0; i < result.length; i++){
        seriesData.push({ name: result[i][0], data: result[i][1] });
    }
    

    And use series data like:

    series: seriesData
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.