public double getMax(List <DataValue> datapoint, string str) { double[] dataPredict = new double[datapoint.Count]; double[] dataValue = new double[datapoint.Count]; for (int i = 0; i < datapoint.Count; i++) { dataPredict[i] = datapoint[i].PredictData; if (str == "000051") { dataValue[i] = datapoint[i].Y; } else if (str == "000052") { dataValue[i] = datapoint[i].Y; } else if (str == "000053") { dataValue[i] = datapoint[i].Y; } else if (str == "000054") { dataValue[i] = datapoint[i].Y; } } return(SelectData.getHigh(dataPredict) > SelectData.getHigh(dataValue)?SelectData.getHigh(dataPredict):SelectData.getHigh(dataValue)); }
public double getMax(List <DataValue> datapoint) { double[] dataPredict = new double[datapoint.Count]; for (int i = 0; i < datapoint.Count; i++) { dataPredict[i] = datapoint[i].PredictData; } return(SelectData.getHigh(dataPredict)); }
private void initDate() { int date; if (wheatePeatsZongQunHeader.predictIndex == 0) { return; } if (!this.IsLoaded) { return; } DateTime dateTime = (DateTime)dateSelect.SelectedDate; TimeSpan time = dateTime - (new DateTime(2015, 7, 17)); date = time.Days; try { List <DataValue> Axis = SelectData.getPredictData("000051", date); DataSource yData = new DataSource("000051"); DataSource y1Data = new DataSource("000052"); DataSource y2Data = new DataSource("000053"); DataSource y3Data = new DataSource("000054"); List <DataValue> predictYData = SelectData.getPredictData("000051", date); List <DataValue> predictY1Data = SelectData.getPredictData("000052", date); List <DataValue> predictY2Data = SelectData.getPredictData("000053", date); List <DataValue> predictY3Data = SelectData.getPredictData("000054", date); colGrainPredict.MarkerType = MarkerType.None; colGrainPredict.Thickness = 5; colGrainPredict.ItemsSource = predictYData; colGrainPredict.ValueMemberPath = "PredictData"; colGrainPredict.XAxis = categoryDateAxis; colGrainPredict.YAxis = numericYAxis; colGrainPredict.Opacity = 0.5; colGrainPredict.Visibility = Visibility.Hidden; colGrainPredict.Brush = new SolidColorBrush(Colors.Green); colGrainPredict.ToolTip = colGrain.ToolTip; this.CategoryChart.Series.Add(colGrainPredict); colCornPredict.MarkerType = MarkerType.None; colCornPredict.Thickness = 5; colCornPredict.ItemsSource = predictY1Data; colCornPredict.ValueMemberPath = "PredictData"; colCornPredict.XAxis = categoryDateAxis; colCornPredict.YAxis = numericYAxis; colCornPredict.Opacity = 0.5; colCornPredict.Visibility = Visibility.Hidden; colCornPredict.Brush = new SolidColorBrush(Colors.Black); colCornPredict.ToolTip = colCorn.ToolTip; this.CategoryChart.Series.Add(colCornPredict); colRicePredict.MarkerType = MarkerType.None; colRicePredict.Thickness = 5; colRicePredict.ItemsSource = predictY2Data; colRicePredict.ValueMemberPath = "PredictData"; colRicePredict.XAxis = categoryDateAxis; colRicePredict.YAxis = numericYAxis; colRicePredict.Opacity = 0.5; colRicePredict.Visibility = Visibility.Hidden; colRicePredict.Brush = new SolidColorBrush(Colors.Chocolate); colRicePredict.ToolTip = colRice.ToolTip; this.CategoryChart.Series.Add(colRicePredict); colTCCPredict.MarkerType = MarkerType.None; colTCCPredict.Thickness = 5; colTCCPredict.ItemsSource = predictY3Data; colTCCPredict.ValueMemberPath = "PredictData"; colTCCPredict.XAxis = categoryDateAxis; colTCCPredict.YAxis = numericYAxis; colTCCPredict.Opacity = 0.5; colTCCPredict.Visibility = Visibility.Hidden; colTCCPredict.Brush = new SolidColorBrush(Colors.Blue); colTCCPredict.ToolTip = colTCC.ToolTip; this.CategoryChart.Series.Add(colTCCPredict); categoryDateAxis.ItemsSource = Axis; colCorn.ItemsSource = y1Data; colRice.ItemsSource = y2Data; colGrain.ItemsSource = yData; colTCC.ItemsSource = y3Data; numericXAxis.MinimumValue = Convert.ToDouble(Axis[0].date.Ticks); numericXAxis.MaximumValue = Convert.ToDouble(Axis[Axis.Count - 1].date.Ticks); double[] high = new double[8]; high[0] = getMax(predictYData); high[1] = getMax(predictY1Data); high[2] = getMax(predictY2Data); high[3] = getMax(predictY3Data); numericYAxis.MaximumValue = SelectData.getHigh(high) + 5; //ClipLine.Value = yData.Count; ClipLine.Value = Convert.ToDouble((new DateTime(2015, 7, 17)).Ticks); } catch (Exception e1) { MessageBox.Show(e1.Message); } if (butCorn.IsChecked == true) { ClickPredict(butCorn); } else if (butGrain.IsChecked == true) { ClickPredict(butGrain); } else if (butRice.IsChecked == true) { ClickPredict(butRice); } else if (butTcc.IsChecked == true) { ClickPredict(butTcc); } }
private void Grid_Loaded(object sender, RoutedEventArgs e) { try { predictYData = SelectData.getAllPredictValue("000051"); predictY1Data = SelectData.getAllPredictValue("000052"); predictY2Data = SelectData.getAllPredictValue("000053"); predictY3Data = SelectData.getAllPredictValue("000054"); colGrainPredict.MarkerType = MarkerType.None; colGrainPredict.Thickness = 5; colGrainPredict.ItemsSource = predictYData; colGrainPredict.ValueMemberPath = "PredictData"; colGrainPredict.XAxis = categoryDateAxis; colGrainPredict.YAxis = numericYAxis; colGrainPredict.Opacity = 0.5; colGrainPredict.Visibility = Visibility.Hidden; colGrainPredict.ToolTip = colGrain.ToolTip; colGrainPredict.Brush = new SolidColorBrush(Colors.Green); this.CategoryChart.Series.Add(colGrainPredict); colCornPredict.MarkerType = MarkerType.None; colCornPredict.Thickness = 5; colCornPredict.ItemsSource = predictY1Data; colCornPredict.ValueMemberPath = "PredictData"; colCornPredict.XAxis = categoryDateAxis; colCornPredict.YAxis = numericYAxis; colCornPredict.Opacity = 0.5; colCornPredict.Visibility = Visibility.Hidden; colCornPredict.ToolTip = colCorn.ToolTip; colCornPredict.Brush = new SolidColorBrush(Colors.Black); this.CategoryChart.Series.Add(colCornPredict); colRicePredict.MarkerType = MarkerType.None; colRicePredict.Thickness = 5; colRicePredict.ItemsSource = predictY2Data; colRicePredict.ValueMemberPath = "PredictData"; colRicePredict.XAxis = categoryDateAxis; colRicePredict.YAxis = numericYAxis; colRicePredict.Opacity = 0.5; colRicePredict.Visibility = Visibility.Visible; colRicePredict.ToolTip = colRice.ToolTip; colRicePredict.Brush = new SolidColorBrush(Colors.Chocolate); this.CategoryChart.Series.Add(colRicePredict); colTCCPredict.MarkerType = MarkerType.None; colTCCPredict.Thickness = 5; colTCCPredict.ItemsSource = predictY3Data; colTCCPredict.ValueMemberPath = "PredictData"; colTCCPredict.XAxis = categoryDateAxis; colTCCPredict.YAxis = numericYAxis; colTCCPredict.Opacity = 0.5; colTCCPredict.Visibility = Visibility.Hidden; colTCCPredict.ToolTip = colTCC.ToolTip; colTCCPredict.Brush = new SolidColorBrush(Colors.Blue); this.CategoryChart.Series.Add(colTCCPredict); categoryDateAxis.ItemsSource = predictYData; colCorn.ItemsSource = predictY1Data; colRice.ItemsSource = predictY2Data; colGrain.ItemsSource = predictYData; colTCC.ItemsSource = predictY3Data; numericXAxis.MinimumValue = 1; numericXAxis.MaximumValue = predictYData.Count; double[] high = new double[8]; high[0] = getMax(predictYData); high[1] = getMax(predictY1Data); high[2] = getMax(predictY2Data); high[3] = getMax(predictY3Data); numericYAxis.MaximumValue = SelectData.getHigh(high) + 5; } catch (Exception e1) { MessageBox.Show(e1.Message); } labTitle.Content = "常温条件下当初始虫口密度为2头/kg时不同储存时间的储粮害虫米象种群数量预测情况"; wheatePeatsZongQunHeader.miaoShu.Document = convertToBox.convertStringToFlowDocument(model2.chartMiaoShu); }