.NET Framework Bookmark and Share   
 index > Chart Controls for .NET Framework > Bind chart series to object
 

Bind chart series to object

Apologies if this is a horrible newbie question, I'm still learning.

I have a Class representation of my data which contains some Properties I want on my chart and some I don't. If I were feeding a ListView with an ObjectDataSource, I could feed the ASP.NETtemplate with the values I need using Eval("Item1"). In trying to getObjectDataSource values into a chart I am having some problems. It's probably my approach.

What I think I would like to do is programmatically access these Properties in the code-behind, assign them to variables, and then feed these variables into an array... something like:

// Get the yval Properties from an ObjectDataSource
double item1 = somehow get the Property???; 
double item2 = somehow get the Property???; 
double item3 = somehow get the Property???; 
double item4 = somehow get the Property???; 

double[] yval = { item1, item2, item3, item4 };

// Hardcode the xval Properties for now
string[] xval { "Item1", "Item2", "Item3", "Item4" };


chart1.series["MySeries"].Points.DataBindXY(xval, yval);
Does anyone have an example for grabbing ObjectDataSource Properties and sticking them into variables... or is my whole approach horrible?

Thanks,

Deak
  • Edited byDeak Wednesday, September 02, 2009 12:27 PMtypos
  •  
Deak
I suggest you to check out the Chart Sample Environment, which can be downloaded from here: http://code.msdn.microsoft.com/mschart.

Chart can easily bind to any enumerable sourec. Have you considered using LINQ to objects?

Alex.
http://blogs.msdn.com/alexgor
Alex Gorev

You can use google to search for other answers

Custom Search

More Threads

• Need .Net component for ontology graphics
• javascript postback for chart imageclick does not work on IE 7,8. Works on FF and Opera.
• Multiple X-Axis Values
• Display percentage and value in data labels?
• Printed chart looks different to that on screen
• problem of path of ChartImg.axd
• DataBindCrossTable giving a IEnumerable error
• tick marks show through markers
• Changing the AxisLabel color
• Does the install touch the .Net framework?