Devexpress WPF ChartControl 多Y轴

 

<Window
    x:Class="DXApplication4.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts"
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        Title="MainWindow" Height="350" Width="525" 
    
    >
    <Grid>
        <dxc:ChartControl >
            <dxc:XYDiagram2D x:Name="diagram1">
                <dxc:XYDiagram2D.SecondaryAxesY>
                    <dxc:SecondaryAxisY2D x:Name="y2">
                        <dxc:SecondaryAxisY2D.Title>
                            <dxc:AxisTitle Content="y2"></dxc:AxisTitle>
                        </dxc:SecondaryAxisY2D.Title>
                    </dxc:SecondaryAxisY2D>
                    <dxc:SecondaryAxisY2D x:Name="y3"/>
                </dxc:XYDiagram2D.SecondaryAxesY>
                <dxc:XYDiagram2D.AxisX>
                    <dxc:AxisX2D />
                </dxc:XYDiagram2D.AxisX>
                <dxc:XYDiagram2D.AxisY>
                    <dxc:AxisY2D  >
                        <dxc:AxisY2D.Range>
                            <dxc:AxisRange MaxValue="10" MinValue="0"></dxc:AxisRange>
                        </dxc:AxisY2D.Range>
                    </dxc:AxisY2D>      
                </dxc:XYDiagram2D.AxisY>
                <dxc:LineSeries2D  ArgumentDataMember="Key" ValueDataMember="Value" x:Name="series1"/>
                <dxc:LineSeries2D dxc:XYDiagram2D.SeriesAxisY="{Binding ElementName=y2}" ArgumentDataMember="Key" ValueDataMember="Value" x:Name="series2"/>          
                <dxc:LineSeries2D  ArgumentDataMember="Key" ValueDataMember="Value" x:Name="series3">
                    <dxc:XYDiagram2D.SeriesAxisY>
                        <Binding ElementName="y3"/>
                    </dxc:XYDiagram2D.SeriesAxisY>
                </dxc:LineSeries2D>
            </dxc:XYDiagram2D>
        </dxc:ChartControl>
    </Grid>
</Window>

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using DevExpress.Xpf.Charts;
using System.Data;


namespace DXApplication4
{
    public partial class MainWindow : Window
    {
        public MainWindow ()
        {
            InitializeComponent();

            Dictionary<int, int> d1 = new Dictionary<int, int>();
            d1.Add(1, 1);
            d1.Add(2, 2);
            d1.Add(3, 3);
            d1.Add(4, 4);

            series1.DataSource = d1;
            SecondaryAxisY2D y1 = new SecondaryAxisY2D();            
            y1.Title = new AxisTitle() { Content = "y1" };
            y1.Range = new AxisRange() { MaxValue = 10, MinValue = 0 };
            diagram1.SecondaryAxesY.Remove(y1);
            diagram1.SecondaryAxesY.Add(y1);           
            XYDiagram2D.SetSeriesAxisY(series1, y1);

            Dictionary<int, int> d2 = new Dictionary<int, int>();
            d2.Add(1, 2);
            d2.Add(2, 4);
            d2.Add(3, 7);
            d2.Add(4, 9);
            series2.DataSource = d2;

            Dictionary<int, int> d3 = new Dictionary<int, int>();
            d3.Add(1, 1);
            d3.Add(2, 5);
            d3.Add(3, 2);
            d3.Add(4, 8);
            series3.DataSource = d3;

        }
       
    
    }


}

 

posted @ 2014-05-18 01:37  枯无穷肉  阅读(2718)  评论(1编辑  收藏  举报