Hi
Pls i need to plot a simple graph from a text file having the coordinate values .
i could not find anything to plot a graph in c#. Is there any graph function?
plotting graph in C# (x.y) pointsi want to plot a graph in x,y axis like excel in c#
Page 1 of 1
8 Replies - 64543 Views - Last Post: 28 September 2008 - 11:27 AM
Replies To: plotting graph in C# (x.y) points
#2
Re: plotting graph in C# (x.y) points
Posted 24 September 2008 - 03:16 PM
No graphing functions are built into the standard library. You will need to implement your own or use a third party plug-in.
#3
Re: plotting graph in C# (x.y) points
Posted 24 September 2008 - 03:54 PM
What kind of graph? A simple scatter graph?
This gives me an idea...
NEW PROJECT!
I don't think it would be too difficult to design some graphing stuff.
Thanks for the idea! I'll post up something when I'm got started.
This gives me an idea...
NEW PROJECT!
I don't think it would be too difficult to design some graphing stuff.
Thanks for the idea! I'll post up something when I'm got started.
#4
Re: plotting graph in C# (x.y) points
Posted 24 September 2008 - 04:15 PM
OK, Here's some basic code that will hopefully get you started.
It draws the x/y axis on to a bitmap in red, and then adds a point at (20,30)
It's messy, but it might get you started:
It draws the x/y axis on to a bitmap in red, and then adds a point at (20,30)
It's messy, but it might get you started:
public MainForm()
{
// just make the window big enough to fit this graph...
this.Width = 500;
this.Height = 350;
// add 5 so the bars fit properly
int x = 240; // the position of the X axis
int y = 0; // the position of the Y axis
Bitmap bmp = new Bitmap(360, 290);
Graphics g = Graphics.FromImage(bmp);
g.DrawLine (new Pen(Color.Red, 2), 5,5, 5,250);
g.DrawLine (new Pen(Color.Red, 2), 5,250, 300,250);
// let's draw a coordinate equivalent to (20,30) (20 up, 30 across)
g.DrawString("X", new Font("Calibri", 12), new SolidBrush(Color.Black), y+30,x-20);
PictureBox display = new PictureBox();
display.Width = 360;
display.Height = 290;
this.Controls.Add(display);
display.Image = bmp;
}
#5
Re: plotting graph in C# (x.y) points
Posted 25 September 2008 - 05:23 PM
hey quick question.. why use this.MemberVar? Why not just Form.MemberVar?
I see this all of the time, and I don't like it but there must be a purpose.
I see this all of the time, and I don't like it but there must be a purpose.
#6
Re: plotting graph in C# (x.y) points
Posted 25 September 2008 - 05:44 PM
The this keyword refers to the current instance of the class, in this case referring to the form that is being worked in. If you had a class, say named Employer then this would refer to the instance of the Employer class that is currently instantiated. Like
public Employer(string name, string address)
{
this.name = name;
this.address = address;
}
#7
Re: plotting graph in C# (x.y) points
Posted 25 September 2008 - 10:55 PM
PsychoCoder, on 25 Sep, 2008 - 05:44 PM, said:
The this keyword refers to the current instance of the class, in this case referring to the form that is being worked in. If you had a class, say named Employer then this would refer to the instance of the Employer class that is currently instantiated. Like
public Employer(string name, string address)
{
this.name = name;
this.address = address;
}
so this.name and this.address are actually member vars inside of of the class Employee. And the parameter names are name and address.
If my understanding is correct why not just use name = name and address = address (maybe have to change var names on one or the other depending on the scope)
what is the special purpose of this ?
#8
Re: plotting graph in C# (x.y) points
Posted 27 September 2008 - 09:50 PM
The answer, with regard to what PsychoCoder posted, is that this.name refers to a class-level variable, while "name" in that context is a local variable for that method. Of course, naming the method variables differently would have allowed you to simply use name and address as the class variables, but ... especially when your working on other people's projects, this isn't always an easy option.
Edit - perhaps to be a little more clear ... name, in the context of that method, has only 1 meaning - the parameter variable name. name = name will, in any context, be a tautology of sorts ... assigning a variable's value to itself doesn't accomplish anything.
Edit - perhaps to be a little more clear ... name, in the context of that method, has only 1 meaning - the parameter variable name. name = name will, in any context, be a tautology of sorts ... assigning a variable's value to itself doesn't accomplish anything.
This post has been edited by vertizor: 27 September 2008 - 10:06 PM
#9
Re: plotting graph in C# (x.y) points
Posted 28 September 2008 - 11:27 AM
vertizor, on 27 Sep, 2008 - 09:50 PM, said:
The answer, with regard to what PsychoCoder posted, is that this.name refers to a class-level variable, while "name" in that context is a local variable for that method. Of course, naming the method variables differently would have allowed you to simply use name and address as the class variables, but ... especially when your working on other people's projects, this isn't always an easy option.
Edit - perhaps to be a little more clear ... name, in the context of that method, has only 1 meaning - the parameter variable name. name = name will, in any context, be a tautology of sorts ... assigning a variable's value to itself doesn't accomplish anything.
Edit - perhaps to be a little more clear ... name, in the context of that method, has only 1 meaning - the parameter variable name. name = name will, in any context, be a tautology of sorts ... assigning a variable's value to itself doesn't accomplish anything.
Alright I get it now. Thank you
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote








|