Click here to Skip to main content
13,737,037 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


14 bookmarked
Posted 15 Nov 2008
Licenced GPL3

Graph control

, 15 Nov 2008
Rate this:
Please Sign up or sign in to vote.
this controls allows to draw function graph.


There are many times when we need simple tool for draw function graph. And the best solution for this task is a control which include all logic for drawing with simple interface for loading data. So, one alternative of such control represens in this article.

Let's begin 

Inerface of this control is very simple. It's include properties for set bounds of drawing box and function to load data for build graphic:

public double MinX;
public double MaxX;
public double MinY;
public double MaxY;

public void AddObject(List<PointF> coords<pointf>, Color c, VisualizationType type); 

By the function AddObject we can load array of points which will draw with specified color c and can have one of three types visualization: 1) continous line 2) points 3) daggers. We can load many objects for draw at a time. When we finished loading of object we simple call function DrawGraph() and all our objects appear on the screen. For use this control you must add library to your solution and add control from toolBox on your form. Next code show how you can use this control for drawing a graph:  

        private double function (double x)
            double res = Math.Sin(x);
            return res;
        private void btnDraw_Click(object sender, EventArgs e)
            List<PointF> points = new List<PointF>();<pointf><pointf>
            for (double x = 0; x < 10; x += 0.1)
                points.Add(new PointF((float) x, (float) function(x)));
            ucGraphSolution1.AddObject(points, Color.Red,VisualizationType.DAGGERS);
</pointf> </pointf> 
Also you can enlarge scale by the mouse selection and decrease scale by the mouse double click. Good luck!


This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


About the Author

Slezko S.G.
Software Developer (Senior)
Russian Federation Russian Federation
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralCorrupt Download Pin
MoloneyPat15-Nov-08 13:10
memberMoloneyPat15-Nov-08 13:10 
I may be wrong but the zip file seems corrupt.
GeneralRe: Corrupt Download Pin
Slezko S.G.15-Nov-08 14:30
memberSlezko S.G.15-Nov-08 14:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180920.1 | Last Updated 15 Nov 2008
Article Copyright 2008 by Slezko S.G.
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid