My Chart is Clipped Slightly

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

My Chart is Clipped Slightly

Post by Dave » Wed Jan 06, 2010 2:29 pm

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);

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

Re: My Chart is Clipped Slightly

Post by Narcís » Thu Jan 07, 2010 3:00 pm

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.
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

Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Re: My Chart is Clipped Slightly

Post by Dave » Fri Jan 08, 2010 10:29 am

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);

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

Re: My Chart is Clipped Slightly

Post by Narcís » Fri Jan 08, 2010 3:03 pm

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!
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

Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Re: My Chart is Clipped Slightly

Post by Dave » Mon Jan 11, 2010 10:13 am

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.

Post Reply