sl4 toolkit图表控件显示双y轴

下面是页面代码

代码
< UserControl  xmlns:toolkit ="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"   x:Class ="SilverlightApplication2.MainPage"
    xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d
="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc
="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable
="d"
               xmlns:local
="clr-namespace:SilverlightApplication2"
    d:DesignHeight
="300"  d:DesignWidth ="400"   >

    
< Grid  x:Name ="LayoutRoot"  Background ="White" >
        
< Grid.Resources >
            
< local:EngineMeasurementCollection  x:Key ="EngineMeasurementCollection" />
        
</ Grid.Resources >
        
< toolkit:Chart >
            
<!--  Power curve   -->
            
< toolkit:LineSeries
                            
Title ="Power"
                           ItemsSource
=" {StaticResource EngineMeasurementCollection} "
                            IndependentValueBinding
=" {Binding Speed} "
                            DependentValueBinding
=" {Binding Power} " >
                
<!-- MarkerWidth="5"
                            MarkerHeight="5"
-->
                
<!--  Vertical axis for power curve  Orientation="Vertical" -->
                
< toolkit:LineSeries.DependentRangeAxis >

                    
< toolkit:LinearAxis
                         
                                     
Orientation ="y"
                                    Title
="Power (hp)"
                                    Minimum
="0"
                                    Maximum
="250"
                                    Interval
="50"
                                    ShowGridLines
="True" />
                
</ toolkit:LineSeries.DependentRangeAxis >
            
</ toolkit:LineSeries >
            
< toolkit:ColumnSeries    Title ="Power"
                           ItemsSource
=" {StaticResource EngineMeasurementCollection} "
                            IndependentValueBinding
=" {Binding Speed} "
                            DependentValueBinding
=" {Binding Power} " >
                
< toolkit:ColumnSeries.DependentRangeAxis >
                    
< toolkit:LinearAxis     Orientation ="y"
                                    Title
="Power (hp)"
                                    Minimum
="0"
                                    Maximum
="250"
                                    Interval
="50"
                                    ShowGridLines
="True" ></ toolkit:LinearAxis >
                
</ toolkit:ColumnSeries.DependentRangeAxis >
            
</ toolkit:ColumnSeries >
            
<!--  Torque curve   -->
            
< toolkit:LineSeries
                            
Title ="Torque"
                           ItemsSource
=" {StaticResource EngineMeasurementCollection} "
                            IndependentValueBinding
=" {Binding Speed} "
                            DependentValueBinding
=" {Binding Torque} " >
                
<!-- MarkerWidth="5" -->
                
<!-- MarkerHeight="5" -->
                
<!--  Vertical axis for torque curve  Orientation="Vertical" -->
                
< toolkit:LineSeries.DependentRangeAxis >
                    
< toolkit:LinearAxis
                                   
Orientation ="Y"
                                    Title
="Torque (lb-ft)"
                                    Minimum
="50"
                                    Maximum
="300"
                                    Interval
="50" />
                
</ toolkit:LineSeries.DependentRangeAxis >
            
</ toolkit:LineSeries >
            
< toolkit:Chart.Axes >
                
<!--  Shared horizontal axis Orientation="Horizontal" -->
                
< toolkit:LinearAxis
                                
Orientation ="X"
                                Title
="Speed (rpm)"
                                Interval
="1000"
                                ShowGridLines
="True" />
            
</ toolkit:Chart.Axes >
        
</ toolkit:Chart >
    
</ Grid >
</ UserControl >

 

数据类EngineMeasurement

  public   class  EngineMeasurement
    {
        
public   int  Speed {  get set ; }
        
public   int  Torque {  get set ; }
        
public   int  Power {  get set ; }
    }

 

数据集合EngineMeasurementCollection

代码
  public   class  EngineMeasurementCollection : Collection < EngineMeasurement >
    {
        
public  EngineMeasurementCollection()
        {
            Add(
new  EngineMeasurement { Speed  =   1000 , Torque  =   100 , Power  =   20  });
            Add(
new  EngineMeasurement { Speed  =   2000 , Torque  =   160 , Power  =   60  });
            Add(
new  EngineMeasurement { Speed  =   3000 , Torque  =   210 , Power  =   125  });
            Add(
new  EngineMeasurement { Speed  =   4000 , Torque  =   220 , Power  =   160  });
            Add(
new  EngineMeasurement { Speed  =   5000 , Torque  =   215 , Power  =   205  });
            Add(
new  EngineMeasurement { Speed  =   6000 , Torque  =   200 , Power  =   225  });
            Add(
new  EngineMeasurement { Speed  =   7000 , Torque  =   170 , Power  =   200  });
        }
    }

 

 以上代码在silverlight4 vs2010 英文 

和Microsoft Silverlight 4 Toolkit April 2010  下调试通过

 

你可能感兴趣的:(图表控件)