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 6659933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:05:31+00:00 2026-05-26T02:05:31+00:00

I have an IEnumerable (List<>) of a particular Type. The Type has a set

  • 0

I have an IEnumerable (List<>) of a particular Type. The Type has a set of properties which I would like to chart as individual series (MVC3/Razor).

Is there a way I can transpose the data in the list of objects into a list of the properties?

e.g.
Given the code below, the end result I am trying to acheive is a set of Series so I have

Bucket1: IEnumerable<Date, Value>
Bucket2: IEnumerable<Date, Value>
etc

So that I can then chart each series to get a line chart with Date on x and value on y, for (in this example) 3 series/lines. This code works perfectly, but just feels wrong somehow?

 var buckets = new List<Bucket>(){
            new Bucket{
                    Date=DateTime.Today.AddDays(-3),
                    Bucket1=1000,
                    Bucket2=2000,
                    Bucket3=3000},
                new Bucket{
                    Date=DateTime.Today.AddDays(-2),
                    Bucket1=1000,
                    Bucket2=2020,
                    Bucket3=3300},
                new Bucket{
                    Date=DateTime.Today.AddDays(-1),
                    Bucket1=1000,
                    Bucket2=2040,
                    Bucket3=3600}
        };

        var chart = new Chart(){ Height = 400, Width = 600 };
        var area = new ChartArea();
        chart.ChartAreas.Add(area);

        var series1 = chart.Series.Add("Bucket 1");
        var series2 = chart.Series.Add("Bucket 2");
        var series3 = chart.Series.Add("Bucket 3");
        foreach (var series in chart.Series)
        {
            series.ChartType = SeriesChartType.Line;
        }

        foreach (var item in buckets)
        {
            series1.Points.AddXY(item.Date, item.Bucket1);
            series2.Points.AddXY(item.Date, item.Bucket2);
            series3.Points.AddXY(item.Date, item.Bucket3);
        }
  • 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-26T02:05:32+00:00Added an answer on May 26, 2026 at 2:05 am

    Thanks to the comments posted I kept my original code and don’t think there’s an easier way to do this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have variable of type IEnumerable<List<string>> is there a LINQ statement or lambda
I have an IEnumerable object. I would like to access based on index for
I have two IEnumerable collections that I would like to union. One selects news
I have a List/IEnumerable of objects and I'd like to perform a calculation on
Suppose I have an IEnumerable such as a List(TValue) and I want to keep
Say I have: public ViewResult List() { IEnumerable<IModel> myList = repository.GetMyList(); if(1 == myList.Count())
If I have a list of objects IEnumerable<MyType> myTypes; Is it possible for me
I have the following code: List<T> list = new List<T>(); IEnumerable<T> query1 = ...
I have IEnumerable<MyData> which contains following data Fruits | Name | Quantity | __________________________
LinQ contains the method Cast which casts each entry in the list to type

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.