Page 1 of 1

How to: Add vertical & horizontal Median lines on scatte

Posted: Wed Dec 13, 2006 3:53 pm
by 9524907
Hello,
is it possible to have a scatter chart with a vertical & horizontal median lines? If so, can someone point us in the right direction?

The scatter is to determine how a person is performing against their peers.

Thanks!

Posted: Wed Dec 13, 2006 3:57 pm
by narcis
Hi ASM,

Yes, this can be done as shown in the What's New?\Welcome !\New Functions\Median Function example. This example can be found at the features demo available at TeeChart's program group.

Posted: Wed Dec 13, 2006 3:59 pm
by 9524907
NarcĂ­s
Thanks for the quick response!

Chris
ASM Research

Posted: Wed Dec 13, 2006 6:57 pm
by 9524907
we can get the horizontal median to display but how do we also display a vertical median to create a "crosshair".

Thanks!

Posted: Thu Dec 14, 2006 9:41 am
by narcis
Hi ASM,

Vertical median function doesn't exist. However, you can easily implement that using an horizontal line series like this:

Code: Select all

		private void Form1_Load(object sender, EventArgs e)
		{
			tChart1.Aspect.View3D = false;
			line1.FillSampleValues();

			Steema.TeeChart.Styles.HorizLine vertMedian1 = new Steema.TeeChart.Styles.HorizLine(tChart1.Chart);

			double xMedian;

			if (line1.Count % 2 != 0)
				xMedian = line1.XValues[(line1.Count / 2) + 1];
			else
				xMedian = (line1.XValues[(line1.Count / 2)] + line1.XValues[(line1.Count / 2) + 1]) / 2;

			vertMedian1.Add(xMedian, line1.YValues.Minimum);
			vertMedian1.Add(xMedian, line1.YValues.Maximum);
		}

Posted: Thu Dec 14, 2006 12:57 pm
by narcis
Hi ASM,

Sorry but I noticed my initial algorithm was wrong, should be like this:

Code: Select all

		private void Form1_Load(object sender, EventArgs e)
		{
			tChart1.Aspect.View3D = false;
			line1.FillSampleValues();

			Steema.TeeChart.Styles.HorizLine vertMedian1 = new Steema.TeeChart.Styles.HorizLine(tChart1.Chart);

			double xMedian;

			if (line1.Count % 2 == 0)
				xMedian = line1.XValues[(line1.Count / 2)];
			else
				xMedian = (line1.XValues[(line1.Count / 2)] + line1.XValues[(line1.Count / 2) + 1]) / 2;

			vertMedian1.Add(xMedian, line1.YValues.Minimum);
			vertMedian1.Add(xMedian, line1.YValues.Maximum);
		}

scatter chart line1 object

Posted: Fri Dec 15, 2006 8:55 pm
by 9524907
What sort of object is line1? Would you send the fully qualified objects to draw a line?

Posted: Fri Dec 15, 2006 9:57 pm
by 9524907
Also, can you post the VB.NET equivalent of the algorithm you gave? I am having trouble converting some of your declarations. For example, I can't do:

Dim vertMedian1 = As New Steema.TeeChart.Styles.HorizLine

Posted: Mon Dec 18, 2006 8:39 am
by narcis
Hi ASM,

I have converted C# code to VB.NET code using Kamal Patel's conversor. You may also be interested in knowing of Carlos Aguilar's conversor.

Code: Select all

      Private  Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
         tChart1.Aspect.View3D = False
         line1.FillSampleValues()
 
         Dim vertMedian1 As Steema.TeeChart.Styles.HorizLine =  New Steema.TeeChart.Styles.HorizLine(tChart1.Chart) 
 
         Dim xMedian As Double
 
         If line1.Count % 2 = 0 Then
            xMedian = line1.XValues((line1.Count / 2))
         Else 
            xMedian = (line1.XValues((line1.Count / 2)) + line1.XValues((line1.Count / 2) + 1)) / 2
         End If
 
         vertMedian1.Add(xMedian, line1.YValues.Minimum)
         vertMedian1.Add(xMedian, line1.YValues.Maximum)
      End Sub
If the VB.NET code I posted doesn't work for you please let me know.