Page 1 of 1

skiping dates in Axes.Bottom

Posted: Fri Jun 20, 2008 9:06 am
by 13048237
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

Posted: Fri Jun 20, 2008 9:32 am
by narcis
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());
			}

Posted: Fri Jun 20, 2008 12:05 pm
by 13048237
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;
}
}