Hi Teechart
Thought pass questions I have been able to set the labels so they do not overlap and my grid is set at one year.
TChartz.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(DateTimeSteps.OneYear)
I have a graph with 53 years of data and with a vertical line every year it is getting crowded. Is there a way to set the vertical grid to show every two years or five years.
Thanks
Timestep greater than a Year
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Hi Avatar,
You should be able to use the following:
You should be able to use the following:
Code: Select all
private Steema.TeeChart.Styles.Line line1;
private void InitializeChart()
{
line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
tChart1.Axes.Bottom.Labels.Angle = 90;
line1.XValues.DateTime = true;
DateTime today = DateTime.Today;
Random rnd = new Random();
for(int i=0; i < 50; ++i)
{
line1.Add(today, rnd.Next(100));
today = today.AddYears(1);
}
double fouryearincrement = 365 + 365 + 365 + 366;
tChart1.Axes.Bottom.Increment = fouryearincrement;
}
Thank you!
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
Hi Chris,
The grid changes with increment greater than a year but now there is another problem.
Originally (a year ago) I had a problem where ‘DateTimeFormat = "yyyy"’ would label the year and grid to the last day of the year. So Dec 31, 1961 would appear 1961 where in fact that grid line was the start of the next year and should be labeled 1962.
If I use: ’GetDateTimeStep(DateTimeSteps.OneYear)’ the grid and the Years line up with 1962 being the start of 1962
If I use:
Dim fouryearincrement as double = 365 + 365 + 365 + 366
tChart1.Axes.Bottom.Increment = fouryearincrement
I get a grid with 4 years of spacing but the label year is the end or the previous year not the start of the next year. So the grid and label that should say 1962 now says 1961.
The grid changes with increment greater than a year but now there is another problem.
Originally (a year ago) I had a problem where ‘DateTimeFormat = "yyyy"’ would label the year and grid to the last day of the year. So Dec 31, 1961 would appear 1961 where in fact that grid line was the start of the next year and should be labeled 1962.
If I use: ’GetDateTimeStep(DateTimeSteps.OneYear)’ the grid and the Years line up with 1962 being the start of 1962
If I use:
Dim fouryearincrement as double = 365 + 365 + 365 + 366
tChart1.Axes.Bottom.Increment = fouryearincrement
I get a grid with 4 years of spacing but the label year is the end or the previous year not the start of the next year. So the grid and label that should say 1962 now says 1961.
Hi Avatar,
Another option to resolve your problem could be using custom labels. You can modify the original code in the following way:
Another option to resolve your problem could be using custom labels. You can modify the original code in the following way:
Code: Select all
private Steema.TeeChart.Styles.Line line1;
private void InitializeChart()
{
line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
tChart1.Axes.Bottom.Labels.Angle = 90;
line1.XValues.DateTime = true;
DateTime today = DateTime.Today;
Random rnd = new Random();
for(int i=0; i < 50; ++i)
{
line1.Add(today, rnd.Next(100));
today = today.AddYears(1);
}
//Custom labels
for (int i=2005; i<2055; i++)
{
if ((i % 4)==0)
tChart1.Axes.Bottom.Labels.Items.Add(Steema.TeeChart.Utils.DateTime(Convert.ToDateTime("01/01/"+i.ToString())),"01/01/"+i.ToString());
}
//double fouryearincrement = 365 + 365 + 365 + 366;
//tChart1.Axes.Bottom.Increment = fouryearincrement;
}