Page 1 of 1

Pie Chart and List of Object Lists

Posted: Thu May 26, 2011 3:06 pm
by 15656682
Hi,

I have a little problem of understanding with the Pie Chart. I'll try to describe my problem with an example :
1°) I have one product which contains several properties which have a particular value in a specific date
2°) My ProductValueDateList contains one product's values for several date
3°) My ProductList contains several ProductValueDateList , as many as product I have.

I want my Pie Chart display the value for each product in the same date (for compare them). How can I do this ?
If you do not understand what I mean, I can draw something much easier to understand (sometime, draw is a better language than write).

This is a little complex, that's why I require your help.

Thank you =)

Re: Pie Chart and List of Object Lists

Posted: Fri May 27, 2011 1:40 pm
by 10050769
Hello Alexandre,

I think that you can achieve following doing next:

1.- Select of your productList one ProductValueDateList.
2.- Add ProducteValueDateList to Pie, that you find value as you want doing a query to date.
3.- Add value are you find in Pie and you can use name of product as label.

I hope will help.

Thanks,

Re: Pie Chart and List of Object Lists

Posted: Mon May 30, 2011 9:41 am
by 15656682
Hi Sandra,

Thank you for the answer.
I tried to follow your advices but nothing is displaying in the chart.

Here's the code I used :

Code: Select all

foreach (List<AUM> item in aListOfAumLists)
{
         pie.Add(from aum in item where aum.Date == aDate select aum.AUMPart);
}
Is there a problem with it or am I misunderstanding you ?
I don't need the ProducteValueDateList in the chart, just the value (here's AUMPart) for one specific Date.

Thanks.

Re: Pie Chart and List of Object Lists

Posted: Mon May 30, 2011 11:34 am
by 10050769
Hello Alexandre,

Ok. Can you send us, a simple project so we can reproduce exactly your problem and we can try to detected where is it occurs?

Thanks,

Re: Pie Chart and List of Object Lists

Posted: Mon May 30, 2011 1:23 pm
by 15656682
Hi Sandra,

Here's the simple project I created for you. It's a little simplistic but it's more or less what I've done in my real project.

Thank you.

Re: Pie Chart and List of Object Lists

Posted: Tue May 31, 2011 11:20 am
by 10050769
Hello Alexandre,

Seems that your problem is when you do the select. I have solved it changing next code:

Code: Select all

    foreach (List<Product> item in aListOfProductLists)
                    {
                        IEnumerable<double> result = from product in item where product.Date == aDate select product.Price;
                        
                        pie.Add(from product in item where product.Date == aDate select product.Price);
                    }
To the below lines of code:

Code: Select all

foreach (List<Product> item in aListOfProductLists)
                    {
                        IEnumerable<double> result = from product in item where product.Date == aDate select product.Price;

                        foreach (var item1 in result.ToList())
                        {
                            pie.Add(item1);
                        }
                    }
Please, do my recommendation changes in your application and tell us if these solve your problem.

I hope will helps.

Thanks,

Re: Pie Chart and List of Object Lists

Posted: Tue May 31, 2011 12:32 pm
by 15656682
Hi Sandra,

Your recommendation was very helpful and solved my problem.
Thank you very much =)

Best regards.

Re: Pie Chart and List of Object Lists

Posted: Tue May 31, 2011 1:38 pm
by 15656682
Just one more little question.
How can I add the ID corresponding to my Product in the Chart Legend ?

Thank you.

Re: Pie Chart and List of Object Lists

Posted: Tue May 31, 2011 2:10 pm
by 15656682
Sorry for the triple post (no edit function ?), but I found the solution :

var result = from aum in aumList where aum.Date == aDate select new { aum.AUMPart, aum.CodeShare };
foreach (var item in result.ToList())
{
pie.Add(item.AUMPart, item.CodeShare);
}

Thanks =)

Re: Pie Chart and List of Object Lists

Posted: Tue May 31, 2011 4:12 pm
by 10050769
Hello Alexandre,

Don't worry. I am glad that you find a solution for your problem :)

Thanks,