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

  • SEARCH
  • Home
  • 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 639855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:53:19+00:00 2026-05-13T20:53:19+00:00

I am using a charting javascript library that expects its data in a specific

  • 0

I am using a charting javascript library that expects its data in a specific JSON format – without property names.
I have an object in my Model that I am using to return the data to the charts. This looks as follows:

public class ChartData
{
    public string Key { get; set; }
    public int Value { get; set; }
}

An action looks as follows:

public ActionResult AssetsPerFloor(Guid id)
    {
        var results = from a in surveyRepository.GetAssetsForBuidling(id)
                      group a by a.Room.Floor into g
                      select new ChartData{ Key = g.Key.ToString(), Value = g.Count() };
        return Json(results);
    }

This returns JSON in the format [{"Key":"Main Building","Value":1}]

However, the chart requires no property names, eg: [[5, 2], [6, 3], [8, 2]]

Is there anyway I can return the results in this format. I’m sure there’s a simple trick to it, but I cant think of it.

  • 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-13T20:53:20+00:00Added an answer on May 13, 2026 at 8:53 pm

    As far as I understand, it needs to return a multi-dimensional array. Try this :

    var results = 
        (from a in surveyRepository.GetAssetsForBuidling(id)
            group a by a.Room.Floor into g
            select new ChartData{ Key = g.Key.ToString(), Value = g.Count() })
            .Select(x => new string[] { x.Key, x.Value.ToString() };
    return Json(results);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a horizontal bar graph using gRaphael charting library. I want to
I'm looking for javascript libraries that draw graphs using the Raphael library. Until now
I'm using the' System.Windows.Forms.DataVisualization.Charting ' library for my chart and I was wondering if
I planned on using the jquery charting library flot; before embarking on this adventure
I am using the highcharts charting library, i am including excanvas if the browser
i have a big problem here..i am using Microsoft charting controls in my asp.net
I'm using the ASP.NET charting library (System.Web.UI.DataVisualization.Charting) and the SeriesChartType enumeration has a ton
I have been using DataVisualization.Charting.Chart to produce few charts. Everything works very well, until
I am using JFreeChart ( http://www.jfree.org/jfreechart/ ) as a charting library. But for Android
I am using NPlot charting library to draw several plots illustrating signal fluctuations. The

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.