/// <summary> /// 임계치 알람 선 그리기 /// </summary> ///<param name="strTypeWeather">관측 종류(강우, 수위, 유속)</param> private void drawAlarmLine(string strTypeWeather) { //그래프의 알람라인 alarmLevelList = null; alarmLevelList = new List <double>(3); //1,2,3 차 임계치를 담기위함 CustomGridLine alarmLine1 = null; // 알람라인 ( 그리드 라인) CustomGridLine alarmLine2 = null; CustomGridLine alarmLine3 = null; //그래프 선 초기화 chtWeather2.AxisY.CustomGridLines.Clear(); switch (strTypeWeather) { case "강우": alarmLevelList.Add(getAlarmValue("7")); //강수량 1차 임계치 alarmLevelList.Add(getAlarmValue("8")); //강수량 2차 임계치 alarmLevelList.Add(getAlarmValue("9")); //강수량 3차 임계치 break; case "수위": alarmLevelList.Add(getAlarmValue("10")); //수위 1차 임계치 alarmLevelList.Add(getAlarmValue("11")); //수위 2차 임계치 alarmLevelList.Add(getAlarmValue("12")); //수위 3차 임계치 break; case "유속": alarmLevelList.Add(getAlarmValue("13")); //유속 1차 임계치 alarmLevelList.Add(getAlarmValue("14")); //유속 2차 임계치 alarmLevelList.Add(getAlarmValue("15")); //유속 3차 임계치 break; } //경계 alarmLine1 = new CustomGridLine(); alarmLine1.Value = alarmLevelList[0]; //기상정보(강우,...) 1차 임계치 alarmLine1.Color = Color.Orange; alarmLine1.Text = "주의"; alarmLine1.TextColor = Color.Orange; chtWeather2.AxisY.CustomGridLines.Add(alarmLine1); //위험 alarmLine2 = new CustomGridLine(); alarmLine2.Value = alarmLevelList[1];//기상정보(강우,...) 2차 임계치 alarmLine2.Color = Color.Violet; alarmLine2.Text = "경계"; alarmLine2.TextColor = Color.OrangeRed; chtWeather2.AxisY.CustomGridLines.Add(alarmLine2); //대피 alarmLine3 = new CustomGridLine(); alarmLine3.Value = alarmLevelList[2];//기상정보(강우,...) 3차 임계치 alarmLine3.Color = Color.Red; alarmLine3.Text = "대피"; alarmLine3.TextColor = Color.Red; chtWeather2.AxisY.CustomGridLines.Add(alarmLine3); }
public void ShowTagLine_FX(ChartFX.WebForms.Chart ChartName, int TagValue) { CustomGridLine TagLine = new CustomGridLine(); TagLine.Color = Color.Red; TagLine.Value = TagValue; TagLine.ShowLine = true; TagLine.ShowText = true; TagLine.TextColor = Color.Red; ChartName.AxisY.CustomGridLines.Add(TagLine); ConditionalHighlightAttributes hCustomGridAttr = ChartName.AxisY.CustomGridLines[0].Highlight; hCustomGridAttr.Series = 1; }
public TelemetryChart() : base() { AreaSeriesDefinition lineSeries = new AreaSeriesDefinition(); lineSeries.ShowItemLabels = false; lineSeries.ShowPointMarks = false; SeriesMapping dataMapping = new SeriesMapping(); dataMapping.SeriesDefinition = lineSeries; dataMapping.ItemMappings.Add(new ItemMapping("TimePositionAsDateTime", DataPointMember.XValue)); dataMapping.ItemMappings.Add(new ItemMapping("PercentageThreshold", DataPointMember.YValue)); dataMapping.ItemMappings[1].SamplingFunction = ChartSamplingFunction.KeepExtremes; this.SeriesMappings.Add(dataMapping); this.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.None; this.DefaultView.ChartArea.ZoomScrollSettingsY.ScrollMode = ScrollMode.None; this.DefaultView.ChartLegend.Visibility = System.Windows.Visibility.Collapsed; this.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "#VAL{HH:mm:ss}"; this.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "#VAL{p0}"; this.AxisElementBrush = new SolidColorBrush(Colors.White); this.AxisForeground = new SolidColorBrush(Colors.White); this.DefaultView.ChartArea.AxisY.MajorGridLinesVisibility = Visibility.Collapsed; this.DefaultView.ChartArea.AxisY.MinorGridLinesVisibility = Visibility.Collapsed; this.DefaultView.ChartArea.AxisY.StripLinesVisibility = Visibility.Collapsed; this.DefaultView.ChartArea.AxisX.MajorGridLinesVisibility = Visibility.Collapsed; this.DefaultView.ChartArea.AxisX.Step = 1.0 / 24.0 / 3600.0 / 2.0; this.DefaultView.ChartArea.LabelFormatBehavior = LabelFormatBehavior.None; this.SamplingSettings.SamplingThreshold = 1000; this.DefaultView.ChartArea.EnableAnimations = false; line = new CustomGridLine(); line.XIntercept = 0; line.Visibility = System.Windows.Visibility.Visible; line.Stroke = new SolidColorBrush(Colors.Green); line.StrokeThickness = 2; this.DefaultView.ChartArea.AxisY.AutoRange = false; zone = new MarkedZone(); this.DefaultView.ChartArea.Annotations.Add(zone); }
/// <summary> /// 임계치 알람 선 그리기 /// </summary> ///<param name="strTypeWeather">관측 종류(강우, 수위, 유속)</param> private void drawAlarmLine(string strTypeWeather, List <double> alarmLevelList) { if (alarmLevelList != null) { //그래프의 알람라인 CustomGridLine alarmLine1 = null; CustomGridLine alarmLine2 = null; CustomGridLine alarmLine3 = null; //그래프 선 초기화 chtWeather.AxisY.CustomGridLines.Clear(); //경계 alarmLine1 = new CustomGridLine(); alarmLine1.Value = alarmLevelList[0]; alarmLine1.Color = Color.OrangeRed; alarmLine1.Text = "경계"; alarmLine1.TextColor = Color.Orange; chtWeather.AxisY.CustomGridLines.Add(alarmLine1); //위험 alarmLine2 = new CustomGridLine(); alarmLine2.Value = alarmLevelList[1]; alarmLine2.Color = Color.OrangeRed; alarmLine2.Text = "위험"; alarmLine2.TextColor = Color.OrangeRed; chtWeather.AxisY.CustomGridLines.Add(alarmLine2); //대피 alarmLine3 = new CustomGridLine(); alarmLine3.Value = alarmLevelList[2]; alarmLine3.Color = Color.Red; alarmLine3.Text = "대피"; alarmLine3.TextColor = Color.Red; chtWeather.AxisY.CustomGridLines.Add(alarmLine3); } }
public void LoadDataChart(ObservableCollection <RefTimestamp> refTimestamp) { rChart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "HH:mm:ss"; rChart.DefaultView.ChartArea.AxisX.LabelRotationAngle = 45; var Tank1Series = new DataSeries { LegendLabel = "Tank 1", Definition = new LineSeriesDefinition(), }; if (t1C.IsChecked != null && t1C.IsChecked.Value) { CustomGridLine gridline = new CustomGridLine(); var tank1Max = refTimestamp[0].RootRefObject.tank1.max; if (tank1Max != null) { gridline.YIntercept = tank1Max.Value; } gridline.Stroke = new SolidColorBrush(Colors.DeepSkyBlue); gridline.StrokeThickness = 2; gridline.ElementStyle = this.Resources["CustomGridLineStyle"] as Style; rChart.DefaultView.ChartArea.Annotations.Add(gridline); Tank1Series.Definition.Appearance.Stroke = Tank1Series.Definition.Appearance.Fill = new SolidColorBrush(Colors.DeepSkyBlue); } var Tank2Series = new DataSeries { LegendLabel = "Tank 2", Definition = new LineSeriesDefinition(), }; if (t2C.IsChecked.Value) { CustomGridLine gridline2 = new CustomGridLine(); var tank2Max = refTimestamp[0].RootRefObject.tank2.max; if (tank2Max != null) { gridline2.YIntercept = tank2Max.Value; } gridline2.Stroke = new SolidColorBrush(Colors.Red); gridline2.StrokeThickness = 2; gridline2.ElementStyle = this.Resources["CustomGridLineStyle"] as Style; rChart.DefaultView.ChartArea.Annotations.Add(gridline2); Tank2Series.Definition.Appearance.Stroke = Tank2Series.Definition.Appearance.Fill = new SolidColorBrush(Colors.Red); } var Tank3Series = new DataSeries { LegendLabel = "Tank 3", Definition = new LineSeriesDefinition(), }; if (t3C.IsChecked.Value) { CustomGridLine gridline3 = new CustomGridLine(); var tank3Max = refTimestamp[0].RootRefObject.tank3.max; if (tank3Max != null) { gridline3.YIntercept = tank3Max.Value; } gridline3.Stroke = new SolidColorBrush(Colors.DarkOrange); gridline3.StrokeThickness = 2; gridline3.ElementStyle = this.Resources["CustomGridLineStyle"] as Style; rChart.DefaultView.ChartArea.Annotations.Add(gridline3); Tank3Series.Definition.Appearance.Stroke = Tank3Series.Definition.Appearance.Fill = new SolidColorBrush(Colors.DarkOrange); } var pumpe1Series = new DataSeries { LegendLabel = "Pumpe 1", Definition = new LineSeriesDefinition(), }; if (p1C.IsChecked.Value) { CustomGridLine gridlinep1 = new CustomGridLine(); var pump1Max = refTimestamp[0].RootRefObject.pumpe1.max; if (pump1Max != null) { gridlinep1.YIntercept = pump1Max.Value; } gridlinep1.Stroke = new SolidColorBrush(Colors.Chartreuse); gridlinep1.StrokeThickness = 2; gridlinep1.ElementStyle = this.Resources["CustomGridLineStyle"] as Style; rChart.DefaultView.ChartArea.Annotations.Add(gridlinep1); pumpe1Series.Definition.Appearance.Stroke = pumpe1Series.Definition.Appearance.Fill = new SolidColorBrush(Colors.Chartreuse); } var pumpe2Series = new DataSeries { LegendLabel = "Pumpe 2", Definition = new LineSeriesDefinition(), }; if (p2C.IsChecked.Value) { CustomGridLine gridlinep2 = new CustomGridLine(); var pump2Max = refTimestamp[0].RootRefObject.pumpe2.max; if (pump2Max != null) { gridlinep2.YIntercept = pump2Max.Value; } gridlinep2.Stroke = new SolidColorBrush(Colors.OliveDrab); gridlinep2.StrokeThickness = 2; gridlinep2.ElementStyle = this.Resources["CustomGridLineStyle"] as Style; rChart.DefaultView.ChartArea.Annotations.Add(gridlinep2); pumpe2Series.Definition.Appearance.Stroke = pumpe2Series.Definition.Appearance.Fill = new SolidColorBrush(Colors.OliveDrab); } var pumpe3Series = new DataSeries { LegendLabel = "Pumpe 3", Definition = new LineSeriesDefinition(), }; if (p3C.IsChecked.Value) { CustomGridLine gridlinep3 = new CustomGridLine(); var pump3Max = refTimestamp[0].RootRefObject.pumpe3.max; if (pump3Max != null) { gridlinep3.YIntercept = pump3Max.Value; } gridlinep3.Stroke = new SolidColorBrush(Colors.Black); gridlinep3.StrokeThickness = 2; gridlinep3.ElementStyle = this.Resources["CustomGridLineStyle"] as Style; rChart.DefaultView.ChartArea.Annotations.Add(gridlinep3); pumpe3Series.Definition.Appearance.Stroke = pumpe3Series.Definition.Appearance.Fill = new SolidColorBrush(Colors.Black); } var adg1Series = new DataSeries { LegendLabel = "Adg 1", Definition = new LineSeriesDefinition(), }; if (a1C.IsChecked.Value) { CustomGridLine gridlinea1 = new CustomGridLine(); var adg1Max = refTimestamp[0].RootRefObject.adg1.max; if (adg1Max != null) { gridlinea1.YIntercept = adg1Max.Value; } gridlinea1.Stroke = new SolidColorBrush(Colors.Aqua); gridlinea1.StrokeThickness = 2; gridlinea1.ElementStyle = this.Resources["CustomGridLineStyle"] as Style; rChart.DefaultView.ChartArea.Annotations.Add(gridlinea1); adg1Series.Definition.Appearance.Stroke = adg1Series.Definition.Appearance.Fill = new SolidColorBrush(Colors.Aqua); } var adg2Series = new DataSeries { LegendLabel = "Adg 2", Definition = new LineSeriesDefinition(), }; if (a2C.IsChecked.Value) { CustomGridLine gridlinea2 = new CustomGridLine(); var adg2Max = refTimestamp[0].RootRefObject.adg2.max; if (adg2Max != null) { gridlinea2.YIntercept = adg2Max.Value; } gridlinea2.Stroke = new SolidColorBrush(Colors.Bisque); gridlinea2.StrokeThickness = 2; gridlinea2.ElementStyle = this.Resources["CustomGridLineStyle"] as Style; rChart.DefaultView.ChartArea.Annotations.Add(gridlinea2); adg2Series.Definition.Appearance.Stroke = adg2Series.Definition.Appearance.Fill = new SolidColorBrush(Colors.Bisque); } var adg3Series = new DataSeries { LegendLabel = "Adg 3", Definition = new LineSeriesDefinition(), }; if (a3C.IsChecked.Value) { CustomGridLine gridlinea3 = new CustomGridLine(); var adg3Max = refTimestamp[0].RootRefObject.adg3.max; if (adg3Max != null) { gridlinea3.YIntercept = adg3Max.Value; } gridlinea3.Stroke = new SolidColorBrush(Colors.CadetBlue); gridlinea3.StrokeThickness = 2; gridlinea3.ElementStyle = this.Resources["CustomGridLineStyle"] as Style; rChart.DefaultView.ChartArea.Annotations.Add(gridlinea3); adg3Series.Definition.Appearance.Stroke = adg3Series.Definition.Appearance.Fill = new SolidColorBrush(Colors.CadetBlue); } var gas1Series = new DataSeries { LegendLabel = "Gas 1", Definition = new LineSeriesDefinition(), }; if (g1C.IsChecked.Value) { CustomGridLine gridlineg1 = new CustomGridLine(); var gas1Max = refTimestamp[0].RootRefObject.gas1.max; if (gas1Max != null) { gridlineg1.YIntercept = gas1Max.Value; } gridlineg1.Stroke = new SolidColorBrush(Colors.DarkOrchid); gridlineg1.StrokeThickness = 2; gridlineg1.ElementStyle = this.Resources["CustomGridLineStyle"] as Style; rChart.DefaultView.ChartArea.Annotations.Add(gridlineg1); gas1Series.Definition.Appearance.Stroke = gas1Series.Definition.Appearance.Fill = new SolidColorBrush(Colors.DarkOrchid); } var gas2Series = new DataSeries { LegendLabel = "Gas 1", Definition = new LineSeriesDefinition(), }; if (g2C.IsChecked.Value) { CustomGridLine gridlineg2 = new CustomGridLine(); var gas2Max = refTimestamp[0].RootRefObject.gas2.max; if (gas2Max != null) { gridlineg2.YIntercept = gas2Max.Value; } gridlineg2.Stroke = new SolidColorBrush(Colors.DarkRed); gridlineg2.StrokeThickness = 2; gridlineg2.ElementStyle = this.Resources["CustomGridLineStyle"] as Style; rChart.DefaultView.ChartArea.Annotations.Add(gridlineg2); gas2Series.Definition.Appearance.Stroke = gas2Series.Definition.Appearance.Fill = new SolidColorBrush(Colors.DarkRed); } foreach (var reftimestamp in refTimestamp) { if (t1C.IsChecked.Value) { var itemt1 = new DataPoint { YValue = double.Parse(reftimestamp.RootRefObject.tank1.actual), XValue = DateTime.Parse(reftimestamp.Timestamp).ToOADate() }; Tank1Series.Add(itemt1); } if (t2C.IsChecked.Value) { var itemt2 = new DataPoint { YValue = double.Parse(reftimestamp.RootRefObject.tank2.actual), XValue = DateTime.Parse(reftimestamp.Timestamp).ToOADate() }; Tank2Series.Add(itemt2); } if (t3C.IsChecked.Value) { var itemt3 = new DataPoint { YValue = double.Parse(reftimestamp.RootRefObject.tank3.actual), XValue = DateTime.Parse(reftimestamp.Timestamp).ToOADate() }; Tank3Series.Add(itemt3); } if (p1C.IsChecked.Value) { var itemp1 = new DataPoint { YValue = double.Parse(reftimestamp.RootRefObject.pumpe1.actual), XValue = DateTime.Parse(reftimestamp.Timestamp).ToOADate() }; pumpe1Series.Add(itemp1); } if (p2C.IsChecked.Value) { var itemp2 = new DataPoint { YValue = double.Parse(reftimestamp.RootRefObject.pumpe2.actual), XValue = DateTime.Parse(reftimestamp.Timestamp).ToOADate() }; pumpe2Series.Add(itemp2); } if (p3C.IsChecked.Value) { var itemp3 = new DataPoint { YValue = double.Parse(reftimestamp.RootRefObject.pumpe3.actual), XValue = DateTime.Parse(reftimestamp.Timestamp).ToOADate() }; pumpe3Series.Add(itemp3); } if (a1C.IsChecked.Value) { var itema1 = new DataPoint { YValue = double.Parse(reftimestamp.RootRefObject.adg1.actual), XValue = DateTime.Parse(reftimestamp.Timestamp).ToOADate() }; adg1Series.Add(itema1); } if (a2C.IsChecked.Value) { var itema2 = new DataPoint { YValue = double.Parse(reftimestamp.RootRefObject.adg2.actual), XValue = DateTime.Parse(reftimestamp.Timestamp).ToOADate() }; adg2Series.Add(itema2); } if (a3C.IsChecked.Value) { var itema3 = new DataPoint { YValue = double.Parse(reftimestamp.RootRefObject.adg3.actual), XValue = DateTime.Parse(reftimestamp.Timestamp).ToOADate() }; adg3Series.Add(itema3); } if (g1C.IsChecked.Value) { var itemg1 = new DataPoint { YValue = double.Parse(reftimestamp.RootRefObject.gas1.actual), XValue = DateTime.Parse(reftimestamp.Timestamp).ToOADate() }; gas1Series.Add(itemg1); } if (g2C.IsChecked.Value) { var itemg2 = new DataPoint { YValue = double.Parse(reftimestamp.RootRefObject.gas2.actual), XValue = DateTime.Parse(reftimestamp.Timestamp).ToOADate() }; gas2Series.Add(itemg2); } } if (refTimestamp.Count > 1) { rChart.DefaultView.ChartArea.DataSeries.Clear(); } if (t1C.IsChecked.Value) { rChart.DefaultView.ChartArea.DataSeries.Add(Tank1Series); } if (t2C.IsChecked.Value) { rChart.DefaultView.ChartArea.DataSeries.Add(Tank2Series); } if (t3C.IsChecked.Value) { rChart.DefaultView.ChartArea.DataSeries.Add(Tank3Series); } if (p1C.IsChecked.Value) { rChart.DefaultView.ChartArea.DataSeries.Add(pumpe1Series); } if (p2C.IsChecked.Value) { rChart.DefaultView.ChartArea.DataSeries.Add(pumpe2Series); } if (p3C.IsChecked.Value) { rChart.DefaultView.ChartArea.DataSeries.Add(pumpe3Series); } if (a1C.IsChecked.Value) { rChart.DefaultView.ChartArea.DataSeries.Add(adg1Series); } if (a2C.IsChecked.Value) { rChart.DefaultView.ChartArea.DataSeries.Add(adg2Series); } if (a3C.IsChecked.Value) { rChart.DefaultView.ChartArea.DataSeries.Add(adg3Series); } if (g1C.IsChecked.Value) { rChart.DefaultView.ChartArea.DataSeries.Add(gas1Series); } if (g2C.IsChecked.Value) { rChart.DefaultView.ChartArea.DataSeries.Add(gas2Series); } }
//Сформувати статистику private void CreateButton_Click(object sender, RoutedEventArgs e) { using (SqlConnection con = new SqlConnection(connectionString)) { //Обрати критерію з ComboBox ComboBoxItem comboItem = (ComboBoxItem)CriteriaComboBox.SelectedItem; string criterianame = comboItem.Name; //Обрати місяць ComboBoxItem comboItem2 = (ComboBoxItem)MonthComboBox.SelectedItem; string monthname = comboItem2.Name; //Запит для виводу інформації про діяльність string query = String.Format("SELECT wk.Surname , act.{0} " + "FROM Workers wk " + "INNER JOIN Activity act on wk.ID=act.WorkerID " + "WHERE act.CalendarMonthName = '{1}' AND act.CalendarYear = {2} ", criterianame, monthname, NumericUpDown.Value); con.Open(); SqlDataAdapter dataAdapter = new SqlDataAdapter(query, connectionString); DataTable table = new DataTable(); dataAdapter.Fill(table); Chart.ItemsSource = table; //Заговолок графіку відповідно до обраних параметрів Chart.DefaultView.ChartTitle.Content = "Статистика: " + comboItem.Content.ToString().ToLowerInvariant() + " за " + monthname.ToLowerInvariant() + " " + NumericUpDown.Value + " року"; //Автоматично генерувати легенду Chart.DefaultView.ChartLegend.UseAutoGeneratedItems = false; //Назва осей X та Y Chart.DefaultView.ChartArea.AxisX.Title = "Працівник (табельний номер)"; Chart.DefaultView.ChartArea.AxisY.Title = "Кількість днів"; Chart.DefaultView.ChartLegend.UseAutoGeneratedItems = true; //Назва легенди ChartLegendItem item1 = new ChartLegendItem(); item1.Label = "Дні"; item1.MarkerFill = new SolidColorBrush(Colors.DarkTurquoise); Chart.DefaultView.ChartLegend.Items.Add(item1); //Форма значка легенди Chart.DefaultView.ChartLegend.LegendItemMarkerShape = MarkerShape.Circle; //показати лінії сітки //для присутності if (comboItem.Name.ToString() == "Present") { //позитивне значення CustomGridLine gridlinePositive = new CustomGridLine(); gridlinePositive.YIntercept = 20; gridlinePositive.Stroke = new SolidColorBrush(Colors.Chartreuse); gridlinePositive.StrokeThickness = 2; this.Chart.DefaultView.ChartArea.Annotations.Add(gridlinePositive); //негативне значення CustomGridLine gridlineNegative = new CustomGridLine(); gridlineNegative.YIntercept = 5; gridlineNegative.Stroke = new SolidColorBrush(Colors.Tomato); gridlineNegative.StrokeThickness = 2; this.Chart.DefaultView.ChartArea.Annotations.Add(gridlineNegative); } //для відсутності if (comboItem.Name.ToString() == "Absence") { //позитивне значення CustomGridLine gridlinePositive = new CustomGridLine(); gridlinePositive.YIntercept = 3; gridlinePositive.Stroke = new SolidColorBrush(Colors.Chartreuse); gridlinePositive.StrokeThickness = 2; this.Chart.DefaultView.ChartArea.Annotations.Add(gridlinePositive); //негативне значення CustomGridLine gridlineNegative = new CustomGridLine(); gridlineNegative.YIntercept = 15; gridlineNegative.Stroke = new SolidColorBrush(Colors.Tomato); gridlineNegative.StrokeThickness = 2; this.Chart.DefaultView.ChartArea.Annotations.Add(gridlineNegative); } } }