
Hello, I'm trying to generate a stack bar chart that has a BarSeries for each task in the taskGroup collection. How do I go about this?
C#:
var taskA = new TaskInfoCustom();
taskA.Costs.Add(new CostInfoCustom { Qty = 3, CostDate = DateTime.Now + new TimeSpan(3, 0, 0, 0) });
taskA.Costs.Add(new CostInfoCustom { Qty = 4, CostDate = DateTime.Now + new TimeSpan(3, 0, 0, 0) });
taskA.Costs.Add(new CostInfoCustom { Qty = 3, CostDate = DateTime.Now + new TimeSpan(2, 0, 0, 0) });
taskA.Costs.Add(new CostInfoCustom { Qty = 2, CostDate = DateTime.Now + new TimeSpan(5, 0, 0, 0) });
taskA.Costs.Add(new CostInfoCustom { Qty = 1, CostDate = DateTime.Now + new TimeSpan(4, 0, 0, 0) });
var taskB = new TaskInfoCustom();
taskB.Costs.Add(new CostInfoCustom { Qty = 3, CostDate = DateTime.Now + new TimeSpan(5, 0, 0, 0) });
taskB.Costs.Add(new CostInfoCustom { Qty = 3, CostDate = DateTime.Now + new TimeSpan(4, 0, 0, 0) });
taskB.Costs.Add(new CostInfoCustom { Qty = 2, CostDate = DateTime.Now + new TimeSpan(3, 0, 0, 0) });
taskB.Costs.Add(new CostInfoCustom { Qty = 4, CostDate = DateTime.Now + new TimeSpan(2, 0, 0, 0) });
taskB.Costs.Add(new CostInfoCustom { Qty = 2, CostDate = DateTime.Now + new TimeSpan(1, 0, 0, 0) });
var taskGroup = new ObservableCollection<TaskInfoCustom>();
taskGroup.Add(taskA);
taskGroup.Add(taskB);
InitializeComponent();
HourChart.DataContext = taskGroup;
XAML:
<charts:XYChart Name="HourChart">
<charts:BarSeries ItemsSource="{Binding Costs}" YPath="Qty" XPath="CostDate" StackKind="Normal"/>
</charts:XYChart>