Click here to Skip to main content
15,886,067 members
Articles / Multimedia / GDI+

A flexible charting library for .NET

Rate me:
Please Sign up or sign in to vote.
4.70/5 (1,112 votes)
6 Jun 200730 min read 8.9M   180.2K   2.1K  
Looking for a way to draw 2D line graphs with C#? Here's yet another charting class library with a high degree of configurability, that is also easy to use.
#pragma once


namespace graphtest
{
	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	using namespace ZedGraph;

	/// <summary> 
	/// Summary for Form1
	///
	/// WARNING: If you change the name of this class, you will need to change the 
	///          'Resource File Name' property for the managed resource compiler tool 
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public __gc class Form1 : public System::Windows::Forms::Form
	{	
	public:
		Form1(void)
		{
			InitializeComponent();
		}
  
	protected:
		void Dispose(Boolean disposing)
		{
			if (disposing && components)
			{
				components->Dispose();
			}
			__super::Dispose(disposing);
		}

	private: ZedGraph::ZedGraphControl *  z1;



	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container * components;

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->z1 = new ZedGraph::ZedGraphControl();
			this->SuspendLayout();
			// 
			// z1
			// 
			this->z1->Location = System::Drawing::Point(16, 32);
			this->z1->Name = S"z1";
			this->z1->Size = System::Drawing::Size(416, 240);
			this->z1->TabIndex = 2;
			// 
			// Form1
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
			this->ClientSize = System::Drawing::Size(456, 329);
			this->Controls->Add(this->z1);
			this->Name = S"Form1";
			this->Text = S"Form1";
			this->Load += new System::EventHandler(this, Form1_Load);
			this->ResumeLayout(false);

		}	

	private:
		System::Void Form1_Load(System::Object *  sender, System::EventArgs *  e)
		{
			z1->IsShowPointValues = true;
			z1->GraphPane->Title = "Test C++ Case";

			Double x[] = __gc new Double[100];
			Double y[] = __gc new Double[100];
			int		i;

			for ( i=0; i<100; i++ )
			{
				x[i] = (double) i / 100.0 * Math::PI * 2.0;
				y[i] = Math::Sin( x[i] );
			}

			z1->GraphPane->AddCurve( "Sine Wave", x, y, Color::Blue,
							ZedGraph::SymbolType::Diamond );
			z1->AxisChange();
			z1->Invalidate();
		}
	};
}


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
Engineer
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