鹏--扶摇直上

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

前端:

<UserControl x:Class="SLThree.CharReport"
    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"
    xmlns:c="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:f="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    mc:Ignorable="d"
    d:DesignHeight="500" d:DesignWidth="800">

    <Grid x:Name="LayoutRoot" Background="White">
        <StackPanel Width="400" Height="400" Margin="0,20,400,80">
            <c:Chart x:Name="mychart" Height="312">
                <c:ColumnSeries Title="销售额" DependentValueBinding="{Binding Amount}"
                            IndependentValueBinding="{Binding Day}">
                </c:ColumnSeries>
            </c:Chart>
        </StackPanel>
        <StackPanel Width="400" Height="400" Margin="400,20,0,80">
            <c:Chart x:Name="mychart2" Height="312">
                <c:PieSeries Title="销售额" DependentValueBinding="{Binding Amount}" IndependentValueBinding="{Binding Day}"></c:PieSeries>
            </c:Chart>
        </StackPanel>
    </Grid>

 

后台:

 public CharReport()
        {
            InitializeComponent();
            MyWebService.WebService1SoapClient client = new MyWebService.WebService1SoapClient();
            client.GetAllSalesCompleted += new EventHandler<MyWebService.GetAllSalesCompletedEventArgs>(client_GetAllSales);
            client.GetAllSalesAsync();
        }

        void client_GetAllSales(object sender, MyWebService.GetAllSalesCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                HtmlPage.Window.Alert(e.Error.Message);
                return;
            }
            ((ColumnSeries)(this.mychart.Series[0])).ItemsSource = e.Result;
            ((PieSeries)(this.mychart2.Series[0])).ItemsSource = e.Result;
        }

 第二种:

前台:
  <c:Chart x:Name="mychart" Height="312">
            <c:ColumnSeries Title="上周销售额" DependentValueBinding="{Binding Amount}"
                            IndependentValueBinding="{Binding Day}">
            </c:ColumnSeries>
            <c:ColumnSeries Title="本周销售额" DependentValueBinding="{Binding Amount}"
                            IndependentValueBinding="{Binding Day}">
            </c:ColumnSeries>
        </c:Chart>

后台:

  ((ColumnSeries)(this.mychart.Series[0])).ItemsSource = e.Result[0];
            ((ColumnSeries)(this.mychart.Series[1])).ItemsSource = e.Result[1];

 

posted on 2013-07-05 23:48  xinyu's  阅读(320)  评论(0编辑  收藏  举报