ColorLine sum left to it

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
pw
Newbie
Newbie
Posts: 57
Joined: Fri Nov 15, 2002 12:00 am

ColorLine sum left to it

Post by pw » Fri Dec 04, 2009 5:25 am

Hi,

I've setup a ColorLine with reference to the bottom axis. When the users drag the ColorLine, I would like to show the sum of Vertical Axis values for one of the line chart to the left of the ColorLine and also the Bottom Axis value.

Is it possible?

Thanks.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: ColorLine sum left to it

Post by Narcís » Fri Dec 04, 2009 11:25 am

Hi pw,

You can use ColorLine events for that, for example:

Code: Select all

	  public Form1()
	  {
	    InitializeComponent();
			InitializeChart();			
		}

		private Steema.TeeChart.Tools.ColorLine colorLine1;
		private Steema.TeeChart.Styles.Line line1;

		private void InitializeChart()
		{
			line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			line1.FillSampleValues();

			colorLine1 = new Steema.TeeChart.Tools.ColorLine(tChart1.Chart);
			colorLine1.Axis = tChart1.Axes.Bottom;
			colorLine1.DragLine += new EventHandler(colorLine1_DragLine);
			colorLine1.EndDragLine += new Steema.TeeChart.Tools.ColorLineToolOnDragEventHandler(colorLine1_EndDragLine);
		}

		void colorLine1_EndDragLine(object sender)
		{
			SumValues();
		}

		void colorLine1_DragLine(object sender, EventArgs e)
		{
			//SumValues();
		}

		private void SumValues()
		{
			double ySum = 0;

			for (int i = 0; i < line1.Count; i++)
			{
				if (line1.XValues[i] <= colorLine1.Value)
				{
					ySum = ySum + line1.YValues[i];
				}
				else
				{
					break;
				}

			}

			tChart1.Header.Text = "Y values sum: " + ySum.ToString() + "\n" +
														"ColorLine value: " + colorLine1.Value.ToString("#.####");
		}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply