This question is locked. New answers and comments are not allowed.
Hi,
I am currently using Silverlight 4, and Telerik.Windows.Controls.Charting v 2011.1.315.1040
Can you help me without doing an upgrade?
without pointing me to your demos (because they are on silverlight 5) Can you please help?
I am trying to create a bar chart with a Category on the X Axis. Each Category will contain 3 (unstacked) bars representing JobCount, EstHrs, ActHrs. I am attaching an excel spreadsheet to show you exactly how I need the data to look.
I have gone about this several different ways and haven't got it to work.
I have created a BarchartItem to hold the data that looks like this:
I have created a xaml that looks like this:
I get an error: Exception has been thrown by the target of an invocation when I try to assign my data to the DataContext
I also tried grouping the data myself:
and put it into a different XAML like this:
and I get no data. Can you help me please to get this to work?
I am currently using Silverlight 4, and Telerik.Windows.Controls.Charting v 2011.1.315.1040
Can you help me without doing an upgrade?
without pointing me to your demos (because they are on silverlight 5) Can you please help?
I am trying to create a bar chart with a Category on the X Axis. Each Category will contain 3 (unstacked) bars representing JobCount, EstHrs, ActHrs. I am attaching an excel spreadsheet to show you exactly how I need the data to look.
I have gone about this several different ways and haven't got it to work.
I have created a BarchartItem to hold the data that looks like this:
public class CategoryBarchartItem { public int JobCount { get; set; } public decimal EstHrsCount { get; set; } public decimal ActHrsCount { get; set; } public string Category { get; set; } public int ItemId { get; set; }}I have created a xaml that looks like this:
<telerik:RadChart Name="Chart" ItemsSource="{Binding}"> <telerik:RadChart.SeriesMappings> <tCharting:SeriesMapping> <tCharting:SeriesMapping.SeriesDefinition> <tCharting:BarSeriesDefinition /> </tCharting:SeriesMapping.SeriesDefinition> <tCharting:SeriesMapping.GroupingSettings> <tCharting:GroupingSettings ShouldCreateSeriesForLastGroup="True"> <tCharting:GroupingSettings.GroupDescriptors> <tCharting:ChartGroupDescriptor Member="JobCount" /> <tCharting:ChartGroupDescriptor Member="ActHrsCount" /> <tCharting:ChartGroupDescriptor Member="EstHoursCount" /> </tCharting:GroupingSettings.GroupDescriptors> </tCharting:GroupingSettings> </tCharting:SeriesMapping.GroupingSettings> <tCharting:SeriesMapping.ItemMappings> <tCharting:ItemMapping FieldName="Value" DataPointMember="YValue"/> <tCharting:ItemMapping FieldName="Description" DataPointMember="XCategory"/> </tCharting:SeriesMapping.ItemMappings> </tCharting:SeriesMapping> </telerik:RadChart.SeriesMappings> </telerik:RadChart></UserControl>I get an error: Exception has been thrown by the target of an invocation when I try to assign my data to the DataContext
I also tried grouping the data myself:
private void PopulateData() { //take raw data and group it var query = from jh in JobHours group jh by jh.CategoryName into g select new { Actualhours = g.Sum(jh => jh.ActualTime), EstimatedHours = g.Sum(jh => jh.EstimatedTime), currentCategory = g.Key, currentJobCount = g.Count() }; List<CategoryBarchartItem> chartItems = new List<CategoryBarchartItem>(); int counter = 0; foreach (var myjobCount in query) { chartItems.Add(new CategoryBarchartItem { ActHrsCount = myjobCount.Actualhours ?? 0, EstHrsCount = myjobCount.EstimatedHours ?? 0, JobCount = myjobCount.currentJobCount, Category = myjobCount.currentCategory, ItemId = counter }); counter++; } DataContext = chartItems; }and put it into a different XAML like this:
<UserControl x:Class="Macu.MarketingMinutes.Controls.Charts.JobHoursByCategory" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:tCharting="clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <telerik:RadChart Name="Chart" ItemsSource="{Binding}"> <telerik:RadChart.SeriesMappings> <telerik:SeriesMapping LegendLabel="Jobs"> <telerik:SeriesMapping.SeriesDefinition> <telerik:BarSeriesDefinition> <telerik:BarSeriesDefinition.Appearance> <telerik:SeriesAppearanceSettings Cursor="Hand" /> </telerik:BarSeriesDefinition.Appearance> </telerik:BarSeriesDefinition> </telerik:SeriesMapping.SeriesDefinition> <telerik:SeriesMapping.GroupingSettings> <telerik:GroupingSettings ShouldCreateSeriesForLastGroup="True"> <telerik:GroupingSettings.GroupDescriptors> <telerik:ChartGroupDescriptor Member="CategoryName"/> </telerik:GroupingSettings.GroupDescriptors> </telerik:GroupingSettings> </telerik:SeriesMapping.GroupingSettings> <telerik:SeriesMapping.ItemMappings> <telerik:ItemMapping DataPointMember="XCategory" FieldName="CategoryName"/> <telerik:ItemMapping DataPointMember="YValue" FieldName="JobCount"/> </telerik:SeriesMapping.ItemMappings> </telerik:SeriesMapping> <telerik:SeriesMapping LegendLabel="Est.Hours"> <telerik:SeriesMapping.SeriesDefinition> <telerik:BarSeriesDefinition> <telerik:BarSeriesDefinition.Appearance> <telerik:SeriesAppearanceSettings Cursor="Hand"/> </telerik:BarSeriesDefinition.Appearance> </telerik:BarSeriesDefinition> </telerik:SeriesMapping.SeriesDefinition> <telerik:SeriesMapping.ItemMappings> <telerik:ItemMapping DataPointMember="XCategory" FieldName="CategoryName"/> <telerik:ItemMapping DataPointMember="YValue" FieldName="EstHrsCount"/> </telerik:SeriesMapping.ItemMappings> </telerik:SeriesMapping> <telerik:SeriesMapping LegendLabel="Act. Hours"> <telerik:SeriesMapping.SeriesDefinition> <telerik:BarSeriesDefinition> <telerik:BarSeriesDefinition.Appearance> <telerik:SeriesAppearanceSettings Cursor="Hand" /> </telerik:BarSeriesDefinition.Appearance> </telerik:BarSeriesDefinition> </telerik:SeriesMapping.SeriesDefinition> <telerik:SeriesMapping.ItemMappings> <telerik:ItemMapping DataPointMember="XCategory" FieldName="CategoryName"/> <telerik:ItemMapping DataPointMember="YValue" FieldName="ActHrsCount" /> </telerik:SeriesMapping.ItemMappings> </telerik:SeriesMapping> </telerik:RadChart.SeriesMappings> </telerik:RadChart></UserControl>and I get no data. Can you help me please to get this to work?