Page 1 of 1

My Chart is Clipped Slightly

Posted: Wed Jan 06, 2010 2:29 pm
by 13050364
Hi

Ive a slight problem when displaying my line on a chart. Im developing in C# and a code outline is shown below.
What is happening is that some of the line is not visible and I have to right-click and drag to make the missing part visible.
I thought that TeeChart would automatically scale everything such that the whole line was visible. Most of the time it appears as though the part that is
not visible is a horizontal part that lies exactly on the Y=0 and/or y=maxm part of the chart. Can I fix this?


===============

Line myLine;
myLine = new Line(myChart.Chart);
myLine.Color = Color.Yellow;

double[] xcoord= new double[2500];
double[] ycoord = new double[2500];

int i = 0;
while(i < 2500)
{
xcoord = whatever;
ycoord = whatever;
}

myLine.Clear();
myLine.Add(xcoord, ycoord);

Re: My Chart is Clipped Slightly

Posted: Thu Jan 07, 2010 3:00 pm
by narcis
Hi Dave,
I thought that TeeChart would automatically scale everything such that the whole line was visible.
Yes, this is default behaviour and works fine for me here using this code:

Code: Select all

			Steema.TeeChart.Styles.Line myLine = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			myLine.Color = Color.Yellow;

			double[] xcoord = new double[2500];
			double[] ycoord = new double[2500];

			Random x = new Random();
			Random y = new Random();

			for (int i = 0; i < xcoord.Length; i++)
			{
				xcoord[i] = x.Next();
				ycoord[i] = y.Next();
			}

			myLine.Clear();
			myLine.Add(xcoord, ycoord);
Most of the time it appears as though the part that is not visible is a horizontal part that lies exactly on the Y=0 and/or y=maxm part of the chart. Can I fix this?
In that case you may need to use minimum and maximum axes offset, for example:

Code: Select all

			tChart1.Axes.Bottom.MinimumOffset = 50;
			tChart1.Axes.Bottom.MaximumOffset = 50;

			tChart1.Axes.Left.MinimumOffset = 50;
			tChart1.Axes.Left.MaximumOffset = 50;
If this doesn't help please attach a simple example project we can run "as-is" or modify the code snippet above so that we can reproduce the problem here.

Thanks in advance.

Re: My Chart is Clipped Slightly

Posted: Fri Jan 08, 2010 10:29 am
by 13050364
Hi Narcis

Try out this code. The first horizontal part of the line where y=0 is not displayed. You have to right-click and drag up to see this part of the line.
The version we are using is 3.5.3371.26406


Steema.TeeChart.Styles.Line myLine = new Steema.TeeChart.Styles.Line(tChart1.Chart);
myLine.Color = Color.Yellow;

double[] xcoord = new double[250];
double[] ycoord = new double[250];

Random x = new Random();
Random y = new Random();

for (int i = 0; i < xcoord.Length; i++) {
xcoord = i;

if (i < 100)
ycoord = 0;
else
ycoord = y.Next();
}

myLine.Clear();
myLine.Color = Color.DarkRed;
myLine.Add(xcoord, ycoord);

Re: My Chart is Clipped Slightly

Posted: Fri Jan 08, 2010 3:03 pm
by narcis
Hi Dave,

Is your chart in 2D? The line is painted but is painted but is painted over (or below) the bottom axis line. There are 2 solutions to this:

1. Set custom left axis minimum, for example:

Code: Select all

			tChart1.Axes.Left.AutomaticMinimum = false;
			tChart1.Axes.Left.Minimum = -y.Next();
2. Use axis offset, for example:

Code: Select all

			tChart1.Axes.Left.MinimumOffset = 30;
This is not working though due to a bug (TF02014628) which has just been discussed here. So that you'll have to use offset like this for now:

Code: Select all

			tChart1.Axes.Left.SetMinMax(myLine.MinYValue(), myLine.MaxYValue());
			tChart1.Axes.Left.MinimumOffset = 30;
Hope this helps!

Re: My Chart is Clipped Slightly

Posted: Mon Jan 11, 2010 10:13 am
by 13050364
tChart1.Axes.Left.SetMinMax(myLine.MinYValue(), myLine.MaxYValue());
tChart1.Axes.Left.MinimumOffset = 30;


Narcis

The above code works perfectly. Thanks. I had the same problem at the top of the chart so added

tChart1.Axes.Left.MaximumOffset = 30;

which ensures the whole chart data is always visible.