Page 1 of 1
Dates on the bottom axis
Posted: Tue Nov 10, 2009 5:28 pm
by 14045174
I have a bar series (just one) and the values are provided for Dec 15th in 10 consecutive years. The bottom axis is Automatic = true and Increment is set to One Year. It shows January as my months, not Decembers! If I uncheck the automatic (which would present another problem for me) than by resetting axis offsets to 0 (which is again not the thing you want, since the bar now is partially hidden) I can get my Decembers to show up, but honestly, I cannot provide a way to do it - it just sometimes happens to show them and I have no idea what is the combination of properties which will do it.
So, my question is: if my points are for Decembers and increment is set to One Year (or One Month, or 6 Months, etc) why some other month is showing up there?
Re: Dates on the bottom axis
Posted: Fri Nov 13, 2009 9:24 am
by narcis
Hi UserLS,
Your issues are being reviewed. We will postback to this thread when more information is available.
Re: Dates on the bottom axis
Posted: Tue Dec 01, 2009 3:17 pm
by narcis
Hi UserLS,
We have been investigating the issue (TF02014557) here and we found there are some workarounds available:
1. Set Marks.Style to be XValue and set Axes.Bottom.Labels.Style to Mark. This can be done either using the chart editor or programmatically, for example:
Code: Select all
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.XValues.DateTime = true;
bar1.Marks.Style = Steema.TeeChart.Styles.MarksStyles.XValue;
bar1.Marks.Visible = false;
tChart1.Axes.Bottom.Labels.Style = Steema.TeeChart.AxisLabelStyle.Mark;
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneYear);
tChart1.Axes.Bottom.Labels.Angle = 90;
for (int i = 0; i < 10; i++)
{
int currentYear = DateTime.Now.Year;
bar1.Add(DateTime.Parse("15/12/" + Convert.ToString(currentYear + i)), i);
}
2. Adding X DateTime values as point labels, for example:
Code: Select all
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.XValues.DateTime = true;
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneYear);
tChart1.Axes.Bottom.Labels.Angle = 90;
for (int i = 0; i < 10; i++)
{
int currentYear = DateTime.Now.Year;
DateTime dt = DateTime.Parse("15/12/" + Convert.ToString(currentYear + i));
bar1.Add(dt, i, dt.ToShortDateString());
}
3. Customizing labels text in the GetAxisLabel event.
4. Using custom labels for the bottom axis.
Anyway, this is still on the wish-list to be considered as an enhancement for future releases.
Re: Dates on the bottom axis
Posted: Tue Dec 01, 2009 4:09 pm
by 14045174
There are 2 problems with your first work around:
- my users might actually want to see marks and show something different on them, so I cannot tell: "you have to hide your marks".
- even if they do whatever you suggest, the Axis.Labels.Style property is not serialized by your objects, therefore, next time they open their graph, it goes back to whatever default it is, making the whole work around thing worthless, since most of the time they do not even open the graph in the editor, they simply print it as a part of a report package (without even seeing it on the screen)
I did not have time to check the second option, but I do remember, that in Delphi version doing the same thing (I actually did try at some point of time) was not playing well with Axis.Increment (so setting it to One Year or 6 Months had no effect). I'll have to play with it more in .NET, but this will require significant code changes in our system and I'll need to find time to do so.
Re: Dates on the bottom axis
Posted: Wed Dec 02, 2009 8:12 am
by narcis
Hi UserLS,
* even if they do whatever you suggest, the Axis.Labels.Style property is not serialized by your objects, therefore, next time they open their graph, it goes back to whatever default it is, making the whole work around thing worthless, since most of the time they do not even open the graph in the editor, they simply print it as a part of a report package (without even seeing it on the screen)
Ok, I understand your point. However, Axis.Labels.Style serializes correctly for me here using this code:
Code: Select all
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.XValues.DateTime = true;
bar1.Marks.Style = Steema.TeeChart.Styles.MarksStyles.XValue;
bar1.Marks.Visible = false;
tChart1.Axes.Bottom.Labels.Style = Steema.TeeChart.AxisLabelStyle.Mark;
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneYear);
tChart1.Axes.Bottom.Labels.Angle = 90;
for (int i = 0; i < 10; i++)
{
int currentYear = DateTime.Now.Year;
bar1.Add(DateTime.Parse("15/12/" + Convert.ToString(currentYear + i)), i);
}
System.IO.MemoryStream stream = new System.IO.MemoryStream();
tChart1.Export.Template.Save(stream);
stream.Position = 0;
tChart2.Import.Template.Load(stream);
I did not have time to check the second option, but I do remember, that in Delphi version doing the same thing (I actually did try at some point of time) was not playing well with Axis.Increment (so setting it to One Year or 6 Months had no effect). I'll have to play with it more in .NET, but this will require significant code changes in our system and I'll need to find time to do so.
Second option works fine even when exporting a chart template (see code below). Point labels are serialized and since bottom axis uses point labels instead of automatically calculated labels Increment has no influence here.
Code: Select all
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.XValues.DateTime = true;
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneYear);
tChart1.Axes.Bottom.Labels.Angle = 90;
for (int i = 0; i < 10; i++)
{
int currentYear = DateTime.Now.Year;
DateTime dt = DateTime.Parse("15/12/" + Convert.ToString(currentYear + i));
bar1.Add(dt, i, dt.ToShortDateString());
}
System.IO.MemoryStream stream = new System.IO.MemoryStream();
tChart1.Export.Template.Save(stream);
stream.Position = 0;
tChart2.Import.Template.Load(stream);
Re: Dates on the bottom axis
Posted: Wed Dec 02, 2009 3:18 pm
by 14045174
Well, in other words, do not even try the second solution, since I have really no idea, what are the selections on the graph and therefore, the increment should work for those, who have selected a lot of data and want some control over the bottom axis labels...
Re: Dates on the bottom axis
Posted: Fri Jan 08, 2010 3:56 pm
by narcis
Hi UserLS,
We have been reviewing the issue here now. We don't think this is an exclusive problem of DateTime values. Have a look at this code snippet please:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
tChart1.Axes.Bottom.Increment = 100;
for (int i = 0; i < 10; i++)
{
double value = (100 * i) + 23;
bar1.Add(value, i);
//bar1.Add(value, i, value.ToString());
}
}
Here you can see that the bottom axis labels start are [0, 100, 200, 300, etc.] and not [123, 223, 323, 423, etc.]. This is exactly the same problem. To fix this problem, you can add in labels as done in the commented out line. The DateTime equivalent example is this:
Code: Select all
private void InitializeChart()
{
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.XValues.DateTime = true;
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneYear);
tChart1.Axes.Bottom.Labels.Angle = 90;
for (int i = 0; i < 10; i++)
{
int currentYear = DateTime.Now.Year;
DateTime date = DateTime.Parse("21/06/" + Convert.ToString(currentYear + i));
bar1.Add(date, i, date.ToShortDateString());
}
}
We don't see why DateTime values should be treated differently to any other values. In fact, TeeChart treats them as double values internally. If by default the bottom axis label becomes the XValues.Minimum value for the series associated to it, many more customers will start to complain as it will break their applications.
Having said that, could you please send us a simple example project which clearly shows why you can't use any of the suggested ways of working?
Thanks in advance.