Exemple #1
0
        public static graph graph1, graph2, graph3, graph4; //They are static because we need to access them from other forms

        public Form1()
        {
            InitializeComponent();
            graph1 = new graph("chart1"); //Initializing graph objects
            graph2 = new graph("chart2");
            graph3 = new graph("chart3");
            graph4 = new graph("chart4");
            loadFromFileIntoObject(graph1); //Calling function that is reading values from the file and it's storing them in object that we are passing here
            loadFromFileIntoObject(graph2);
            loadFromFileIntoObject(graph3);
            loadFromFileIntoObject(graph4);
        }
Exemple #2
0
        public void loadChart()
        {
            graph r = Form1.graph4;

            foreach (series s in r.seriesList)
            {
                chart1.Series.Add(s.name);
                int y = 0;
                foreach (string ss in s.xPoints)
                {
                    chart1.Series[chart1.Series.Count - 1].Points.AddXY(ss, s.yPoints[y]);
                    y++;
                }
            }
            chart1.Titles.Add(r.title);
            chart1.ChartAreas["main"].AxisX.Interval = 1;
            chart1.ChartAreas["main"].AxisX.Title    = r.xAxis;
            chart1.ChartAreas["main"].AxisY.Title    = r.yAxis;
        }
Exemple #3
0
        public void loadChart()
        {
            graph r = Form1.graph1;                                                              //This is reference copy to save us from calling it by it's whole name & reference

            foreach (series s in r.seriesList)                                                   //Going through every series in our object
            {
                lineChart.Series.Add(s.name);                                                    //Add new series to our chart
                lineChart.Series[lineChart.Series.Count - 1].ChartType = SeriesChartType.Line;   //Change type of our newly added series
                int y = 0;                                                                       //This is counting how many times we passed through foreach loop
                foreach (string ss in s.xPoints)                                                 //Going through each xPoint
                {
                    lineChart.Series[lineChart.Series.Count - 1].Points.AddXY(ss, s.yPoints[y]); //Adding new point to our newly added series
                    y++;
                }
            }
            lineChart.Titles.Add(r.title);                         //Title of a chart
            lineChart.ChartAreas["main"].AxisX.Interval = 1;       //We set interval to 1 so we don't miss displaying every piece of data in our file
            lineChart.ChartAreas["main"].AxisX.Title    = r.xAxis; //Changing xAxis name (description)
            lineChart.ChartAreas["main"].AxisY.Title    = r.yAxis; //Editing name (description) for yAxis
        }
Exemple #4
0
        public void loadChart()
        {
            graph r = Form1.graph2;

            foreach (series s in r.seriesList)
            {
                areaChart.Series.Add(s.name);
                areaChart.Series[areaChart.Series.Count - 1].ChartType = SeriesChartType.SplineArea;
                int y = 0;
                foreach (string ss in s.xPoints)
                {
                    areaChart.Series[areaChart.Series.Count - 1].Points.AddXY(ss, s.yPoints[y]);
                    y++;
                }
            }
            areaChart.Titles.Add(r.title);
            areaChart.ChartAreas["main"].AxisX.Interval = 1;
            areaChart.ChartAreas["main"].AxisX.Title    = r.xAxis;
            areaChart.ChartAreas["main"].AxisY.Title    = r.yAxis;
        }
Exemple #5
0
        public void loadChart()
        {
            graph r = Form1.graph3;

            foreach (series s in r.seriesList)
            {
                pieChart.Series.Add(s.name);
                pieChart.Series[pieChart.Series.Count - 1].ChartType  = SeriesChartType.Pie;
                pieChart.Series[pieChart.Series.Count - 1].Label      = "#PERCENT";
                pieChart.Series[pieChart.Series.Count - 1].LegendText = "#VALX";
                int y = 0;
                foreach (string ss in s.xPoints)
                {
                    pieChart.Series[pieChart.Series.Count - 1].Points.AddXY(ss, s.yPoints[y]);
                    y++;
                }
            }
            pieChart.Titles.Add(r.title);
            pieChart.ChartAreas["main"].AxisX.Interval = 1;
            pieChart.ChartAreas["main"].AxisX.Title    = r.xAxis;
            pieChart.ChartAreas["main"].AxisY.Title    = r.yAxis;
        }
Exemple #6
0
        public void loadFromFileIntoObject(graph o)
        {
            int    counter = 0;    //Counter for lines
            string line;           //Current line text
            int    emptyLines = 0; //Passed empty lines
            int    currentY   = 0; //Current Y value index

            // Read the file and display it line by line.
            System.IO.StreamReader file =
                new System.IO.StreamReader(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName, "ChartData", o.path, "data.txt"));
            while ((line = file.ReadLine()) != null)
            {
                if (counter == 0)   //First line of doc is title
                {
                    o.title = line; //Setting title of our chart
                    counter++;      //Adding counter for lines read before executing continue
                    continue;
                }
                else if (counter == 1) //Second line is name of x axis (if it does not exist type "." in file)
                {
                    o.xAxis = line;    //Editing name (description) for xAxis
                    counter++;
                    continue;
                }
                else if (counter == 2) //Third line is name of y axis (if it does not exist type "." in file)
                {
                    o.yAxis = line;    //Editing name (description) for zAxis
                    counter++;
                    continue;
                }
                if (line == "")         //Checking if line is empty
                {
                    if (emptyLines > 1) //If we are parsing Y values blocks and it's empty line, reset index counter
                    {
                        currentY = 0;
                    }
                    counter++;
                    emptyLines++;
                    continue;
                }
                if (emptyLines == 0) //Parsing series
                {
                    series n = new series();
                    n.name = line;
                    o.seriesList.Add(n);
                }
                else if (emptyLines == 1) //Parsing Y values
                {
                    foreach (series s in o.seriesList)
                    {
                        s.xPoints.Add(line); //Adding our line name to xPoints list
                    }
                }
                else                                                            //Parsing X values
                {
                    o.seriesList[currentY].yPoints.Add(Convert.ToDouble(line)); //Converting value to double before adding it to the yPoints list
                    currentY++;
                }
                counter++;
            }
            file.Close();
        }