private void RefreshAction(object obj) { var dataKec = (from a in DataAccess.DataBasic.DataPendudukPerKecamatan() select a); var groupPengaduan = DataAccess.DataBasic.DataPengaduan.GroupBy(x => x.KodeDistrik); List <double> rasio = new List <double>(); List <double> jumlahKorbanAnak = new List <double>(); datgrafirk.Clear(); foreach (var kec in dataKec) { var model = new GrafikModel { Kategori = kec.Nama, Series = kec.Nama }; var kasus = groupPengaduan.Where(x => x.Key == kec.Id).FirstOrDefault(); if (kasus != null) { var listkasusAnak = (from p in kasus from korban in p.Korban where korban.TanggalLahir != null let age = p.TanggalLapor.Value.Year - korban.TanggalLahir.Year group p by age < 18 ? "Anak" :"Dewasa" into ages select new { Age = ages.Key, Persons = ages }); Double kasusAnak = listkasusAnak.Where(x => x.Age == "Anak").Count(); var total = kasusAnak + listkasusAnak.Where(x => x.Age == "Dewasa").Count(); double data = (Convert.ToDouble((kasusAnak / kec.Total) * 1000)); rasio.Add(Math.Round(data, 2)); jumlahKorbanAnak.Add(kasusAnak); model.Nilai = Math.Round(data, 2); model.Nilai2 = kasusAnak; } else { rasio.Add(0); jumlahKorbanAnak.Add(0); model.Nilai = 0; model.Nilai2 = 0; } datgrafirk.Add(model); } SeriesCollection = new SeriesCollection { new LineSeries { Title = "Rasio", Values = new ChartValues <double>(rasio), }, new ColumnSeries { Title = "Jumlah Korban Anak", Values = new ChartValues <double>(jumlahKorbanAnak) } }; Labels = (from a in DataAccess.DataBasic.GetKecamatan() select a.Nama).ToArray(); //new[] { "Jan", "Feb", "Mar", "Apr", "May" }; //YFormatter = value => value.ToString("C"); }
private void RefreshAction(object obj) { var dataKec = (from a in DataAccess.DataBasic.DataPendudukPerKecamatan() select a); var datapeng = (from a in DataAccess.DataBasic.DataPendudukKerjaPerKecamatan() select a); var groupPengaduan = DataAccess.DataBasic.DataPengaduan.GroupBy(x => x.KodeDistrik); List <double> listKasus = new List <double>(); List <double> listPekerja = new List <double>(); List <int> jumKasus = new List <int>(); datgrafirk.Clear(); SeriesCollection.Clear(); int number = 0; foreach (var kec in dataKec) { var kasus = groupPengaduan.Where(x => x.Key == kec.Id).FirstOrDefault(); var pekerja = datapeng.Where(x => x.Id == kec.Id).FirstOrDefault(); var model = new GrafikModel { Kategori = kec.Nama, Series = kec.Nama }; if (pekerja != null && kasus != null) { var data = Math.Round((Convert.ToDouble(pekerja.Menganggur) / kec.Total) * 100, 2); model.Nilai = data; listPekerja.Add(data); } else { model.Nilai = 0; listPekerja.Add(0); } if (kasus != null) { var data = Math.Round((Convert.ToDouble(kasus.Count()) / kec.Total) * 100, 2); listKasus.Add(data); jumKasus.Add(kasus.Count()); model.Nilai2 = (double)data; model.Nilai3 = kasus.Count(); } else { listKasus.Add(0); jumKasus.Add(0); model.Nilai2 = 0; model.Nilai3 = 0; } number++; datgrafirk.Add(model); } SeriesCollection.Clear(); SeriesCollection.Add(new LineSeries { Title = "Persen Penganguran", Values = new ChartValues <double>(listPekerja), }); SeriesCollection.Add(new LineSeries { Title = "Persen Kasus Terhadap Penduduk", Values = new ChartValues <double>(listKasus) }); SeriesCollection.Add(new ColumnSeries { Title = "Jumlah Kasus", Values = new ChartValues <int>(jumKasus) }); Labels = (from a in DataAccess.DataBasic.GetKecamatan() select a.Nama).ToArray(); //new[] { "Jan", "Feb", "Mar", "Apr", "May" }; //YFormatter = value => value.ToString("C"); }
private void RefreshAction(object obj) { var dataKec = (from a in DataAccess.DataBasic.DataPendudukPerKecamatan() select a); var groupPengaduan = DataAccess.DataBasic.DataPengaduan.GroupBy(x => x.KodeDistrik); List <double> rasio = new List <double>(); List <double> jumlahKorbanPerempuan = new List <double>(); datgrafirk.Clear(); foreach (var kec in dataKec) { var model = new GrafikModel { Kategori = kec.Nama, Series = kec.Nama }; var kasus = groupPengaduan.Where(x => x.Key == kec.Id).FirstOrDefault(); if (kasus != null) { double kasusPerem = (from a in kasus from korban in a.Korban where korban.Gender == Gender.P select korban).Count(); if (kasusPerem > 0) { double data = (Convert.ToDouble(kasusPerem / kec.Perempuan) * 10000); rasio.Add(Math.Round(data, 2)); jumlahKorbanPerempuan.Add(kasusPerem); model.Nilai = Math.Round(data, 2); model.Nilai2 = kasusPerem; } else { rasio.Add(0); jumlahKorbanPerempuan.Add(0); model.Nilai = 0; model.Nilai2 = 0; } } else { rasio.Add(0); jumlahKorbanPerempuan.Add(0); model.Nilai = 0; model.Nilai2 = 0; } datgrafirk.Add(model); } SeriesCollection = new SeriesCollection { new LineSeries { Title = "Rasio", Values = new ChartValues <double>(rasio), }, new ColumnSeries { Title = "Jumlah Korban Perempuan", Values = new ChartValues <double>(jumlahKorbanPerempuan) } }; Labels = (from a in DataAccess.DataBasic.GetKecamatan() select a.Nama).ToArray(); //new[] { "Jan", "Feb", "Mar", "Apr", "May" }; //YFormatter = value => value.ToString("C"); }