i have a problem here with the maximum number of points. i am currently working on a project that has 4000 x and y points and the problem is when i tried to place all the points in the array list and try to plot it the whole graph collapses, and i only see striped lines on the x and y axis.
My question is does this program can accept points that are greater than 1000? thanks
Thanks for the simple and interactive post on graphs.
I was able to build the project from the sources you have provided but while dragging the graph.dll on another windows form generated following error.
"Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"
I was trying to use the same method for plotting somewhere about 1000 data points and the graph took over 250MB RAM and 80 CPU cycles.
Could you suggest how I could optimize its performance? The fact that paint gets called on every slight action on / over the form, troubles and causes the issue.
I am trying to implement the same logic using VB.Net code (educational purposes), however I could not understand the implementation of the following part. Is points an array? Is it redimensioned automatically in the for loop?
void DrawLineGraph(Graphics g)
Pen p = new Pen(graphColor);
Point start = (Point)Points;
prev = FindLocationOnGraph(start);
for(int i=1 ; i < Points.Count ;i++)
Point pt = (Point)Points[i];
current = FindLocationOnGraph(pt);
Brush b = new SolidBrush(textColor);
Font f = new Font(Font.FontFamily,Font.Size);
string title = "(" + pt.X + "," + pt.Y + ")"; if(prev.Y > current.Y)
g.DrawString(title,f,b,current.X - 25,
current.Y - 15);
current.X - 25, current.Y + 5);
title = "(" + start.X + "," + start.Y + ")";
g.DrawString(title,f,b,prev.X - 10, prev.Y - 15);
prev = current;
By the way, I do not know any C#, I'm trying to make sense out of what I know from learning Visual Basic.
When I reduce the dialog size, a portion of the graph control gets cut. Is there a way I can enable scrolling for the control (only for the control not the dialog box) or can you recommend any other control in codeproject which does scrolling.
I tried different ways of solving this problem but am stuck. I logically feel that if the form is being resized then the form should provide the scrolling and not the graph control. However, if you want to enable scrolling in graph control, you can set the minimum size of the graph by defualt and if the parent form add an instance of this control with a size lesser that the one you have defined , then it will draw the scrollbars for the graph control and not the form.
The code for the form looks like this :
Think about this, if the form is made very small, whats the point of having scroll bars to appear on the graph. Wouldnt you rather have them appear on the form , so you can scroll to diffrent controls over the form ???
Along with above code you can also set the following property:
AutoScrollMinSize = new Size(300,300);
This will enusre that scroll bars appear if the size of the form/control is made smaller than 300,300.
Although this is not exactly what you wanted, I hope this helps a little bit.
Thanks Mike! I have learnt so much about C# from this site than what I did from reading C# books.And I want others to learn C# and develop their skills just as I did, and this is my contribuition toward that!!! And yeah, the Graph control kicks ass...I am doing some studying on building a similar control for ASP.NET but havent figured out how to do the rendering yet.Lets see how it goes.
Have fun coding! C# rocks!!
I just finished building my WebControl and was going to post it but found out that there are already many other graph/chart controls submitted on Asp.NEt side of the site. So I am not sure whether I should post one more! I am currently drawing the graph as a bitmap and storing it on the harddrive and displaying the image in the browser. But I was reading one of these articles on the site where the dud uses ImageStreaming. I looked at his code but didnt understand what he was exactly doing.Is there a way I can write the created bitmap directly to the output stream ??How do I do it ??? And how will it fit into the "img src = filename" tag ???