Silverlight3 toolkit 饼图,柱状图,折线图,气泡图

内容来源:
http://www.cnblogs.com/daizhj/archive/2009/07/24/1529320.html

自己重新写了一遍,终于编译通过了

MainPage.xaml.cs
ContractedBlock.gif ExpandedBlockStart.gif Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Controls.DataVisualization.Charting;

namespace SilverlightApplication10
ExpandedBlockStart.gifContractedBlock.gif
{

    
public class EmployeeInfo
ExpandedSubBlockStart.gifContractedSubBlock.gif     
{
ExpandedSubBlockStart.gifContractedSubBlock.gif         
public int EmployeeID setget; }
ExpandedSubBlockStart.gifContractedSubBlock.gif         
public string EmployeeName setget; }
ExpandedSubBlockStart.gifContractedSubBlock.gif         
public int Salary setget; }
ExpandedSubBlockStart.gifContractedSubBlock.gif         
public int[] Cost getset; }
ExpandedSubBlockStart.gifContractedSubBlock.gif         
public string City setget; }
     }
  

    
public partial class MainPage : UserControl
ExpandedSubBlockStart.gifContractedSubBlock.gif    
{
        
public List<EmployeeInfo> GetEmployeeList()
ExpandedSubBlockStart.gifContractedSubBlock.gif         
{
             List
<EmployeeInfo> employeeList = new List<EmployeeInfo>();
ExpandedSubBlockStart.gifContractedSubBlock.gif             employeeList.Add(
new EmployeeInfo { EmployeeID = 1, EmployeeName = "大林", Salary = 1000, City = "合肥" });
ExpandedSubBlockStart.gifContractedSubBlock.gif             employeeList.Add(
new EmployeeInfo { EmployeeID = 2, EmployeeName = "小林", Salary = 1000, City = "合肥" });
ExpandedSubBlockStart.gifContractedSubBlock.gif             employeeList.Add(
new EmployeeInfo { EmployeeID = 3, EmployeeName = "张三", Salary = 1000, City = "合肥" });
ExpandedSubBlockStart.gifContractedSubBlock.gif             employeeList.Add(
new EmployeeInfo { EmployeeID = 4, EmployeeName = "李四", Salary = 1500, City = "天津" });
ExpandedSubBlockStart.gifContractedSubBlock.gif             employeeList.Add(
new EmployeeInfo { EmployeeID = 5, EmployeeName = "王五", Salary = 2000, City = "上海" });
             
return employeeList;
         }

 
         
public List<EmployeeInfo> GetOtherEmployeeList()
ExpandedSubBlockStart.gifContractedSubBlock.gif         
{
             List
<EmployeeInfo> employeeList = new List<EmployeeInfo>();
ExpandedSubBlockStart.gifContractedSubBlock.gif             employeeList.Add(
new EmployeeInfo { EmployeeID = 6, EmployeeName = "赵六", Salary = 800, City = "北京" });
ExpandedSubBlockStart.gifContractedSubBlock.gif             employeeList.Add(
new EmployeeInfo { EmployeeID = 7, EmployeeName = "尤七", Salary = 2100, City = "武汉" });
ExpandedSubBlockStart.gifContractedSubBlock.gif             employeeList.Add(
new EmployeeInfo { EmployeeID = 8, EmployeeName = "马八", Salary = 1209, City = "海口" });
ExpandedSubBlockStart.gifContractedSubBlock.gif             employeeList.Add(
new EmployeeInfo { EmployeeID = 9, EmployeeName = "许九", Salary = 1600, City = "海口" });
ExpandedSubBlockStart.gifContractedSubBlock.gif             employeeList.Add(
new EmployeeInfo { EmployeeID = 10, EmployeeName = "代十", Salary = 2300, City = "海口" });
             
return employeeList;
         }


        
public MainPage()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            InitializeComponent();

ContractedSubBlock.gifExpandedSubBlockStart.gif           
柱状图#region 柱状图
            Action
<Chart> chartModifier = (chart) =>
ExpandedSubBlockStart.gifContractedSubBlock.gif            
{
ExpandedSubBlockStart.gifContractedSubBlock.gif                DisplayAxis dataAxis 
= new CategoryAxis { Orientation = AxisOrientation.X, Title = "雇员", FontStyle = FontStyles.Normal, ShowGridLines = true };
                EmployeeChart.Axes.Add(dataAxis);
ExpandedSubBlockStart.gifContractedSubBlock.gif                DisplayAxis valueAxis 
= new CategoryAxis { Orientation = AxisOrientation.Y, Title = "薪水", FontStyle = FontStyles.Normal, ShowGridLines = true };
                EmployeeChart.Axes.Add(valueAxis);
            }
;
            chartModifier(EmployeeChart);

ExpandedSubBlockStart.gifContractedSubBlock.gif             ColumnSeries columnSeries1 
= new ColumnSeries() { Title = "雇员" };
             columnSeries1.ItemsSource 
= GetEmployeeList();
             columnSeries1.IndependentValueBinding 
= new System.Windows.Data.Binding("EmployeeName");
             columnSeries1.DependentValueBinding 
= new System.Windows.Data.Binding("Salary");
             columnSeries1.Foreground 
= new SolidColorBrush(Colors.DarkGray);
             EmployeeChart.Series.Add(columnSeries1);                        
            
#endregion



ContractedSubBlock.gifExpandedSubBlockStart.gif            
折线图#region 折线图
             Action
<Chart> chartModifier1 = (chart) =>
ExpandedSubBlockStart.gifContractedSubBlock.gif             
{
ExpandedSubBlockStart.gifContractedSubBlock.gif                 DisplayAxis dataAxis 
= new CategoryAxis { Orientation = AxisOrientation.X, Title = "雇员", FontStyle = FontStyles.Normal, ShowGridLines = true };
                 LineSeriesEmp.Axes.Add(dataAxis);
ExpandedSubBlockStart.gifContractedSubBlock.gif                 DisplayAxis valueAxis 
= new CategoryAxis { Orientation = AxisOrientation.Y, Title = "薪水", FontStyle = FontStyles.Normal, ShowGridLines = true };
                 LineSeriesEmp.Axes.Add(valueAxis);
             }
;
             chartModifier1(LineSeriesEmp);
 
             LineSeries lineSeries1 
= new LineSeries();
             lineSeries1.ItemsSource 
= GetOtherEmployeeList();
             lineSeries1.IndependentValueBinding 
= new System.Windows.Data.Binding("EmployeeName");
             lineSeries1.DependentValueBinding 
= new System.Windows.Data.Binding("Salary");
             lineSeries1.Foreground 
= new SolidColorBrush(Colors.Cyan);
             LineSeriesEmp.Series.Add(lineSeries1);
             
#endregion



ContractedSubBlock.gifExpandedSubBlockStart.gif            
饼图#region 饼图
ExpandedSubBlockStart.gifContractedSubBlock.gif             
/**//**//**//*
             Action<Chart> chartModifier2 = (chart) =>
             {
                 DisplayAxis dataAxis = new CategoryAxis { Orientation = AxisOrientation.X, Title = " 雇员", FontStyle = FontStyles.Normal, ShowGridLines = true };
                 PieEmployee.Axes.Add(dataAxis);
                 DisplayAxis valueAxis = new CategoryAxis { Orientation = AxisOrientation.Y, Title = " 薪水", FontStyle = FontStyles.Normal, ShowGridLines = true };
                 PieEmployee.Axes.Add(valueAxis);
             };
             chartModifier2(PieEmployee);
             
*/

            PieSeries pieSeries1 
= new PieSeries();
            pieSeries1.ItemsSource 
= GetEmployeeList();
            pieSeries1.IndependentValueBinding 
= new System.Windows.Data.Binding("EmployeeName");
            pieSeries1.DependentValueBinding 
= new System.Windows.Data.Binding("Salary");
            PieEmployee.Series.Add(pieSeries1);
            
#endregion



ContractedSubBlock.gifExpandedSubBlockStart.gif               
气泡图#region 气泡图
            Action
<Chart> chartModifier3 = (chart) =>
ExpandedSubBlockStart.gifContractedSubBlock.gif            
{
ExpandedSubBlockStart.gifContractedSubBlock.gif                DisplayAxis dataAxis 
= new CategoryAxis { Orientation = AxisOrientation.X, Title = "雇员", FontStyle = FontStyles.Normal, ShowGridLines = true };
                BubbleEmp.Axes.Add(dataAxis);
ExpandedSubBlockStart.gifContractedSubBlock.gif                DisplayAxis valueAxis 
= new CategoryAxis { Orientation = AxisOrientation.Y, Title = "薪水", FontStyle = FontStyles.Normal, ShowGridLines = true };
                BubbleEmp.Axes.Add(valueAxis);
            }
;
            chartModifier3(BubbleEmp);

            BubbleSeries bubbleSeries1 
= new BubbleSeries();
            bubbleSeries1.ItemsSource 
= GetOtherEmployeeList();
            bubbleSeries1.IndependentValueBinding 
= new System.Windows.Data.Binding("EmployeeName");
            bubbleSeries1.DependentValueBinding 
= new System.Windows.Data.Binding("Salary");
            bubbleSeries1.Foreground 
= new SolidColorBrush(Colors.Cyan);
            BubbleEmp.Series.Add(bubbleSeries1);
            
#endregion




        }

    }

}


MainPage.xaml

ContractedBlock.gif ExpandedBlockStart.gif Code
<Grid.ColumnDefinitions>
          
            
<ColumnDefinition Width="320"></ColumnDefinition>
          
            
<ColumnDefinition Width="320"></ColumnDefinition>
           
            
<ColumnDefinition Width="320"></ColumnDefinition>
           
            
<ColumnDefinition Width="320"></ColumnDefinition>
          
        
</Grid.ColumnDefinitions>
     

        
<chartingToolkit:Chart x:Name="EmployeeChart" Title="柱状图" Grid.Column="0"></chartingToolkit:Chart>
       
        
<chartingToolkit:Chart x:Name="LineSeriesEmp" Title="折线图" Grid.Column="1"></chartingToolkit:Chart>

        
<chartingToolkit:Chart x:Name="PieEmployee" Title="饼图" Grid.Column="2"></chartingToolkit:Chart>
  
        
<chartingToolkit:Chart x:Name="BubbleEmp" Title="气泡图" Grid.Column="3"></chartingToolkit:Chart>
    
</Grid>



刚开始学Silverlight,作为自己的学习笔记吧

转载于:https://www.cnblogs.com/zhouzhengzhe/archive/2009/09/04/1559956.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值