skiping dates in Axes.Bottom

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
tjip
Newbie
Newbie
Posts: 4
Joined: Wed Feb 06, 2008 12:00 am

skiping dates in Axes.Bottom

Post by tjip » Fri Jun 20, 2008 9:06 am

Hi,

I am trying to display a graph where the bottom axes are dates and they increase by 1 day.

teeChartControl.Axes.Bottom.Labels.DateTimeFormat = "dd-MM-yy";
teeChartControl.Axes.Bottom.Increment = 1.0;

The problem here is when i give as dates e.g. 01-01-2008 and 03-01-2008

i get to see en empty 02-01-2008 label.

how can i fix that? so basicly i want to skip the dates without a value.

Regards,

M.ismail

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

Post by Narcís » Fri Jun 20, 2008 9:32 am

Hi M.ismail,
I am trying to display a graph where the bottom axes are dates and they increase by 1 day.

teeChartControl.Axes.Bottom.Labels.DateTimeFormat = "dd-MM-yy";
teeChartControl.Axes.Bottom.Increment = 1.0;
You need to set DateTime increments as shown here. However, this will result on having a label for every date.
The problem here is when i give as dates e.g. 01-01-2008 and 03-01-2008

i get to see en empty 02-01-2008 label.

how can i fix that? so basicly i want to skip the dates without a value.
In that case I can think of two options:

1. Adding labels you want to be displayed as text labels when populating your series:

Code: Select all

			Steema.TeeChart.Styles.FastLine fastLine1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
			
			fastLine1.XValues.DateTime = true;

			Random y = new Random();
			fastLine1.Add(DateTime.Parse("01/07/2008"), y.Next(), "01/07/2008");
			fastLine1.Add(DateTime.Parse("03/07/2008"), y.Next(), "03/07/2008");
			fastLine1.Add(DateTime.Parse("05/07/2008"), y.Next(), "05/07/2008");
			fastLine1.Add(DateTime.Parse("07/07/2008"), y.Next(), "06/07/2008");

			tChart1.Axes.Bottom.Labels.Style = Steema.TeeChart.AxisLabelStyle.Text;
2: Using custom labels:

Code: Select all

			Steema.TeeChart.Styles.FastLine fastLine1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
			
			fastLine1.XValues.DateTime = true;

			Random y = new Random();

			fastLine1.Add(DateTime.Parse("01/07/2008"), y.Next());
			fastLine1.Add(DateTime.Parse("03/07/2008"), y.Next());
			fastLine1.Add(DateTime.Parse("05/07/2008"), y.Next());
			fastLine1.Add(DateTime.Parse("07/07/2008"), y.Next());

			tChart1.Axes.Bottom.Labels.Items.Clear();

			for (int i = 0; i < fastLine1.Count; i++)
			{
				double xval = fastLine1.XValues[i];
				tChart1.Axes.Bottom.Labels.Items.Add(xval, DateTime.FromOADate(xval).ToString());
			}
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

tjip
Newbie
Newbie
Posts: 4
Joined: Wed Feb 06, 2008 12:00 am

Post by tjip » Fri Jun 20, 2008 12:05 pm

thx for your replay.

since i had no time to wait i tried that and it worked:

teeChartControl.Axes.Bottom.GetAxisDrawLabel += new GetAxisDrawLabelEventHandler(Bottom_GetAxisDrawLabel);



void Bottom_GetAxisDrawLabel(object sender, GetAxisDrawLabelEventArgs e)
{
string draw = e.Text;


if ( list.Contains(draw))
{
e.DrawLabel = true;
}
else
{
e.DrawLabel = false;
}
}

Post Reply