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

Multiple items custom labels binding

1 Answer 77 Views
Chart
This is a migrated thread and some comments may be shown as answers.
shivinder
Top achievements
Rank 1
shivinder asked on 04 Mar 2011, 12:00 AM
So i have points Data that have two members YValue and Axis Label.
i have multiple series. for each series i set the mapping as such

seriesmapping.SeriesDefinition = GetSeriesType(series.SeriesType);// right now all are line charts
            seriesmapping.CollectionIndex =index;
    ItemMapping itemMapping = new ItemMapping();
            itemMapping.DataPointMember = DataPointMember.YValue;
            itemMapping.FieldName = "YValue";
            return itemMapping;
    seriesmapping.ItemMappings.Add(ItemMapping);

Now for the labels i am taking the following approach. i tried keeping this binding for only the first series. then bind to every series
//ItemMapping itemMapping = new ItemMapping();
                //itemMapping.DataPointMember = DataPointMember.Label;// i tried both this and X category
                //itemMapping.FieldName = "AxisLabel";
                //seriesmapping.ItemMappings.Add(itemMapping);

with one series the labels work (i have other issues but they are mentioned in my last question). but adding multiple series and trying to bind the labels it does not work . what am i doing wrong.

Also. i dont want display certain points. these points i have as NAN. but you guys graph that and makes my graph look awful. is there anyway i can not display NAN.

1 Answer, 1 is accepted

Sort by
0
Missing User
answered on 09 Mar 2011, 02:00 PM
Hello shivinder,

When creating the chart data mappings in the code behind you need to create each SeriesMapping and its ItemMappings and add the mapping to the RadChart.SeriesMappings. You can try the following approach:

for (int i = 0; i < testData.Count; i++)
{
    SeriesMapping seriesmapping = new SeriesMapping();
    seriesmapping.SeriesDefinition = new LineSeriesDefinition();
    seriesmapping.CollectionIndex = i;
 
    ItemMapping itemMapping = new ItemMapping();
    itemMapping.DataPointMember = DataPointMember.YValue;
    itemMapping.FieldName = "YValue";
    seriesmapping.ItemMappings.Add(itemMapping);
 
    ItemMapping itemMapping2 = new ItemMapping();
    itemMapping2.DataPointMember = DataPointMember.Label;
    itemMapping2.FieldName = "AxisLabel";
    seriesmapping.ItemMappings.Add(itemMapping2);
 
    chart.SeriesMappings.Add(seriesmapping);
}

More information about Data Binding to Nested Collections can be found here.

If you have empty values that you want to hide you can use empty/null values functionality that will be introduced with the upcoming Q1 2011 version of the Chart control. In your case when you have NaN values, you can convert them to null. More information about this feature can be found in this blog post.

I hope this helps.

Regards,
Polina
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Chart
Asked by
shivinder
Top achievements
Rank 1
Answers by
Missing User
Share this question
or