Click here to Skip to main content
15,886,014 members
Articles / Programming Languages / C#

High Speed, Feature Rich, and Easy-To-Use Graphs and Charts

Rate me:
Please Sign up or sign in to vote.
4.92/5 (75 votes)
29 Nov 20066 min read 223.6K   17K   263  
High speed graphs and charts that are also very easy to configure and use. As easy as inserting a simple chart in MS Excel!
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D;
using System.Diagnostics;
using System.Globalization;

namespace GraphComponents
{
	/// <summary>
	/// Summary description for Cursor.
	/// </summary>
	class Cursor : IGraphElement
	{		
		private Rectangle graphArea;
		private Channel channel;

		public Rectangle GraphArea
		{
			get { return graphArea;  }
			set { graphArea = value; }
		}

		public Cursor(Channel channel)
		{						
			this.channel = channel;
		}

		#region IGraphElement Members

		public void Draw(Graphics graphics)
		{
			// TODO:  Add Cursor.Draw implementation

			int halfGraphHeight = GraphArea.Height / 2;
			float range = channel.MaximumValue - channel.MinimumValue;
			
			int offsetInPixel = (int) ((float) (GraphArea.Height / range) * channel.CursorOffset);

			Point leftPoint = new Point ();
			leftPoint.X = GraphArea.Left;
			leftPoint.Y = GraphArea.Bottom - halfGraphHeight + offsetInPixel;
			
			Point rightPoint = new Point (GraphArea.Right, leftPoint.Y);

			graphics.DrawLine (new Pen (channel.ChannelColor), leftPoint, rightPoint);

		}

		#endregion

	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions