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();
Swapping Axis
-
- Advanced
- Posts: 192
- Joined: Thu Feb 01, 2007 12:00 am
- Contact:
Hi Mikes
You can use the "3D Grid Transpose" tool, to do this in your surface series, as below code:
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();
}
-
- Advanced
- Posts: 192
- Joined: Thu Feb 01, 2007 12:00 am
- Contact:
follow up questions
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?
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?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Mike,
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.
I guess this was because you asked this:You propose using a 3D grid, but what if I am using a Line series as my example shows?
Is there a way to do it for a Steema.TeeChart.Styles.Surface?
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: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?
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);
}
Nothing should happen. Line series doesn't need to have regular intervals.What effect will we encounter if X has a regular interval and Y does not after we swap the X and Y?
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |