Swapping Axis

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Mike Jones
Advanced
Posts: 192
Joined: Thu Feb 01, 2007 12:00 am
Contact:

Swapping Axis

Post by Mike Jones » Fri Apr 20, 2007 4:14 pm

Is there a way to swap axes with out removing a series rebuilding it and re-adding it? In other words, I would like to be able to do the equivalent below in a more efficient manner.

Is there a way to do it for a Steema.TeeChart.Styles.Surface?

For example:

Steema.TeeChart.Styles.Line series = new Steema.TeeChart.Styles.Line();
tChart1.Series.Add(series);
series.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending;
double[] x = new double[] { 10, 4, 8, 20, 18, 2, 6, 12, 16, 14};
double[] y = new double[] { 10, 25, 12.5, 5, 5.556, 50, 16.667, 8.333, 6.25, 7.1428};series.Add(x, y);
series.XValues.Sort();
series.YValues.Sort();

tChart1.Refresh();

.
.
.

// Now lets swap the x & y axis

tChart1.Series.Clear();
Steema.TeeChart.Styles.Line series = new Steema.TeeChart.Styles.Line();
tChart1.Series.Add(series);
series.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending;
double[] x = new double[] { 10, 4, 8, 20, 18, 2, 6, 12, 16, 14};
double[] y = new double[] { 10, 25, 12.5, 5, 5.556, 50, 16.667, 8.333, 6.25, 7.1428};series.Add(y, x); //NOTICE: swapped X & Y
series.XValues.Sort();
series.YValues.Sort();

tChart1.Refresh();

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Mon Apr 23, 2007 8:06 am

Hi Mikes

You can use the "3D Grid Transpose" tool, to do this in your surface series, as below code:

Code: Select all

 private void Form1_Load(object sender, EventArgs e)
        {
            surface1.FillSampleValues();
            Steema.TeeChart.Tools.GridTranspose gridTranspose1 = new Steema.TeeChart.Tools.GridTranspose(tChart1.Chart); 
            gridTranspose1.Series = surface1; 
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ((Steema.TeeChart.Tools.GridTranspose)tChart1.Tools[0]).Transpose(); 
        }
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

Mike Jones
Advanced
Posts: 192
Joined: Thu Feb 01, 2007 12:00 am
Contact:

follow up questions

Post by Mike Jones » Mon Apr 23, 2007 1:32 pm

You propose using a 3D grid, but what if I am using a Line series as my example shows?

Also it is very important to our design that we add points by passing in array of doubles. This is most efficient when we have thousands of points. How do you suggest we swap and X and Y axis in a Line series?

What effect will we encounter if X has a regular interval and Y does not after we swap the X and Y?

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

Post by Narcís » Tue Apr 24, 2007 8:21 am

Hi Mike,
You propose using a 3D grid, but what if I am using a Line series as my example shows?
I guess this was because you asked this:
Is there a way to do it for a Steema.TeeChart.Styles.Surface?
Also it is very important to our design that we add points by passing in array of doubles. This is most efficient when we have thousands of points. How do you suggest we swap and X and Y axis in a Line series?
What you already do seems fine to me as valuelists can not be assigned directly since they are read only. The only thing I would change is not removing and creating series everytime. I would do something like this:

Code: Select all

		private double[] x = new double[] { 10, 4, 8, 20, 18, 2, 6, 12, 16, 14 };
		private double[] y = new double[] { 10, 25, 12.5, 5, 5.556, 50, 16.667, 8.333, 6.25, 7.1428 };

		private void button1_Click(object sender, EventArgs e)
		{
			tChart1[0].Clear();
			Steema.TeeChart.Styles.ValueListOrder tmpOrder = tChart1[0].XValues.Order;
			tChart1[0].XValues.Order = tChart1[0].YValues.Order;
			tChart1[0].YValues.Order = tmpOrder;

			tChart1[0].Add(y, x);
		}		

		private void Form1_Load(object sender, EventArgs e)
		{
			tChart1.Series.Clear();

			Steema.TeeChart.Styles.Line series = new Steema.TeeChart.Styles.Line();
			tChart1.Series.Add(series);
			series.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending;
			series.Add(x, y);
		}
Also notice that we have implemented SeriesTransposeTool for TeeChart for .NET v3 Beta, which is available at the client download area. However, this tool doesn't behave as you request here.
What effect will we encounter if X has a regular interval and Y does not after we swap the X and Y?
Nothing should happen. Line series doesn't need to have regular intervals.
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