Hi,
is it possible to have multiple lines in a same chart using different seriesmapping object?
To be more clear, i have 2 "List<StructXY>" where "StructXY" is a structure with two field(double x, double y).
i have a "List<List<StructXY>>" collection and i want to bind 2 different seriesmapping(to draw two independant lines) in my chart based on the x and y value of eah collection.
Thanks in advance if you can give me a simple working C# example.
is it possible to have multiple lines in a same chart using different seriesmapping object?
To be more clear, i have 2 "List<StructXY>" where "StructXY" is a structure with two field(double x, double y).
i have a "List<List<StructXY>>" collection and i want to bind 2 different seriesmapping(to draw two independant lines) in my chart based on the x and y value of eah collection.
Thanks in advance if you can give me a simple working C# example.
3 Answers, 1 is accepted
0
Enill
Top achievements
Rank 1
answered on 21 May 2010, 11:41 PM
Here is my test project(The reference to collectionindex = 1 just doesnt work at all):
namespace seriesmapping_test |
{ |
public partial class MainPage : UserControl |
{ |
public struct structXY |
{ |
public double valueX { get; set; } |
public double valueY { get; set; } |
} |
public MainPage() |
{ |
InitializeComponent(); |
RadChart rc = new RadChart(); |
List<List<structXY>> lstMain = new List<List<structXY>>(); |
List<structXY> lst1 = new List<structXY>(); |
List<structXY> lst2 = new List<structXY>(); |
SeriesMapping sm1 = new SeriesMapping() |
{ |
SeriesDefinition = new LineSeriesDefinition() |
{ |
ShowItemLabels = false |
} |
}; |
sm1.CollectionIndex = 1; |
sm1.ItemMappings.Add(new ItemMapping("valueX", DataPointMember.XValue)); |
sm1.ItemMappings.Add(new ItemMapping("valueY", DataPointMember.YValue)); |
SeriesMapping sm2 = new SeriesMapping() |
{ |
SeriesDefinition = new BarSeriesDefinition |
{ |
ShowItemLabels = false |
} |
}; |
sm2.CollectionIndex = 1; |
sm2.ItemMappings.Add(new ItemMapping("valueX", DataPointMember.XValue)); |
sm2.ItemMappings.Add(new ItemMapping("valueY", DataPointMember.YValue)); |
rc.SeriesMappings.Add(sm1); |
rc.SeriesMappings.Add(sm2); |
for (int i = 0; i < 100; i++) |
{ |
lst1.Add(new structXY() { valueX = i, valueY = i }); |
lst2.Add(new structXY() { valueX = i, valueY = i ^ i }); |
} |
lstMain.Add(lst1); |
lstMain.Add(lst2); |
rc.PaletteBrushes.Add(new SolidColorBrush(Colors.Red)); |
rc.PaletteBrushes.Add(new SolidColorBrush(Colors.Green)); |
rc.ItemsSource = lstMain; |
LayoutRoot.Children.Add(rc); |
} |
} |
} |
0
Hi Enill,
I reviewed your code and I found two possible issues:
Greetings,
Ves
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
I reviewed your code and I found two possible issues:
- CollectionIndex is set to 1 for both series definitions
- valueY = i ^ i -- this always sets valueY with 0, try changing it to i*i or i*5
Greetings,
Ves
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Enill
Top achievements
Rank 1
answered on 26 May 2010, 01:45 PM
Hi,
actually i noticed that i didnt posted the good code block, i apologies.
The correct code block did'nt had the i ^ i , it was for a test purpose.
Also, as you pointed, both collection were pointing to CollectionIndex = 1, it was my mistake, lack of awareness.
Thanks you!
actually i noticed that i didnt posted the good code block, i apologies.
The correct code block did'nt had the i ^ i , it was for a test purpose.
Also, as you pointed, both collection were pointing to CollectionIndex = 1, it was my mistake, lack of awareness.
Thanks you!