This is a migrated thread and some comments may be shown as answers.

Does ItemMapping support dot notation?

1 Answer 67 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Maxim
Top achievements
Rank 2
Maxim asked on 28 Jan 2011, 04:59 PM
If I have two classes as follows:
public class Defect
{
    public DateTime DefectDate { get; set; }
    public double QuanityDefective { get; set; }
    public Customer CustomerName { get; set; }
}

public class Customer
{
    public string Name { get; set; }
    public string City { get; set; }
}

If I bind my chart to an ObservableCollection of Defect, can I map the Xaxis field as Customer.Name?

1 Answer, 1 is accepted

Sort by
0
Accepted
Yavor
Telerik team
answered on 02 Feb 2011, 09:25 AM
Hi Jeff,

Indeed, you can set the itemmapping to a nested property. This may look something like this:

public class MyClass
   {
       public test _yvalue;
       public test MyClassProperty
       {
           get
           {
               return this._yvalue;
           }
           set
           {
               this._yvalue = value;
           }
       }
   }
   public class test
   {
       int _innerValue;
       public int InnerValue
       {
           get
           {
               return _innerValue;
           }
           set
           {
               _innerValue = value;
           }
       }
   }

public MainPage()
       {
           InitializeComponent();
             
           List<MyClass> chartDataSource = new List<MyClass> ();
           test innerEntry;
           MyClass entry = new MyClass();
           innerEntry = new test();
           innerEntry.InnerValue = 12;
           entry.MyClassProperty = innerEntry;
           chartDataSource.Add(entry);
           entry = new MyClass();
           innerEntry = new test();
           innerEntry.InnerValue = 4;
           entry.MyClassProperty = innerEntry;
           chartDataSource.Add(entry);
                        
           SeriesMapping mapping1 = new SeriesMapping();
           mapping1.SeriesDefinition = new PieSeriesDefinition();
           mapping1.SeriesDefinition.InteractivitySettings.SelectionMode = ChartSelectionMode.Single;
           mapping1.SeriesDefinition.InteractivitySettings.SelectionScope = InteractivityScope.Item;
           ItemMapping itemmaping1 = new ItemMapping();
           itemmaping1.DataPointMember = DataPointMember.YValue;
           itemmaping1.FieldName = "MyClassProperty.InnerValue";
           mapping1.ItemMappings.Add(itemmaping1);
           RadChart1.SeriesMappings.Add(mapping1);
           
           RadChart1.ItemsSource = chartDataSource;
            
       }

I hope this information helps.

All the best,
Yavor
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
Chart
Asked by
Maxim
Top achievements
Rank 2
Answers by
Yavor
Telerik team
Share this question
or