X asix labels not lining up properly
X asix labels not lining up properly
I have a chart that is plotting weekly summary data using a bar graph but I can'y get the x axis labels to line up properly. The data starts 29 Mar 2009 and ends 9 May 2010 in weekly increments, if I plot this data using a bar series I can the following.
As you can see the first label is 01 April 09, what I need is for the bar to have the correct label of 29 Mar 09 and for the label to be centered under the bar.
I've tried several different axis options but no matter what I try I can't get the labels to line up properly, If I increase the size of the chart (see next image) the labels change but still do not line up properly with the bars. Am I missing something here or is this a bug?
Here are sone screen shots of relevant properties pages I'm using Tchart 4.0.2009.62330 in a VS2003 VB environment
As you can see the first label is 01 April 09, what I need is for the bar to have the correct label of 29 Mar 09 and for the label to be centered under the bar.
I've tried several different axis options but no matter what I try I can't get the labels to line up properly, If I increase the size of the chart (see next image) the labels change but still do not line up properly with the bars. Am I missing something here or is this a bug?
Here are sone screen shots of relevant properties pages I'm using Tchart 4.0.2009.62330 in a VS2003 VB environment
Re: X asix labels not lining up properly
Additional:
I've just downloaded the latest build 4.0.2010.13050 and tried that with the same results.
One thing I've noticed that may be related is that I can't seem to change the Offset: value on the bottom axis, it is set to 8 and if I change it to say 0, when I view the axis properties again it is back at 8.
I've just downloaded the latest build 4.0.2010.13050 and tried that with the same results.
One thing I've noticed that may be related is that I can't seem to change the Offset: value on the bottom axis, it is set to 8 and if I change it to say 0, when I view the axis properties again it is back at 8.
Re: X asix labels not lining up properly
Hi Captell,
If I understood well, what you should do is to add your values with labels:
If I understood well, what you should do is to add your values with labels:
Code: Select all
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.Marks.Style = Steema.TeeChart.Styles.MarksStyles.Value;
bar1.XValues.DateTime = true;
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneWeek);
tChart1.Axes.Bottom.Labels.Angle = 90;
Random rnd = new Random();
for (int i = 0; i < 10; i++)
{
DateTime date = DateTime.Parse("29/03/2009").AddDays(7*i);
bar1.Add(date, rnd.Next(100), date.ToString("MMM dd"));
}
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: X asix labels not lining up properly
Yes I could do that but in previous releases I didn't need to, the labels lined up correctly with the bars.
In any event it would be problematic for me to have to add the data with labels as I'm not hard coding the chart definitions, my users can design their own charts.
By adding the data using labels rather than the datetime value I loose the ability for the user to change the format of the labels etc. using the Axis editor.
In any event it would be problematic for me to have to add the data with labels as I'm not hard coding the chart definitions, my users can design their own charts.
By adding the data using labels rather than the datetime value I loose the ability for the user to change the format of the labels etc. using the Axis editor.
Re: X asix labels not lining up properly
Hi Captell,
In that case, I think the best option would be using custom labels:
Could you also post a simple example snipped of code we can run as-is to reproduce this difference of behaviour between releases?
Thanks in advance.
In that case, I think the best option would be using custom labels:
Code: Select all
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Panel.MarginBottom = 15;
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.Marks.Style = Steema.TeeChart.Styles.MarksStyles.Value;
bar1.XValues.DateTime = true;
tChart1.Axes.Bottom.Labels.Angle = 90;
tChart1.Axes.Bottom.Labels.DateTimeFormat = "MMM dd";
Random rnd = new Random();
for (int i = 0; i < 10; i++)
{
DateTime date = DateTime.Parse("29/03/2009").AddDays(7 * i);
bar1.Add(date, rnd.Next(100));//, date.ToString("MMM dd"));
}
RecalcBottomLabels();
}
private void RecalcBottomLabels()
{
tChart1.Axes.Bottom.Labels.Items.Clear();
for (int i = 0; i < tChart1[0].Count; i++)
{
tChart1.Axes.Bottom.Labels.Items.Add(tChart1[0].XValues[i], DateTime.FromOADate(tChart1[0].XValues[i]).ToString(tChart1.Axes.Bottom.Labels.DateTimeFormat));
}
}
Could you please tell us in what release were you experiencing a different behaviour?Captell wrote:Yes I could do that but in previous releases I didn't need to, the labels lined up correctly with the bars.
Could you also post a simple example snipped of code we can run as-is to reproduce this difference of behaviour between releases?
Thanks in advance.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: X asix labels not lining up properly
Hi! I am having the same problem with bar charts. My users are complaining, that when they select just a few points on a time line and the points are representing end of year dates (say, 15th of December each year) and show their data as bar graphs, the labels at the bottom will randomly select a month to show and it is always not centered. The usual question from my client is: "Why, if I select a specific month for the first point, the chart starts with anything BUT the selected month, when the axis is set to automatic?" (same will apply to a specific date, selected by another client) My problem: I cannot use labels for the bottom axis as well as custom drawing, since we are talking about a few thousand clients each having a few hundreds of graphs and not all of them are showing dates on bottom axis. In fact, I have very little control on what they can show on the graph. As to the dates on the bottom axis - clients like to format them differently, set up increment as they need, and unless I will re-implement all your labels drawing logic in my custom Draw Labels, I will have more problems, than I can solve.
Re: X asix labels not lining up properly
I'm not sure excatly which version this bug appeared in but it definately was not present in release 3.5.3146.24804.
Re: X asix labels not lining up properly
Hi Captell and UserLS,
It would be helpful if you could send us a simple example project we can run as-is to reproduce the problem here.
I'm trying to obtain the chart in the last picture from Captell in v3.5.3146 but I can't with the following code:
It would be helpful if you could send us a simple example project we can run as-is to reproduce the problem here.
I'm trying to obtain the chart in the last picture from Captell in v3.5.3146 but I can't with the following code:
Code: Select all
tChart1.Aspect.View3D = false;
tChart1.Panel.MarginBottom = 15;
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.Marks.Style = Steema.TeeChart.Styles.MarksStyles.Value;
bar1.XValues.DateTime = true;
tChart1.Axes.Bottom.Labels.Angle = 90;
tChart1.Axes.Bottom.Labels.DateTimeFormat = "MMM dd";
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneWeek);
Random rnd = new Random();
for (int i = 0; i < 10; i++)
{
DateTime date = DateTime.Parse("29/03/2009").AddDays(7 * i);
bar1.Add(date, rnd.Next(100));
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: X asix labels not lining up properly
Ok, here is the code that reproduces the chart below using the latest released version of TChart:
Note that bottom axis is set to automatic maximum and minimum, none of the points selected are from January, so the question is "Why January is showing up at all?" By setting increment to 365 instead of OneYear, setting Labels.RoundFirst to false and playing with axis Min/Max offsets I can get it to display the correct month (forget about dates!), but in my case it is not going to work, since my clients setup graphs using relative dates (year from today, 6 months from end of last month, etc.) and than print reports every month, or quarter without readjusting them ever after and expect to see the correct dates.
Here is similar problem with monthly dates:
Code: Select all
_testChart.Clear();
var bar = new Bar(_testChart.Chart) {Marks = {Style = MarksStyles.XValue}};
bar.XValues.DateTime = true;
_testChart.Axes.Bottom.Labels.Angle = 90;
_testChart.Axes.Bottom.Labels.DateTimeFormat = "MMM dd";
_testChart.Axes.Bottom.Increment = Utils.GetDateTimeStep(DateTimeSteps.OneYear);
var rnd = new Random();
var date = DateTime.Now;
for (var i = 0; i < 10; i++)
bar.Add(date.AddYears(i), rnd.Next(100));
Code: Select all
_testChart.Clear();
var bar = new Bar(_testChart.Chart) {Marks = {Style = MarksStyles.XValue}};
bar.XValues.DateTime = true;
_testChart.Axes.Bottom.Labels.Angle = 90;
_testChart.Axes.Bottom.Labels.DateTimeFormat = "MMM dd";
_testChart.Axes.Bottom.Increment = Utils.GetDateTimeStep(DateTimeSteps.OneMonth);
var rnd = new Random();
var date = DateTime.Now;
for (var i = 0; i < 10; i++)
bar.Add(date.AddMonths(i), rnd.Next(100));
Re: X asix labels not lining up properly
Hi UserLS and Captell,
Thanks for the samples, UserLS.
I can see strange behaviour that needs to be analysed further so I've added it to the wish list to be revised for future releases (TF02014914).
A) XValues.DateTime. The labels are automatically aligned as you expect if you set the property after populating the series, but before.
B) FillSampleValues. This automatic alignment only seems to work with FillSampleValues. If you change it for the following, the bottom axes labels are non-aligned again (regardless of XValues.DateTime place):
Thanks for the samples, UserLS.
I can see strange behaviour that needs to be analysed further so I've added it to the wish list to be revised for future releases (TF02014914).
A) XValues.DateTime. The labels are automatically aligned as you expect if you set the property after populating the series, but before.
Code: Select all
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.Marks.Style = Steema.TeeChart.Styles.MarksStyles.XValue;
//bar1.XValues.DateTime = true; //non-alignment
tChart1.Axes.Bottom.Labels.Angle = 90;
tChart1.Axes.Bottom.Labels.DateTimeFormat = "MMM dd";
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneDay);
bar1.FillSampleValues();
bar1.XValues.DateTime = true; //alignment
Code: Select all
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.Marks.Style = Steema.TeeChart.Styles.MarksStyles.XValue;
tChart1.Axes.Bottom.Labels.Angle = 90;
tChart1.Axes.Bottom.Labels.DateTimeFormat = "MMM dd";
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneDay);
Random rnd = new Random();
DateTime date = DateTime.Now;
for (var i = 0; i < 10; i++)
bar1.Add(date.AddDays(i), rnd.Next(100));
bar1.XValues.DateTime = true;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: X asix labels not lining up properly
Hi all,
I was just wondering if there is any update on this one?
I was just wondering if there is any update on this one?
Re: X asix labels not lining up properly
Hi Captell,
I'm afraid not yet. I recommend you to be aware at this forum or subscribe to our RSS news feed for new release announcements and what's implemented on them.
I'm afraid not yet. I recommend you to be aware at this forum or subscribe to our RSS news feed for new release announcements and what's implemented on them.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: X asix labels not lining up properly
Hi there,
I just downloaded the June 2010 release 4.0.2010.27960 and this problem is still not fixed. This is really important to my clients, can you tell me when it will be resolved please.
I just downloaded the June 2010 release 4.0.2010.27960 and this problem is still not fixed. This is really important to my clients, can you tell me when it will be resolved please.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: X asix labels not lining up properly
Hello,
I'm not able to commit to a specific date but I have increased issue's priority in the list to be revised.
I'm not able to commit to a specific date but I have increased issue's priority in the list to be revised.
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 |
Re: X asix labels not lining up properly
Hi UserLS and Captell,
After studying the (TF02014914) issue, we concluded that (B) would be a designed behaviour rather than a bug. Let me explain:
The same happens with normal labels:
If you don't specify where the labels should be drawn, we think one would expect them to be drawn at 0, 1, 2 etc, and if you set the increment to be 10, the labels should be at 0, 10, 20 etc. Where otherwise?
And furthermore, if you add more data, breaking the regularity:
If we had changed axis labels to start drawing (5, 15, 25 etc.) they would now be "wrong" when new data added, right?
We could add a new property into axis labels (DrawAtPointValue or something similar) which would only draw labels on the axis where the series has a point. The problem will be that if there was a gap between one point and the next then there would be no axis labels. This is, in effect, identical to adding in point labels using the Series.Add overload.
After studying the (TF02014914) issue, we concluded that (B) would be a designed behaviour rather than a bug. Let me explain:
The same happens with normal labels:
Code: Select all
private void InitializeChart()
{
tChart1.Series.Add(typeof(Bar));
Random rnd = new Random();
for (int i = 0; i < 50; i++)
{
if (i % 5 == 0 && i % 10 != 0)
{
tChart1[0].Add(i, rnd.NextDouble());
}
}
tChart1.Axes.Bottom.Increment = 10;
}
And furthermore, if you add more data, breaking the regularity:
Code: Select all
for (int i = 50; i < 100; i++)
{
if (i % 10 == 0)
{
tChart1[0].Add(i, rnd.NextDouble());
}
}
We could add a new property into axis labels (DrawAtPointValue or something similar) which would only draw labels on the axis where the series has a point. The problem will be that if there was a gap between one point and the next then there would be no axis labels. This is, in effect, identical to adding in point labels using the Series.Add overload.
Code: Select all
tChart1[0].Add(date.AddDays(i), rnd.Next(100), date.AddDays(i).ToString("MMM dd"));
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |