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

RadChart SeriesMapping CollectionIndex - Required and Order-Dependent?

4 Answers 132 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 15 Aug 2011, 10:34 PM

Hello!

We recently upgraded to version 2011.2.712.1040 and we are seeing some unexpected behavior from the RadChart that was not present before.  Upgrading the Telerik DLLs exposed the issue. 

The problem is present when multiple series are charted.  The example shown here can serve as a guide.
http://www.telerik.com/help/wpf/radchart-populating-with-data-data-binding-to-nested-collections.html

Notice the use of CollectionIndex ...

//Series mapping for the collection with index 1
seriesMapping = new SeriesMapping();
seriesMapping.CollectionIndex = 1;
seriesMapping.LegendLabel = "MSFT";
seriesMapping.SeriesDefinition = new LineSeriesDefinition();
seriesMapping.SeriesDefinition.ShowItemLabels = false;
itemMapping = new ItemMapping();
itemMapping.DataPointMember = DataPointMember.YValue;
itemMapping.FieldName = "Close";
seriesMapping.ItemMappings.Add( itemMapping );
this.radChart.SeriesMappings.Add( seriesMapping );

Issue 1.  CollectionIndex is implicitly required?  See line 3 above.  In the newer version, the SeriesMapping Collection will no longer implicitly handle series that are added without a CollectionIndex?  What we see is that if you do not set CollectionIndex and you chart multiple series... only the last added series will chart.  Leaving CollectionIndex at -1 (the default) will cause charting problems with multiple series.

Is this the intended behavior?  Do we now have to manage the CollectionIndex on each individual item instead of letting the collection implicitly manage child object indexes by default?  Now individual items are responsible for this?  Seems odd.  Can you confirm?

Issue 2.  CollectionIndex is order dependent?  It seems that if you set CollectionIndex last, before adding the mapping to the SeriesMapping collection instead of first (as shown above), then the LegendLabel that was set will be ignored.  What we see is that LegendLabel must be set AFTER CollectionIndex or the LegendLabel will not show.  This seems odd as well.  Can you confirm this issue also?

Obviously the workarounds are easy (after tracking down the issue).  We now explicitly set CollectionIndex and we set it first (not last).  But these seem like unnecessary, hidden dependencies.

Thanks!

4 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 18 Aug 2011, 11:43 AM
Hi Tim,

Thanks for the detailed description. Onto the issues:
  • Issue 1: The CollectionIndex property has always been an essential part of the feature and implicit handling has not been officially supported. Please, consider this as the correct implementation.
  • Issue 2: I was not able to reproduce this. Here is the code from my test page:
//Series mapping for the collection with index 1
seriesMapping = new SeriesMapping();
//seriesMapping.CollectionIndex = 1;
seriesMapping.LegendLabel = "MSFT";
seriesMapping.SeriesDefinition = new LineSeriesDefinition();
seriesMapping.SeriesDefinition.ShowItemLabels = false;
itemMapping = new ItemMapping();
itemMapping.DataPointMember = DataPointMember.YValue;
itemMapping.FieldName = "Close";
seriesMapping.ItemMappings.Add(itemMapping);
//seriesMapping.CollectionIndex = 1;
this.radChart.SeriesMappings.Add(seriesMapping);
//seriesMapping.CollectionIndex = 1;
this.radChart.ItemsSource = sampleData;

I tried with any of the three commented lines (one at a time) and it still worked fine. Is there anything I might be missing?

Best regards,
Ves
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Tim
Top achievements
Rank 1
answered on 18 Aug 2011, 04:23 PM
Ves,

Thank you for your timely response and investigation!

1.  CollectionIndex must be set.  We have never used CollectionIndex with earlier versions and it responded well with multiple series.  We assumed it was managing this on it's own.  With the upgrade to the newest version, it appears that it became required for good behavior, so we have now started using it and never let it keep the default of -1.  Easy enough.

2. CollectionIndex set after LegendLabel clears the LegendLabel.  We are noticing this behavior if multiple series are used.  We set the LegendLabel for each SeriesMapping and all other properties as normal.   Now, just before adding the SeriesMapping to the collection, we set the CollectionIndex (due to #1).  To re-create our issue, please do this for all SeriesMappings added, not just the last one.  The last one will behave well, but the ones added earlier will lose their LegendLabel.  In the example above, it seems that you are only setting it for the last series added?

Thanks again,

Tim

0
Accepted
Ves
Telerik team
answered on 23 Aug 2011, 11:50 AM
Hello Tim,

I have attached my test page. I have followed your notes, but I must be missing something. It works correctly for me with the latest official assemblies, version 2011.2.712.1040.

Best regards,
Ves
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Tim
Top achievements
Rank 1
answered on 23 Aug 2011, 04:33 PM
Ves,

I cannot recreate the problem using your example.  (It works great!)  This means that our issue is related to something more complicated that we are doing on our side.  Because our workarounds are working for us, I will leave them as is, but others should not need them based on the sample that you have provided.  Thank you for working with us on this issue.
Tags
Chart
Asked by
Tim
Top achievements
Rank 1
Answers by
Ves
Telerik team
Tim
Top achievements
Rank 1
Share this question
or