コード例 #1
0
ファイル: Plot.cs プロジェクト: sol-prog/GraphDemo2
        public Plot(Read rr, ComboBox xBox, ComboBox yBox, Chart chart)
        {
            int indX = xBox.SelectedIndex;
            int indY = yBox.SelectedIndex;
            float[,] data = rr.get_Data();
            int nLines = rr.get_nLines();
            int nColumns = rr.get_nColumns();
            string []header = rr.get_Header();

            chart.Series.Clear(); //ensure that the chart is empty
            chart.Series.Add("Series0");
            chart.Series[0].ChartType = SeriesChartType.Line;
            chart.ChartAreas[0].AxisX.LabelStyle.Format = "{F2}";
            chart.ChartAreas[0].AxisX.Title = header[indX];
            chart.ChartAreas[0].AxisY.Title = header[indY];

            float x_grids = 6;
            float[] ext = get_Extrema(data, nLines, nColumns, indX);
            chart.ChartAreas[0].AxisX.MajorGrid.Interval = (ext[1] - ext[0]) / x_grids;
            chart.ChartAreas[0].AxisX.LabelStyle.Interval = (ext[1] - ext[0]) / x_grids;
            chart.ChartAreas[0].AxisX.MajorTickMark.Interval = (ext[1] - ext[0]) / x_grids;

            chart.Legends.Clear();
            for (int j = 0; j < nLines; j++)
            {
                chart.Series[0].Points.AddXY(data[j, indX], data[j, indY]);
            }
        }
コード例 #2
0
ファイル: Plot.cs プロジェクト: amal-roshan/GraphDemo1
        public Plot(Read rr, ComboBox xBox, ComboBox yBox, Chart chart)
        {
            int indX = xBox.SelectedIndex;
            int indY = yBox.SelectedIndex;
            float[,] data = rr.get_Data();
            int nLines = rr.get_nLines();

            chart.Series.Clear(); //ensure that the chart is empty
            chart.Series.Add("Series0");
            chart.Series[0].ChartType = SeriesChartType.Line;

            chart.Legends.Clear();
            for (int j = 0; j < nLines; j++)
            {
                chart.Series[0].Points.AddXY(data[j, indX], data[j, indY]);
            }
        }
コード例 #3
0
ファイル: GraphDemo.cs プロジェクト: amal-roshan/GraphDemo1
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Stream myStream = null;
            OpenFileDialog ff = new OpenFileDialog();

            ff.InitialDirectory = "c:\\";
            ff.Filter = "csv files (*.csv)|*.csv|All files (*.*)|*.*";
            ff.FilterIndex = 1;
            ff.RestoreDirectory = true;

            if (ff.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((myStream = ff.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            rr = null;
                            rr = new Read(myStream);
                            string[] header = rr.get_Header();
                            List<string> lX = new List<string>();
                            List<string> lY = new List<string>();
                            for (int i = 0; i < header.Length; i++)
                            {
                                lX.Add(header[i]); lY.Add(header[i]);
                            }
                            //Populate the ComboBoxes
                            xBox.DataSource = lX;
                            yBox.DataSource = lY;
                            // Close the stream
                            myStream.Close();
                        }
                    }
                }
                catch (Exception err)
                {
                    //Inform the user if we can't read the file
                    MessageBox.Show(err.Message);
                }
            }
        }