Question

I'm struggling to figure out why my binding on my multiple series column graph is not working. From what I've been able to see through examples on the net I cant see any problems with the logic of what im doing but maybe I've missed something. As far as I can tell it is supported.

This is my chart control:

<toolkit:Chart x:Name="myChart" Margin="10">
            <toolkit:ColumnSeries 
            Title="Orion"
            IndependentValueBinding="{Binding Date}"
            DependentValueBinding="{Binding Orion}"
            AnimationSequence="FirstToLast">
            </toolkit:ColumnSeries>
            
            <toolkit:ColumnSeries                 
            Title="Access Card"
            IndependentValueBinding="{Binding Date}"
            DependentValueBinding="{Binding AccessCard}"
            AnimationSequence="FirstToLast">
            </toolkit:ColumnSeries>

            <toolkit:ColumnSeries                 
            Title="Time Keeper"
            IndependentValueBinding="{Binding Date}"
            DependentValueBinding="{Binding TimeKeeper}"
            AnimationSequence="FirstToLast">
            </toolkit:ColumnSeries>

        </toolkit:Chart>

This is some test code i'm trying to implement:

private void OrionWebService_ChartComilerCompleted(object sender, ChartCompilerCompletedEventArgs e)
  {
     List<ChartClass> mytest = new List<ChartClass>();
     mytest.Add(new ChartClass
                   {
                      Date = Convert.ToDateTime("01/01/2013 12:00:00 PM"),
                      Orion = 3.0,
                      AccessCard = 4.0,
                      TimeKeeper = 6.0
                   });

     mytest.Add(new ChartClass
                   {
                      Date = Convert.ToDateTime("01/02/2013 12:00:00 PM"),
                      Orion = 6.0,
                      AccessCard = 4.0,
                      TimeKeeper = 8.0
                   });

     ((ColumnSeries)myChart.Series[0]).ItemsSource = mytest;
     BusyIndicator.IsBusy = false;
  }

ChartClass

    public class ChartClass
   {
      public DateTime Date { get; set; }
      public double Orion { get; set; }
      public double AccessCard { get; set; }
      public double TimeKeeper { get; set; }
   }

For now i'm just passing some test data, Ultimately though I'm trying to achieve a chart that has 3 vertical columns, for each day in the date range. Similar to the image below:

What I want my chart to look like

For some reason though when the control loads it isn't filling in any data for any column besides the one Labeled Orion. If I remove the Orion series from the xaml and only define the TimeKeeper and AccessCard, then TimeKeeper Series works but doesnt show AccessCard data. It only seems to bind to the first defined series and ignores binding on all other series in the chart. Does the silverlight toolkit not support what I'm attempting to do?

Can anyone please assist me? Or at least point me in the direction of an example. I cant seem to find anything wrong with what I've done.

Thanks in advance.

Was it helpful?

Solution

Apologies, I found the issue was being caused in Code behind as I was only defining the item source for series[0] and not the other ones. Problem solved with the following code:

((ColumnSeries)myChart.Series[0]).ItemsSource = mytest;
((ColumnSeries)myChart.Series[1]).ItemsSource = mytest;
((ColumnSeries)myChart.Series[2]).ItemsSource = mytest;

Not pretty but my chart is working correctly now

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top