加入參考System.Windows.Controls.DataVisualization.Toolkit
在開頭引用參考
<window xmlns:DVC="clr-namespace: System.Windows.Controls.DataVisualization.Charting; assembly=System.Windows.Controls.DataVisualization.Toolkit">
參考下圖程式
using System.Collections.Generic; using System.Windows.Controls.DataVisualization; using System.Windows.Controls.DataVisualization.Charting; //宣告變數 var listmed = new List>(); var listatten = new List >(); var listdelta = new List >(); var listtheta = new List >(); var listalpha1 = new List >(); var listalpha2 = new List >(); var listbeta1 = new List >(); var listbeta2 = new List >(); var listgamma1 = new List >(); var listgamma2 = new List >(); //圖表的數值 for (int i = 0; i < 180; i++) { listmed.Add(new KeyValuePair (int.Parse(cn.txt_meditation[i]), i + 1)); listatten.Add(new KeyValuePair (int.Parse(cn.txt_attention[i]), i + 1)); listdelta.Add(new KeyValuePair (int.Parse(cn.txt_delta[i]), i + 1)); listtheta.Add(new KeyValuePair (int.Parse(cn.txt_theta[i]), i + 1)); listalpha1.Add(new KeyValuePair (int.Parse(cn.txt_alpha1[i]), i + 1)); listalpha2.Add(new KeyValuePair (int.Parse(cn.txt_aloha2[i]), i + 1)); listbeta1.Add(new KeyValuePair (int.Parse(cn.txt_beta1[i]), i + 1)); listbeta2.Add(new KeyValuePair (int.Parse(cn.txt_beta2[i]), i + 1)); listgamma1.Add(new KeyValuePair (int.Parse(cn.txt_gamma1[i]), i + 1)); listgamma2.Add(new KeyValuePair (int.Parse(cn.txt_gamma2[i]), i + 1)); } //將數值顯示在圖表上 ((LineSeries)mcChart.Series[0]).ItemsSource = listmed; ((LineSeries)mcChartatten.Series[0]).ItemsSource = listatten; ((LineSeries)mcChartDelta.Series[0]).ItemsSource = listdelta; ((LineSeries)mcChartTheta.Series[0]).ItemsSource = listtheta; ((LineSeries)mcChartalpha1.Series[0]).ItemsSource = listalpha1; ((LineSeries)mcChartalpha2.Series[0]).ItemsSource = listalpha2; ((LineSeries)mcChartbeta1.Series[0]).ItemsSource = listbeta1; ((LineSeries)mcChartbeta2.Series[0]).ItemsSource = listbeta2; ((LineSeries)mcChartgamma1.Series[0]).ItemsSource = listgamma1; ((LineSeries)mcChartgamma2.Series[0]).ItemsSource = listgamma2;
程式範例操作步驟
選擇檔案
路徑G:\ExcelFigure\ExcelFigure\bin\Debug\brainwave\m1
點選加入的檔案
點選下拉式選單選擇想看的數值資料
結果呈現
沒有留言:
張貼留言