private void AddNewSeries(XYDataSeries dataSeries) { AlgoChart.BeginUpdate(); AlgoChart.Data.Children.Add(dataSeries); UpdateData(); AlgoChart.EndUpdate(); }
/// <summary> /// 创建显示当前光谱数据 /// </summary> public void CreateCurrentChart(float[] currentData) { AlgoChart.BeginUpdate(); if (hadCurrent) { AlgoChart.Data.Children.Remove(currentDataSeries); } XYDataSeries dataSeries = new XYDataSeries { Label = "实时数据", ConnectionStrokeThickness = 1 }; double[] valueY = new double[currentData.Length]; double[] valueX = new double[currentData.Length]; for (int i = 0; i < currentData.Length; i++) { valueX[i] = i + 1; valueY[i] = currentData[i]; } dataSeries.XValuesSource = valueX; dataSeries.ValuesSource = valueY; currentDataSeries = dataSeries; currentDataSeries.ConnectionFill = new SolidColorBrush(Colors.Red); AlgoChart.Data.Children.Add(currentDataSeries); hadCurrent = true; UpdateData(); AlgoChart.EndUpdate(); }
/// <summary> /// 初始化参数 /// </summary> private void InitParam() { AlgoChart.BeginUpdate(); AlgoChart.ChartType = ChartType.Line; AlgoChart.View.AxisX.Title = XAxisTitle; AlgoChart.View.AxisY.Title = YAxisTitle; AlgoChart.View.AxisX.Min = 1; UpdateData(); AlgoChart.EndUpdate(); }
private void Button_Click(object sender, RoutedEventArgs e) { AlgoChart.BeginUpdate(); AlgoChart.View.AxisX.Scale = 1; AlgoChart.View.AxisX.Value = 0.5; AlgoChart.View.AxisY.Scale = 1; AlgoChart.View.AxisY.Value = 0.5; UpdateScrollbars(); AlgoChart.EndUpdate(); }
private void RemoveSeries(string index) { AlgoChart.BeginUpdate(); if (index != null) { AlgoChart.Data.Children.Remove(dataSeriesMap[index]); } else { dataSeriesMap.Clear(); AlgoChart.Data.Children.Clear(); } UpdateData(); AlgoChart.EndUpdate(); }
/// <summary> /// 解析光谱数据 /// </summary> /// <param name="vocsCollectData"></param> private void ParseVocsCollectData(List <string[]> vocsCollectData, out Dictionary <int, float[]> riDataMap) { riDataMap = new Dictionary <int, float[]>(); List <int> xList = new List <int>(); List <List <string> > yListCollect = new List <List <string> >(); if (vocsCollectData.Count > 0) { int lineNum = vocsCollectData[0].Length; //y轴集合 for (int i = 0; i < lineNum; i++) { yListCollect.Add(new List <string>()); } //x轴,从1递增;y轴 for (int i = 1; i < vocsCollectData.Count; i++) { xList.Add(i); for (int j = 0; j < lineNum; j++) { yListCollect[j].Add(vocsCollectData[i][j]); } } //赋值缓存数据 for (int i = 0; i < yListCollect.Count; i++) { string[] strArray = yListCollect[i].ToArray(); riDataMap.Add(i + 1, Array.ConvertAll(strArray, s => float.Parse(s))); } this.xList = xList; this.yListCollect = yListCollect; this.lineNum = lineNum; AlgoChart.BeginUpdate(); for (int i = 0; i < lineNum; i++) { AlgoChart.Data.Children.Add(SetDataSeries(i)); } UpdateData(); AlgoChart.EndUpdate(); } }