• Silverlight 图形报表 线形图 柱形图 饼图


    附本人实践的线形图源代码:https://files.cnblogs.com/zhxm/SilverlightApplication1.rar

    一、  线形图

    前台布局

    <toolkit:Chart

                           Name="mychart" Title="Hail曲线图" Grid.Row="0">

                <toolkit:Chart.Series>

                    <toolkit:LineSeries Name="myLineChart" Loaded="myLineChart_Loaded"

                                    Title="-1SD"

                                    IndependentValueBinding="{Binding Key}"

                                    DependentValueBinding="{Binding Value}"

                                    DataPointStyle="{StaticResource MyLineDataPointStyle}">

                    </toolkit:LineSeries>

                    <toolkit:LineSeries Name="myLineChart1" Loaded="myLineChart1_Loaded"

                                    Title="-2SD"

                                    IndependentValueBinding="{Binding Key}"

                                    DependentValueBinding="{Binding Value}"

                                    DataPointStyle="{StaticResource MyLineDataPointStyle1}">

                    </toolkit:LineSeries>

     

                    <toolkit:LineSeries Name="myLineChart2"  Loaded="myLineChart2_Loaded"

                                    Title="-3SD"

                                    IndependentValueBinding="{Binding Key}"

                                    DependentValueBinding="{Binding Value}"

                                    DataPointStyle="{StaticResource MyLineDataPointStyle2}">

                    </toolkit:LineSeries>

                    <toolkit:LineSeries Name="myLineChart3" Loaded="myLineChart3_Loaded"

                                    Title="1SD"

                                    IndependentValueBinding="{Binding Key}"

                                    DependentValueBinding="{Binding Value}"

                                    DataPointStyle="{StaticResource MyLineDataPointStyle3}">

                    </toolkit:LineSeries>

     

                    <toolkit:LineSeries Name="myLineChart4" Loaded="myLineChart4_Loaded"

                                    Title="2SD"

                                    IndependentValueBinding="{Binding Key}"

                                    DependentValueBinding="{Binding Value}"

                                    DataPointStyle="{StaticResource MyLineDataPointStyle4}">

                    </toolkit:LineSeries>

                    <toolkit:LineSeries Name="myLineChart5" Loaded="myLineChart5_Loaded"

                                    Title="3SD"

                                    IndependentValueBinding="{Binding Key}"

                                    DependentValueBinding="{Binding Value}"

                                    DataPointStyle="{StaticResource MyLineDataPointStyle5}">

                    </toolkit:LineSeries>

                </toolkit:Chart.Series>

            </toolkit:Chart>

    后台代码

    public ObservableCollection<Hail_CanShu> ObjListSC=new ObservableCollection< Hail_CanShu>();

     

     

            #region  Hail曲线图

            private void myLineChart_Loaded(object sender, RoutedEventArgs e)

            {

                List<KeyValuePair<string, double>> points0 = new List<KeyValuePair<string, double>>();

                for (int i = 0; i < ObjListSC.Count; i++)

                {

                    string StrName = ObjListSC[i].月龄

                    double StrValue = Convert.ToDouble(ObjListSC[i].数值D1); //第一条曲线纵向数据

                    points0.Add(new KeyValuePair<string, double>("" + StrName, StrValue));

                }

                (sender as LineSeries).ItemsSource = points0;

            }

            private void myLineChart1_Loaded(object sender, RoutedEventArgs e)

            {

               

                    List<KeyValuePair<string, double>> points0 = new List<KeyValuePair<string, double>>();

                    for (int i = 0; i < ObjListSC.Count; i++)

                    {

                        string StrName = ObjListSC[i] .月龄;

                        double StrValue = Convert.ToDouble(ObjListSC[i]. .数值D2); //第二条曲线纵向数据

     

                        points0.Add(new KeyValuePair<string, double>("" + StrName, StrValue));

                    }

                    (sender as LineSeries).ItemsSource = points0;

            

            }

            private void myLineChart2_Loaded(object sender, RoutedEventArgs e)

            {

                List<KeyValuePair<string, double>> points0 = new List<KeyValuePair<string, double>>();

                for (int i = 0; i < ObjListSC.Count; i++)

                {

                    string StrName = ObjListSC[i].月龄;

                    double StrValue = Convert.ToDouble(ObjListSC[i] .数值D3);

                    points0.Add(new KeyValuePair<string, double>("" + StrName, StrValue));

                }

                (sender as LineSeries).ItemsSource = points0;

            }

            private void myLineChart3_Loaded(object sender, RoutedEventArgs e)

            {

                List<KeyValuePair<string, double>> points0 = new List<KeyValuePair<string, double>>();

                for (int i = 0; i < ObjListSC.Count; i++)

                {

                    string StrName = ObjListSC[i].月龄;

                    double StrValue = Convert.ToDouble(ObjListSC[i].数值¦G1);

                    points0.Add(new KeyValuePair<string, double>("" + StrName, StrValue));

                }

                (sender as LineSeries).ItemsSource = points0;

            }

            private void myLineChart4_Loaded(object sender, RoutedEventArgs e)

            {

                List<KeyValuePair<string, double>> points0 = new List<KeyValuePair<string, double>>();

                for (int i = 0; i < ObjListSC.Count; i++)

                {

                    string StrName = ObjListSC[i].月龄;

                    double StrValue = Convert.ToDouble(ObjListSC[i].数值G2);

                    points0.Add(new KeyValuePair<string, double>("" + StrName, StrValue));

                }

                (sender as LineSeries).ItemsSource = points0;

     

            }

            private void myLineChart5_Loaded(object sender, RoutedEventArgs e)

            {

                List<KeyValuePair<string, double>> points0 = new List<KeyValuePair<string, double>>();

                for (int i = 0; i < ObjListSC.Count; i++)

                {

                    string StrName = ObjListSC[i].月龄;

                    double StrValue = Convert.ToDouble(ObjListSC[i].数值¦G3);

                    points0.Add(new KeyValuePair<string, double>("" + StrName, StrValue));

                }

                (sender as LineSeries).ItemsSource = points0;

            }

            #endregion

     

    效果图如下:

     

     

    二、柱形图

    前提布局:

    <toolkit:Chart x:Name="chartCJDB" Margin="5" Grid.Row="1" Title="Hail柱形图">

                                        <toolkit:Chart.Series>

     

                                        <toolkit:ColumnSeries Name="nan" Title="Hail数据一"

                                          DependentValueBinding="{Binding Value}"

                                          IndependentValueBinding="{Binding Key}"

                                         >

                                           

                                            </toolkit:ColumnSeries>

                                            <toolkit:ColumnSeries Name="nv" Title=" Hail数据二"

                                          DependentValueBinding="{Binding Value}"

                                          IndependentValueBinding="{Binding Key}"

                                         >

     

                                            </toolkit:ColumnSeries>

                                            <toolkit:ColumnSeries Name="he" Title=" Hail数据三"

                                          DependentValueBinding="{Binding Value}"

                                          IndependentValueBinding="{Binding Key}"

                                         >

     

                                            </toolkit:ColumnSeries>

     

     

     

                                        </toolkit:Chart.Series>

                                    </toolkit:Chart>

     

    后台代码

     

    public ObservableCollection<Hail_CanShu> SQ_GR_TJList=new ObservableCollection< Hail_CanShu>();

     

    KeyValuePair<string, int>[] objArry4 = new KeyValuePair<string, int>[SQ_GR_TJList.Count - 1];

                            for (int i = 0; i < SQ_GR_TJList.Count - 1; i++)

                                            {

                                                objArry4[i] = new KeyValuePair<string, int>(SQ_GR_TJList[i].名称, Convert.ToInt32(SQ_GR_TJList[i].Hail数据一));

                                            }

                             KeyValuePair<string, int>[] objArry5 = new KeyValuePair<string, int>[SQ_GR_TJList.Count - 1];

                            for (int i = 0; i < SQ_GR_TJList.Count - 1; i++)

                                            {

                                                objArry5[i] = new KeyValuePair<string, int>(SQ_GR_TJList[i].名称, Convert.ToInt32(SQ_GR_TJList[i]. Hail数据二));

                                            }

                             KeyValuePair<string, int>[] objArry6 = new KeyValuePair<string, int>[SQ_GR_TJList.Count - 1];

                            for (int i = 0; i < SQ_GR_TJList.Count - 1; i++)

                                            {

                                                objArry6[i] = new KeyValuePair<string, int>(SQ_GR_TJList[i].名称, Convert.ToInt32(SQ_GR_TJList[i]. Hail数据三));

                                            }

                            ((System.Windows.Controls.DataVisualization.Charting.ColumnSeries)chartCJDB.Series[0]).ItemsSource = objArry4;

                            ((System.Windows.Controls.DataVisualization.Charting.ColumnSeries)chartCJDB.Series[1]).ItemsSource = objArry5;

                            ((System.Windows.Controls.DataVisualization.Charting.ColumnSeries)chartCJDB.Series[2]).ItemsSource = objArry6;

     

    效果图如下

     

    三、  饼图

    前台布局

    <toolkit:Chart x:Name="chartCJDB" Margin="5" Grid.Row="1" Title="">

                <toolkit:Chart.Series>

                    <toolkit:PieSeries Title="Hail1"

                         IndependentValueBinding="{Binding Key}"

                         DependentValueBinding="{Binding Value}"

                    >

                       

                    </toolkit:PieSeries>

                </toolkit:Chart.Series>

            </toolkit:Chart>

    后台代码

    public ObservableCollection<Hail_CanShu> ObjListSC=new ObservableCollection< Hail_CanShu>();

     

                List<KeyValuePair<string, double>> points0 = new List<KeyValuePair<string, double>>();

                for (int i = 0; i < ObjListSC.Count; i++)

                {

                    string StrName = ObjListSC[i].月龄;

                    double StrValue = Convert.ToDouble(ObjListSC[i].数值);

                    points0.Add(new KeyValuePair<string, double>("" + StrName, StrValue));

                }

                ((System.Windows.Controls.DataVisualization.Charting.PieSeries)chartCJDB.Series[0]).ItemsSource = points0;

     

     

    效果如下:

    四、  点图

    前台布局

    <toolkit:Chart x:Name="chartCJDB" Margin="5" Grid.Row="1" Title="">

                <toolkit:Chart.Series>

                    <toolkit: ScatterSeries

    Title="Hail1"

                         IndependentValueBinding="{Binding Key}"

                         DependentValueBinding="{Binding Value}"

                    >

                       

                    </toolkit: ScatterSeries>

                </toolkit:Chart.Series>

            </toolkit:Chart>

    后台代码

    public ObservableCollection<Hail_CanShu> ObjListSC=new ObservableCollection< Hail_CanShu>();

     

                List<KeyValuePair<string, double>> points0 = new List<KeyValuePair<string, double>>();

                for (int i = 0; i < ObjListSC.Count; i++)

                {

                    string StrName = ObjListSC[i].月龄;

                    double StrValue = Convert.ToDouble(ObjListSC[i].数值);

                    points0.Add(new KeyValuePair<string, double>("" + StrName, StrValue));

                }

                ((System.Windows.Controls.DataVisualization.Charting. ScatterSeries)chartCJDB.Series[0]).ItemsSource = points0;

     

     

    效果如下:

    Silverlight图形报表

    作者:HaiL

    http://wenku.baidu.com/view/817dcc145f0e7cd18425366a.html

  • 相关阅读:
    Android Activity生命周期
    Android 横屏切换竖屏Activity的生命周期(转)
    (引用)mysql总结(二)
    (转载)mysql指令总结
    (引用)性能测试没有告诉你的
    参数化(引用)
    (引用)什么时候开展性能(二)
    (引用)什么时候开展性能(一)
    性能测试中容易混淆的概念
    浏览器内核
  • 原文地址:https://www.cnblogs.com/zhxm/p/2619118.html
Copyright © 2020-2023  润新知