silverlight 图形报表开发

前端:

<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];
原文地址:https://www.cnblogs.com/xinyus/p/3174701.html