Page 1 of 1
Automatic axis issue
Posted: Tue Apr 10, 2007 2:51 pm
by 9787981
Hello.
When I configure an axis to be automatic, and the maximum and minimum values that comes in are say in the range of 23 to 78, then the axis will be scaled from 23 to 78. What we need is for the scale to be increased a littlebeyond the actual trace values, eg., 10 to 90, so that the upper and lower values of the trace are a little more clear.
Is this is possible using the Steema Teechart?
thanks,
Ben.
Posted: Tue Apr 10, 2007 3:10 pm
by narcis
Hi Ben,
You have 2 options here:
1. Use axes SetMinMax method, for example:
Code: Select all
tChart1.Axes.Bottom.SetMinMax(tChart1[0].MinXValue() - 10, tChart1[0].MinXValue() + 10);
or:
Code: Select all
tChart1.Axes.Bottom.SetMinMax(tChart1.Axes.Bottom.Minimum - 10, tChart1.Axes.Bottom.Maximum + 10);
2. Use axes offset properties, for example:
Code: Select all
tChart1.Axes.Bottom.MinimumOffset = 10;
tChart1.Axes.Bottom.MaximumOffset = 10;
Posted: Tue Apr 10, 2007 3:24 pm
by 9794096
Is it possible at all to set the offset properties as a percentage of the range displayed on the axis itself?
I would prefer not to have to re-calc this every single time we plot something.
The reason I ask is that some of the plots we generate have a Y axis range of 0 to 1200 while others have a range of -0.1 to +0.1.
Obviously, setting an offset of 10 for the axis would not be appropriate in both of these cases but setting it as 10% might be better.
If we have to do the calc of that offset ourselves, where would you suggest doing that so that any time an item is added to a particular axis (left, right or custom or even the bottom [X] axis for that matter) we properly re-calc those offset values?
Posted: Wed Apr 11, 2007 5:02 pm
by 9787981
Hi Narcís,
This all sounds very logical, but when I tried using the option that sets the MinimumOffset and MaximumOffset properties for my custom Y-axis (this option is the best fit for my use case), it doesn't have any effect. Note, I only enforce this when autoscaling (i.e. the automatic property) is set for the Y-axis (left).
Is there something else I might be doing to my Y-axis that may be disabling the use of the MinimumOffset and MaximumOffset properties?
this is how I'm creating my axis:
Code: Select all
this.dnaAxis = new Steema.TeeChart.Axis(false, false, tChart.Chart);
if (dnaAxis != null)
{
tChart.Axes.Custom.Add(this.dnaAxis);
}
thanks,
Ben.
Posted: Thu Apr 12, 2007 7:41 am
by narcis
Hi Ben,
Not that I can think of. Could you please send us a simple example project we can run "as-is" to reproduce the problem here?
You can either post your files at news://
www.steema.net/steema.public.attachments newsgroup or at our
upload page.
Thanks in advance.
Posted: Fri Apr 13, 2007 3:16 am
by 9787981
Hey Narcís,
The issue was a coding error (race condition) on my part. It seems to be working now...
Regards,
Ben.
Posted: Fri Apr 13, 2007 4:12 pm
by 9787981
Hi Narcís,
Is it possible to essentially configure an automatic y-axis, such that the MaximumOffset/MinimumOffset values (or some other Axis property) are set to force the axis to draw one extra labelled tick at the top and bottom.
Perhaps there is some calculation that can be done from which the MaximumOffset/MinimumOffset values can be generated to facilitate this requirement.
Right now I'm calculating the MaximumOffset/MinimumOffset values as 3% of the tchart.Chart.Height property, which of course is not terribly accurate and doesn't always result in having the desired extra labelled tick drawn at the top and bottom of the automatic y-axis.
Regards,
Ben.
Posted: Mon Apr 16, 2007 7:34 am
by narcis
Hi Ben,
No, I can't think of any way to do this automatically. However, to improve what you are doing you'd better use ChartRect's height or axis's size as shown in the code below. Those properties have the exact value you are looking for and are different from chart's height.
Code: Select all
private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
label1.Text = tChart1.Chart.Height.ToString();
Rectangle Rect = tChart1.Chart.ChartRect;
label2.Text = Rect.Height.ToString();
int Height = tChart1.Chart.Axes.Left.IAxisSize;
label3.Text = Height.ToString();
}