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
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.
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; |
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.
It would seem that this haven't helped, even though there is plenty of room for each bar?
See attached file.
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:
- Use single data series with HorizontalBarSeriesDefinition.
- The LegendDisplayMode property of the definition is set to DataPointLabel. This makes the bars appear in different color.
- 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.
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.
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.