WPF Toolkit Chart. Random data printing

Aug 26, 2011 at 10:03 AM

Following the xmal:

 <chartingToolkit:Chart  Name="areaChart"
                                    Title="Area Series Demo"
                                    VerticalAlignment="Top"
                                       MinHeight="300"
                                       MinWidth="300"
                                        Margin="10">
                    <chartingToolkit:Chart.Axes>

                        <chartingToolkit:LinearAxis
                            Interval="10"
                            Maximum="30"
                            Minimum="0"
                            Orientation="X"
                            ShowGridLines="True" />
                       
                        <chartingToolkit:LinearAxis
                            Orientation="Y"
                            Minimum="0"
                            Interval="10"
                            Maximum="50"
                           
                            ShowGridLines="True"/>
                       
                        </chartingToolkit:Chart.Axes>

                
                    <!-- Serie 1 -->
                    <chartingToolkit:AreaSeries 
                        Name ="Serie1"
                        DependentValuePath="Value"
                        IndependentValuePath="Key"
                       
                        ItemsSource="{Binding valueList}"
                        IsSelectionEnabled="True"
                       
                        >


                    </chartingToolkit:AreaSeries>
                   
                     <!--Serie 2 -->
                    <chartingToolkit:AreaSeries 
                        DependentValuePath="Value"
                        IndependentValuePath="Key"
                        ItemsSource="{Binding valueList1}"
                        IsSelectionEnabled="True"
                       
                        >

                    </chartingToolkit:AreaSeries>
                   
                </chartingToolkit:Chart>

 

and code behind:

 

  public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();
      showColumnChart();
    }

    private void showColumnChart()
    {
        //Setting data for area chart
      DataContext = new ViewModel();
    }

  }


  class ViewModel
  {
     public List<KeyValuePair<int, int>> valueList {get; set;}
     public List<KeyValuePair<int, int>> valueList1 { get; set; }

      public ViewModel()
      {
          valueList = new List<KeyValuePair<int, int>>();
          valueList.Add(new KeyValuePair<int, int>(0, 30));
          valueList.Add(new KeyValuePair<int, int>(5, 30));
          valueList.Add(new KeyValuePair<int, int>(5, 10));
          valueList.Add(new KeyValuePair<int, int>(22, 10));
          valueList.Add(new KeyValuePair<int, int>(22, 15));
          valueList.Add(new KeyValuePair<int, int>(23, 15));
    
          valueList1 = new List<KeyValuePair<int, int>>();
          valueList1.Add(new KeyValuePair<int, int>(0, 15));
          valueList1.Add(new KeyValuePair<int, int>(5, 15));
          valueList1.Add(new KeyValuePair<int, int>(5, 5));
          valueList1.Add(new KeyValuePair<int, int>(22, 5));
          valueList1.Add(new KeyValuePair<int, int>(22, 7));
          valueList1.Add(new KeyValuePair<int, int>(23, 7));

      }
  }

 

The result is that the lines in the chart are printed in randow way. Where is the error? I also try to use the following class instead of KeyValuePair:

public class IntKeyIntValue
  {
      public int IntKey { get; set; }
      public int IntValue { get; set; }

      public IntKeyIntValue(int intkey, int intvalue)
      {
          this.IntKey = intkey;
          this.IntValue = intvalue;
      }
  }

 

I obtain the same result. Wrong data printed.