Hi everyone,
I'm having some issues with displaying a StackedBar chart. I can confirm that data is being bound (because the DataBound event is firing). However, the data is not being displayed (see attached). I'm simply getting a "No Data Series". I modeled this chart after another regular bar series chart that works fine.
Any ideas? Thanks!
-Sam
I'm having some issues with displaying a StackedBar chart. I can confirm that data is being bound (because the DataBound event is firing). However, the data is not being displayed (see attached). I'm simply getting a "No Data Series". I modeled this chart after another regular bar series chart that works fine.
using
System;
using
System.Linq;
using
System.Windows;
using
System.Windows.Controls;
using
Telerik.Windows.Controls.Charting;
using
RadHelpdeskDashboard.HelpdeskServiceReference;
using
RadHelpdeskDashboard.Helpers;
using
System.Collections.ObjectModel;
using
System.Collections.Generic;
using
System.Windows.Media;
namespace
RadHelpdeskDashboard
{
public
partial
class
MainPage : UserControl
{
public
MainPage()
{
InitializeComponent();
TotalElapsedOpenTicketsChart.Loaded +=
new
RoutedEventHandler(TotalElapsedOpenTicketsChart_Loaded);
Loaded +=
new
RoutedEventHandler(MainPage_Loaded);
}
public
void
MainPage_Loaded(
object
sender, RoutedEventArgs e)
{
LoadTotalElapsedOpenTicketsChart();
}
protected
void
LoadTotalElapsedOpenTicketsChart()
{
TotalElapsedOpenTicketsChartBusy.IsBusy =
true
;
HelpdeskDataServiceClient obj =
new
HelpdeskDataServiceClient();
obj.GetTotalElapsedOpenTicketsCompleted += (sender, e) =>
{
List<PeopleTotalOpenElapsedTicket> _people =
new
List<PeopleTotalOpenElapsedTicket>();
foreach
(TotalElapsedOpenTickets_GetResult tickresult
in
e.Result)
{
PeopleTotalOpenElapsedTicket temp =
new
PeopleTotalOpenElapsedTicket(tickresult.Name,
(tickresult.Total.HasValue) ? tickresult.Total.Value : 0,
tickresult.LT10, tickresult._10to30, tickresult.GT30);
_people.Add(temp);
}
TotalElapsedOpenTicketsChart.ItemsSource = _people;
TotalElapsedOpenTicketsChartBusy.IsBusy =
false
;
};
obj.GetTotalElapsedOpenTicketsAsync();
}
public
void
TotalElapsedOpenTicketsChart_Loaded(
object
sender, RoutedEventArgs e)
{
StackedBar3DSeriesDefinition bar =
new
StackedBar3DSeriesDefinition(
"Name"
) { ShowItemLabels =
true
};
bar.Appearance.Fill =
new
SolidColorBrush(Colors.Blue);
SeriesMapping smLT10 =
new
SeriesMapping() { LegendLabel =
"Less than 10 days"
, CollectionIndex = 0 };
smLT10.ItemMappings.Add(
new
ItemMapping() { FieldName =
"Name"
, DataPointMember = DataPointMember.XCategory });
smLT10.ItemMappings.Add(
new
ItemMapping() { FieldName =
"TicketsLessThanTenDays"
, DataPointMember = DataPointMember.YValue });
smLT10.GroupingSettings.GroupDescriptors.Add(
new
ChartGroupDescriptor(
"Name"
));
smLT10.SeriesDefinition = bar;
StackedBar3DSeriesDefinition bar1 =
new
StackedBar3DSeriesDefinition(
"Name"
) { ShowItemLabels =
true
};
bar1.Appearance.Fill =
new
SolidColorBrush(Colors.Red);
SeriesMapping sm10to30 =
new
SeriesMapping() { LegendLabel =
"10 to 30 days"
, CollectionIndex = 1 };
sm10to30.ItemMappings.Add(
new
ItemMapping() { FieldName =
"Name"
, DataPointMember = DataPointMember.XCategory });
sm10to30.ItemMappings.Add(
new
ItemMapping() { FieldName =
"TicketsTenToThirtyDays"
, DataPointMember = DataPointMember.YValue });
sm10to30.GroupingSettings.GroupDescriptors.Add(
new
ChartGroupDescriptor(
"Name"
));
sm10to30.SeriesDefinition = bar1;
StackedBar3DSeriesDefinition bar2 =
new
StackedBar3DSeriesDefinition(
"Name"
) { ShowItemLabels =
true
};
bar2.Appearance.Fill =
new
SolidColorBrush(Colors.Green);
SeriesMapping smGT30 =
new
SeriesMapping() { LegendLabel =
"Greater than 30 days"
, CollectionIndex = 2 };
smGT30.ItemMappings.Add(
new
ItemMapping() { FieldName =
"Name"
, DataPointMember = DataPointMember.XCategory });
smGT30.ItemMappings.Add(
new
ItemMapping() { FieldName =
"TicketsMoreThanThirtyDays"
, DataPointMember = DataPointMember.YValue });
smGT30.GroupingSettings.GroupDescriptors.Add(
new
ChartGroupDescriptor(
"Name"
));
smGT30.SeriesDefinition = bar2;
TotalElapsedOpenTicketsChart.SeriesMappings.Add(smLT10);
TotalElapsedOpenTicketsChart.SeriesMappings.Add(sm10to30);
TotalElapsedOpenTicketsChart.SeriesMappings.Add(smGT30);
TotalElapsedOpenTicketsChart.DefaultView.ChartArea.AxisX.Title =
"Employee"
;
TotalElapsedOpenTicketsChart.DefaultView.ChartArea.AxisX.LabelRotationAngle = 45.0;
TotalElapsedOpenTicketsChart.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Inside;
TotalElapsedOpenTicketsChart.DefaultView.ChartArea.AxisY.AutoRange =
true
;
TotalElapsedOpenTicketsChart.DefaultView.ChartArea.AxisY.DefaultLabelFormat =
"0"
;
TotalElapsedOpenTicketsChart.DefaultView.ChartArea.AxisY.Title =
"Tickets"
;
TotalElapsedOpenTicketsChart.DefaultView.ChartLegend.UseAutoGeneratedItems =
true
;
TotalElapsedOpenTicketsChart.DefaultView.ChartTitle.Content =
"Total Elapsed Open Tickets"
;
TotalElapsedOpenTicketsChart.DefaultView.ChartTitle.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
}
}
}
Any ideas? Thanks!
-Sam