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

GridView.Items.Groups.Count

7 Answers 128 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thomas Garp
Top achievements
Rank 1
Thomas Garp asked on 16 Mar 2010, 10:51 AM

I'm using both the Gridview and the chart - as used in the Grouping and aggregation example on the demo site.

I have an issue when getting many results in a group (resulting in many bars:  aprox. 100 bars)
All the bars will not be drawn! Only some of them!

So I tried to swith the axis - and use a horizontial barseries instead of the barseries
The logic should be - if a group has more than 10 items - use an horizontal instead - otherwise - use the normal barseries.
In the Gridview_Grouped event - I'm binding the chart:

 

 

 

 

int groupCount = 0;  
var gridViewItems = GridView.Items as DataItemCollection;  
groupCount = gridViewItems.Groups == null ? 0 : gridViewItems.Groups.Count;  
if (groupCount > 10)  
{  
  var series1 = new HorizontalBarSeriesDefinition();  
  mapping1.SeriesDefinition = series1;  
}  
else  
{  
  var series1 = new BarSeriesDefinition();  
  mapping1.SeriesDefinition = series1;  
}  
 

The issue is:
When the GridView_grouped event is called, the gridViewItems.Groups is != null BUT the count is 0
If I recal the function  - the gridviewItems.Groups.Count is correct, and everything works.
And of course - the issue in the first place was - not all bars are drawn when you have a large number of bars.

Kind regards

 

 

7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 18 Mar 2010, 11:36 AM
Hi Thomas,

You can use Dispatcher to avoid this - I've attached an example project.

Sincerely yours,
Vlad
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
Thomas Garp
Top achievements
Rank 1
answered on 18 Mar 2010, 04:38 PM
That's great.
It worked.

Now the other issue - with the RadChart. Should I post it in another forum?

If I have many bars - not all of the bars are drawn. It seems random.
I've used the sample from the demo site.

//sets the mapping as HorizontalbarSeriesDefinition  
var columnMapping = GetColumnMapping(groupCount);  
                if (gridView.GroupDescriptors.Count > 0)  
                {  
                    var count = 0;  
                    foreach (var descriptor in gridView.GroupDescriptors)  
                    {                        columnMapping.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor(descriptor.Member));  
                        count++;  
                    }  
 
                    var lastGroupDescriptor = gridView.GroupDescriptors[gridView.GroupDescriptors.Count - 1];  
                    columnMapping.ItemMappings.Add(new ItemMapping(lastGroupDescriptor.Member, DataPointMember.XCategory));  
 
                }  
                Chart.SeriesMappings.Add(columnMapping);  
//gets the filtered source from the gridview  
                var chartSource = GetChartSource();  
                Chart.ItemsSource = chartSource
0
Velin
Telerik team
answered on 23 Mar 2010, 07:06 PM
Hello Thomas Garp,

This situation occurs when you have too many visual items on a limited visual space. Let me explain in more details: When you add a certain number of series to the control, the available space is equally divided to N parts where N is the maximum number of items contained in a single series. Then, each of these parts is divided to the number of series and the result is multiplied by the ChartArea.ItemWidthPercent property value (defaulting to 80 percents). That said, when you have large amount of data contained into multiple bar series there might be a condition when the calculated width of the bar is less than one pixel and the bar simply disappears.

What we would recommend you in this scenario is to put the chart control into a scroll viewer and set its height to a value that would allow all the data to render correctly.

Hope this will help.

Kind regards,
Velin
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
Thomas Garp
Top achievements
Rank 1
answered on 24 Mar 2010, 04:12 PM
I've tried this - setting the height to 6000px.
It would seem that this haven't helped, even though there is plenty of room for each bar?

See attached file.
0
Velin
Telerik team
answered on 26 Mar 2010, 11:09 AM
Hi Thomas Garp,

I would like to suggest you a different approach to set up your chart control in order to avoid this situation. Instead of having large number of DataSeries objects with just one(or a few) DataPoints, you could have a single HorizontalBar Series containing all the points. The key modifications are as follow:
  1. Use single data series with HorizontalBarSeriesDefinition.
  2. The LegendDisplayMode property of the definition is set to DataPointLabel. This makes the bars appear in different color.
  3. Map the same field from the items source as XCategory and LegendLabel.

You can find attached a sample project. Please, give it a try and share your feedback with us.

Kind regards,
Velin
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
Thomas Garp
Top achievements
Rank 1
answered on 14 Apr 2010, 01:23 PM
Hi.
I only have one dataseries?
I'm using the code from a sample on your demosite - just customized a bit.
http://demos.telerik.com/silverlight/#Chart/Aggregates

It uses the groups from the GridView. The only difference is, that I'm checking the number of groups - and thereby decide wheter to use Horizontal og "normal" bar series.

Could you please help me, customizing the aggregatessample to work with + 100 series? I'm not sure how to create the itemmappings etc.
0
Velin
Telerik team
answered on 16 Apr 2010, 01:41 PM
Hello Thomas Garp,

Have you tried to set the GroupingSettings.ShouldCreateSeriesForLastGroup property to true in your SeriesMapping objects.

Please, give it a try and let us know whether this solves the problem.

Best wishes,
Velin
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.
Tags
GridView
Asked by
Thomas Garp
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Thomas Garp
Top achievements
Rank 1
Velin
Telerik team
Share this question
or