private void Window_Loaded(object sender, RoutedEventArgs e) { this.Title = tbTitle.Text = standardInfo.Stand_Name + "的平均曲线"; XDocument xdoc; List <List <XElement> > oddList = new List <List <XElement> >(); List <List <XElement> > evenList = new List <List <XElement> >(); foreach (Model.TestInfoModel model in modelList) { string xmlFileName = Model.AppPath.RootPath + "\\AppData\\XmlData\\" + model.DataFileName; xdoc = XDocument.Load(xmlFileName); XElement oddAvgEle = xdoc.Descendants("oddavg").ElementAt(0); XElement evenAvgEle = xdoc.Descendants("evenavg").ElementAt(0); List <XElement> list1 = new List <XElement>(); List <XElement> list2 = new List <XElement>(); foreach (XElement xe in oddAvgEle.Elements()) { list1.Add(xe); } foreach (XElement xe in evenAvgEle.Elements()) { list2.Add(xe); } oddList.Add(list1); evenList.Add(list2); } List <List <double> > oddValueList = ComputeAvgCurve.Compute(oddList); List <List <double> > evenValueList = ComputeAvgCurve.Compute(evenList); List <double> oddAvgValueList = ComputeAvgCurve.ComputeAvg(oddValueList); List <double> evenAvgValueList = ComputeAvgCurve.ComputeAvg(evenValueList); AddSeries(chart1, oddAvgValueList, true, "动作1");//平均曲线 foreach (List <double> list in oddValueList) { AddSeries(chart1, list, false, ""); } AddSeries(chart2, evenAvgValueList, true, "动作2"); foreach (List <double> list in evenValueList) { AddSeries(chart2, list, false, ""); } }
private void MergeAndAddDS(List <List <XElement> > standList, List <List <XElement> > list, Chart chart) { //合并标准和选择的信息 List <List <XElement> > allList = new List <List <XElement> >(); allList.AddRange(standList); allList.AddRange(list); if (allList.Count > 0) { //把所有曲线计算成相同长度 List <List <double> > allValueList = ComputeAvgCurve.Compute(allList); List <List <double> > standValueList = new List <List <double> >(); List <List <double> > checkedValueList = new List <List <double> >();//选择的测试信息的点列表 //取出标准信息的数据,并创建选择的测试信息的曲线 for (int i = 0; i < allValueList.Count; i++) { if ((i + 1) <= standList.Count) { standValueList.Add(allValueList[i]); } else { checkedValueList.Add(allValueList[i]); Model.TestInfoModel mo = TestInfoModelList[i - standList.Count]; if (mo.IsChecked == true) { string leText = string.Format("{0}.{1}", mo.Index, mo.Ath_Name); chart.Series.Add(CreateSeries(allValueList[i], leText));//补全写入legendtest } } } //添加选择的信息的平均曲线 List <double> checkedInfoAvgValueList = ComputeAvgCurve.ComputeAvg(checkedValueList); DataSeries avgds = CreateSeries(checkedInfoAvgValueList, "平均曲线"); avgds.Color = avgBrush; chart.Series.Add(avgds); //添加标准曲线 if (standValueList.Count > 0) { List <double> avgValueList = ComputeAvgCurve.ComputeAvg(standValueList); DataSeries standds = CreateSeries(avgValueList, stand.SelectedItem.Stand_Name); standds.Color = standBrush; chart.Series.Add(standds); } } }