예제 #1
0
        void dataAgeInit(DataTable dt)
        {
            int[] arr = new int[5];
            AgeSeries.Clear();
            //,fyear,cntm,fntm,age
            int  _60h = 0;
            int  _70h = 0;
            int  _80h = 0;
            int  _90h = 0;
            int  _00h = 0;
            long msum = 0;
            long fsum = 0;

            foreach (DataRow row in dt.Rows)
            {
                TotalM += Int32.Parse(row["cntm"].ToString());
                TotalF += Int32.Parse(row["cntf"].ToString());
                msum   += Int32.Parse(row["cntm"].ToString()) * Int32.Parse(row["age"].ToString());
                fsum   += Int32.Parse(row["cntf"].ToString()) * Int32.Parse(row["age"].ToString());
                if (row["fyear"].ToString().Substring(0, 3) == "196")
                {
                    _60h += Int32.Parse(row["cntm"].ToString());
                    _60h += Int32.Parse(row["cntf"].ToString());
                }
                else if (row["fyear"].ToString().Substring(0, 3) == "197")
                {
                    _70h += Int32.Parse(row["cntm"].ToString());
                    _70h += Int32.Parse(row["cntf"].ToString());
                }
                else if (row["fyear"].ToString().Substring(0, 3) == "198")
                {
                    _80h += Int32.Parse(row["cntm"].ToString());
                    _80h += Int32.Parse(row["cntf"].ToString());
                }
                else if (row["fyear"].ToString().Substring(0, 3) == "199")
                {
                    _90h += Int32.Parse(row["cntm"].ToString());
                    _90h += Int32.Parse(row["cntf"].ToString());
                }
                else if (row["fyear"].ToString().Substring(0, 3) == "200")
                {
                    _00h += Int32.Parse(row["cntm"].ToString());
                    _00h += Int32.Parse(row["cntf"].ToString());
                }
            }
            ValueAgeM    = msum / TotalM;
            ValueAgeF    = fsum / TotalF;
            Total        = TotalF + TotalM;
            ValueGenderM = double.Parse((TotalM / Total).ToString("f2")) * 100;
            ValueGenderF = double.Parse((TotalF / Total).ToString("f2")) * 100;
            AgeSeriesAdd(_60h, "60后");
            AgeSeriesAdd(_70h, "70后");
            AgeSeriesAdd(_80h, "80后");
            AgeSeriesAdd(_90h, "90后");
            AgeSeriesAdd(_00h, "00后");
        }
예제 #2
0
 private void AgeSeriesAdd(int _h, string title)
 {
     AgeSeries.Add(new PieSeries
     {
         Title           = title,
         StrokeThickness = 0,
         Values          = new ChartValues <ObservableValue> {
             new ObservableValue(_h)
         },
         DataLabels = true,
         LabelPoint = PiePointLabel
     });
 }