Ejemplo n.º 1
0
        //Create a bar graph, add it to a parent form, fill in data
        public static Graph Create_Line_Graph(Rectangle location, string[][] data)
        {
            //First, create the control graph will be in
            GraphControl gc = new GraphControl();
            List<List<double>> newData = new List<List<double>>();

            //parse the 2d string array
            for (int i = 0; i < data.Length; i++)
            {
                newData.Add(new List<double>());
                for (int j = 0; j < data[i].Length; j++)
                {
                    double parsedDouble;
                    if (!Double.TryParse(data[i][j], out parsedDouble))
                        throw new ArgumentException("Invalid data in Cells");
                    newData[i].Add(parsedDouble);
                }
            }

            // now create graph with data
            Graph gr = new line_graph(newData);

            // location, size of graph in preview tab
            gc.Location = new Point(0, 0);
            gc.Size = new Size(450, 400);
            gc.SetGraph(gr);

            // open up a graph configuration window
            graphConfig gConf = new graphConfig(gr, gc);
            gConf.ShowDialog();

            // if press ok then put graph control in main form
            if (gConf.DialogResult == DialogResult.OK)
            {
                // put in the graph with the changes
                gr = gConf.gr;
                // create new control to reset any parameters
                gc = new GraphControl();
                // location and size of control inside main form
                gc.Location = new Point(location.X, location.Y);
                gc.Size = location.Size;
                gc.SetGraph(gr);
                gr.InitFonts();
                gr.InitLabels();

                Controller.Instance.MainForm.WorksheetsTabControl.SelectedTab.Controls.Add(gc);
                gc.BringToFront();

                return gr;
            }

            return null;
        }
Ejemplo n.º 2
0
        //Create a bar graph, add it to a parent form, fill in data
        public static Graph Create_Line_Graph(Form parent, Rectangle location, string[][] data)
        {
            //First, make a bar graph and add the data
            GraphControl gc = new GraphControl();
            List<List<double>> newData = new List<List<double>>();

            foreach (string[] strarray in data)  //Fill in and parse incoming cell data
            {
                newData.Add(new List<double>());
                foreach (string s in strarray)
                {
                    double parsedDouble;
                    if (!Double.TryParse(s, out parsedDouble))
                        throw new ArgumentException("Invalid data in Cells");
                    newData[0].Add(parsedDouble);
                }
            }

            Graph gr = new line_graph(newData);

            gc.Location = new Point(0, 0);  //gc.loc is a point, not rect
            gc.Size = new Size(450, 400);
            gc.SetGraph(gr);

            graphConfig gConf = new graphConfig(gr, gc);
            gConf.ShowDialog();

            if (gConf.DialogResult == DialogResult.OK)
            {
                gc = new GraphControl();
                gc.Location = new Point(location.X, location.Y);  //gc.loc is a point, not rect
                gc.Size = location.Size;
                gc.SetGraph(gr);
                gr.InitFonts();
                gr.InitLabels();

                parent.Controls.Add(gc);
            }

            parent.Controls.Add(gc);

            return gr;
        }
Ejemplo n.º 3
0
 // this is to make a new graph object equal to this one.
 public override Graph cloneGraph()
 {
     line_graph gr = new line_graph(data);
     gr.draw_title = draw_title;
     gr.TitleString = TitleString;
     gr.LegendOn = LegendOn;
     gr.draw_xLabel = draw_xLabel;
     gr.XLabelString = XLabelString;
     gr.draw_yLabel = draw_yLabel;
     gr.YLabelString = YLabelString;
     gr.nHorzLines = nHorzLines;
     gr.nVertLines = nVertLines;
     gr.maxXVal = maxXVal;
     gr.minXVal = minXVal;
     gr.maxYVal = maxYVal;
     gr.minYVal = minYVal;
     return gr;
 }