private void btn_selectabnormal_event_Click(object sender, RoutedEventArgs e)
        {
            DateTime startdate      = ((dp_startdate.SelectedDate == null) ? DateTime.MinValue : (DateTime)dp_startdate.SelectedDate);
            DateTime enddate        = ((dp_enddate.SelectedDate == null) ? DateTime.MinValue : (DateTime)dp_enddate.SelectedDate);
            string   event_category = this.cbb_category.Text;
            Abnormal_event_analysis_ViewModel               abnormal_Event_Analysis_ViewModel = new Abnormal_event_analysis_ViewModel();
            List <Abnormal_event_analysis_ViewModel>        event_analysiss             = abnormal_Event_Analysis_ViewModel.SelectAbnormal_event_analysis(startdate, enddate, event_category, unit_Names);
            ObservableCollection <Abnormal_event_analysiss> abnormal_event_analysislist = new ObservableCollection <Abnormal_event_analysiss>();

            foreach (var row in event_analysiss)
            {
                abnormal_event_analysislist.Add(new Abnormal_event_analysiss {
                    事件案號   = row.Abnormal_event_ID,
                    事件主旨   = row.Abnormal_event,
                    志工姓名   = row.Volunteer_name,
                    運用單位   = row.Application_unit,
                    異常事件類別 = row.Event_category,
                    處理階段   = row.Stage,
                    通報時間   = row.Notification_date,
                    結案時間   = row.Closing_date,
                    志工督導   = row.Supervisor,
                    處理結果   = row.Result,
                    運用單位描述 = row.Unit_descrition,
                    志工自述   = row.Volunteer_description,
                    志工督導描述 = row.Supervisor_description,
                    志工幹部   = row.Volunteer_leader,
                    志工督導主管 = row.Supervisor_heads,
                    駁回原因   = row.Rejection_Reason
                });
            }

            this.dg_abnormal_event.ItemsSource = abnormal_event_analysislist;

            Abnormal_event_analysis_chart_View abnormal_Event_Analysis_Chart_View = new Abnormal_event_analysis_chart_View(abnormal_Event_Analysis_ViewModel);

            //abnormal_Event_Analysis_Chart_View.Show();
            wondow_show.Children.Clear();
            object content = abnormal_Event_Analysis_Chart_View.Content;

            abnormal_Event_Analysis_Chart_View.Content = null;
            wondow_show.Children.Add(content as UIElement);
        }
Beispiel #2
0
        public Abnormal_event_analysis_chart_View(object abnormal_Event_Analysis_ViewModel)
        {
            InitializeComponent();
            Abnormal_event_analysis_ViewModel Event_Analysis = abnormal_Event_Analysis_ViewModel as Abnormal_event_analysis_ViewModel;
            //折線圖
            Chart chart1 = this.FindName("Chart1") as Chart;

            chart1.Titles.Add("月份數據分析");
            //chart1.DataSource = Event_Analysis.Compute_Eventtypes;
            List <string> xValues1 = new List <string>();
            List <int>    yValues1 = new List <int>();

            foreach (var row in Event_Analysis.Compute_Eventmonths)
            {
                //chart1.Series[0].Points.AddXY(row.Month,row.event_count);
                xValues1.Add(row.Month.ToString());
                yValues1.Add(row.event_count);
            }
            chart1.Series[0].Points.DataBindXY(xValues1, yValues1);
            chart1.Series[0].ChartType           = SeriesChartType.Spline;
            chart1.Series[0].BorderWidth         = 6;
            chart1.Series[0].IsValueShownAsLabel = true;
            //chart1.Series[0].Label = "#VAL";
            chart1.ChartAreas[0].AxisX.Title = "月份";
            chart1.ChartAreas[0].AxisY.Title = "數量";
            //圓餅圖
            Chart chart2 = this.FindName("Chart2") as Chart;

            chart2.Titles.Add("運用單位數據分析");
            //chart2.DataSource = Event_Analysis.Compute_Applicationunits;
            List <string> xValues2 = new List <string>();
            List <int>    yValues2 = new List <int>();

            foreach (var row in Event_Analysis.Compute_Applicationunits)
            {
                xValues2.Add(row.Application_unit);
                yValues2.Add(row.event_count);
            }
            chart2.Series[0].Points.DataBindXY(xValues2, yValues2);
            //chart2.Series[0].Points.DataBindXY(xValues2, yValues2);
            chart2.Series[0].ChartType          = SeriesChartType.Doughnut;
            chart2.Series[0]["PieLabelStyle"]   = "Inside";
            chart2.Series[0]["DoughnutRadius"]  = "80";
            chart2.Series[0]["PieDrawingStyle"] = "Concave";
            //chart2.Legends
            //長條圖
            Chart chart3 = this.FindName("Chart3") as Chart;

            chart3.Titles.Add("事件類別數據分析");
            //chart3.DataSource = Event_Analysis.Compute_Eventtypes;
            chart3.ChartAreas[0].AxisX.Title     = "類別";
            chart3.ChartAreas[0].AxisY.Title     = "數量";
            chart3.Series[0].ChartType           = SeriesChartType.Bar;
            chart3.Series[0]["PointWidth"]       = "0.8";
            chart3.Series[0].IsValueShownAsLabel = true;
            chart3.Series[0]["BarLabelStyle"]    = "Center";
            chart3.Series[0]["DrawingStyle"]     = "Emboss";
            //chart3.Series[0].Label = "#VAL";
            List <string> xValues3 = new List <string>();
            List <int>    yValues3 = new List <int>();

            foreach (var row in Event_Analysis.Compute_Eventtypes)
            {
                xValues3.Add(row.event_Category);
                yValues3.Add(row.event_count);
            }
            chart3.Series[0].Points.DataBindXY(xValues3, yValues3);
        }