예제 #1
0
        private void RefreshAction(object obj)
        {
            SeriesCollection.Clear();
            var result = from p in DataAccess.DataBasic.DataPengaduan
                         from b in EnumSource.DaftarKekerasan()
                         from korban in p.Korban.Where(x => x.KekerasanDialami.Contains(b))
                         group korban by b into counts
                         select new { Key = counts.Key, value = counts.Count() };

            List <string> labels = new List <string>();

            datgrafirk.Clear();
            int number = 0;

            foreach (var item in EnumSource.DaftarKekerasan())
            {
                labels.Add("");
                var value = 0;
                var data  = result.Where(x => x.Key == item).FirstOrDefault();
                if (data != null)
                {
                    value = data.value;
                }

                SeriesCollection.Add(new ColumnSeries
                {
                    DataLabels = true,
                    Title      = $"{item}",
                    Values     = new ChartValues <int> {
                        value
                    }
                });

                number++;
                datgrafirk.Add(new GrafikModel {
                    NilaiText = number.ToString(), Kategori = item, Series = item, Nilai = value, Title = Title
                });
            }

            Labels = labels.ToArray();
            //new[] { "Jan", "Feb", "Mar", "Apr", "May" };
            YFormatter = value => ((int)value).ToString("N");
            XFormatter = value => ((int)value) <= 0 ? "" : ((int)value).ToString("N");
        }
예제 #2
0
 public AddKorbanView()
 {
     InitializeComponent();
     cmb.ItemSource = EnumSource.DaftarKekerasan();
 }