Page 1 of 1

ColorLine sum left to it

Posted: Fri Dec 04, 2009 5:25 am
by 6923298
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.

Re: ColorLine sum left to it

Posted: Fri Dec 04, 2009 11:25 am
by narcis
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("#.####");
		}