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
skiping dates in Axes.Bottom
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi M.ismail,
1. Adding labels you want to be displayed as text labels when populating your series:
2: Using custom labels:
You need to set DateTime increments as shown here. However, this will result on having a label for every date.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;
In that case I can think of two options: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.
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;
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 |
Instructions - How to post in this forum |
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;
}
}
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;
}
}