代码改变世界

DevExpress之ChartControl图标控件-学习

2012-07-21 23:13  张瀚文zhw  阅读(1963)  评论(0编辑  收藏  举报
 1 <Grid x:Name="LayoutRoot" Background="White" Width="900">
 2         <dxc:ChartControl EnableAnimation="False" Height="200" HorizontalAlignment="Left" Margin="123,74,0,0" Name="chartControl1" VerticalAlignment="Top" Width="400">
 3             <dxc:ChartControl.Diagram>
 4                 <dxc:XYDiagram2D>
 5                     <dxc:XYDiagram2D.Series>
 6                         <dxc:BarSideBySideSeries2D ArgumentDataMember="Unit" ValueDataMember="Num" AnimationAutoStartMode="SetStartState">
 7                             <dxc:BarSideBySideSeries2D.Model>
 8                                 <dxc:Quasi3DBar2DModel/>
 9                             </dxc:BarSideBySideSeries2D.Model>
10                         </dxc:BarSideBySideSeries2D>
11                     </dxc:XYDiagram2D.Series>
12                 </dxc:XYDiagram2D>
13             </dxc:ChartControl.Diagram>
14         </dxc:ChartControl>
15     </Grid>
 public MainPage()
        {
            InitializeComponent();
            List<CCEntity> test = new List<CCEntity>();
            for (int i = 0; i < 10; i++)
            {
                test.Add(new CCEntity { ID = i.ToString(), Num = i, Unit = i.ToString() });
            }

            chartControl1.DataSource = test;
        }
实体
 1  /// 图标绑定实体类
 2         /// </summary>
 3         [Serializable]
 4         private class CCEntity
 5         {
 6             private string id;
 7             /// <summary>
 8             /// ID
 9             /// </summary> 
10             public string ID
11             {
12                 get { return id; }
13                 set { id = value; }
14             }
15 
16             private int num;
17             /// <summary>
18             /// 数量
19             /// </summary> 
20             public int Num
21             {
22                 get { return num; }
23                 set { num = value; }
24             }
25 
26             private string unit;
27             /// <summary>
28             /// 单位
29             /// </summary> 
30             public string Unit
31             {
32                 get { return unit; }
33                 set { unit = value; }
34             }
35         }