Page 1 of 1
Initial and final date in the x-axis
Posted: Mon Nov 04, 2013 4:19 pm
by 15654539
Is it possible to have always visible in the x-axis the initial and final date?
By example in the attached screenshot we can see fist visible date in the axis is "01/01/2009 16:00" but, the chart starts but I would like to see in the x- axis "01/01/2009 13:00" just in the begininng of the chart. Is it possible?
Thanks
Re: Initial and final date in the x-axis
Posted: Tue Nov 05, 2013 2:44 pm
by 10050769
Hello wakeup,
A solution would be change the labels styles of x-axis as do in next line of code:
Code: Select all
tChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.PointValue;
Could you tell us if previous code works in your end?
Thanks,
Re: Initial and final date in the x-axis
Posted: Tue Nov 05, 2013 3:40 pm
by 15654539
Now it show the time of the first inserted point, but if I don't have automatic scale in x-axis it doen't show the first value of the axis in the 0/0 coordinate...
Thanks
Re: Initial and final date in the x-axis
Posted: Wed Nov 06, 2013 9:48 am
by 10050769
Hello wakeup,
Other solution allow you achieve as you want is, use custom labels as I do in next lines of code:
Code: Select all
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
DateTime dt = DateTime.Today;
Random rnd = new Random();
for (int i = 0; i < 20; i++)
{
line1.Add(dt, rnd.Next(1000));
dt = dt.AddDays(1);
dt = dt.AddHours(1);
}
line1.Pointer.Visible = true;
line1.XValues.DateTime = true;
AddCustomLabels();
tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MM/yyyy HH:mm";
tChart1.Axes.Bottom.Labels.MultiLine = true;
tChart1.Axes.Bottom.Labels.Angle = 90;
}
private void AddCustomLabels()
{
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("dd/MM/yyyy HH:mm"));
}
}
Could you tell us if previous code works in your end? On the other hand to know more about DateTimeFormat please, taking a look in this
link.
Thanks,
Re: Initial and final date in the x-axis
Posted: Fri Nov 08, 2013 10:53 am
by 15654539
It is not exatly what I want because the first date would be the first point, and I would like to see the minimum of the x-axis scale. I think I could change the code to do it manually, but then I would lose the automatic way of teechart to write dates... and it is very usefull because in the manual way the dates sometimes are one over other...
So it there isn't any automatic way, I think it is better to forget it, it's not a very important requeriment.
Thanks
Re: Initial and final date in the x-axis
Posted: Fri Nov 08, 2013 4:40 pm
by 10050769
Hello wakeup,
I am not sure this suggestion help you, but you can try to change the Minimum and Maximum offset of Bottom axis and use SetMinMax to adjust the axis as you want. You can do something as next:
Code: Select all
tChart1.Axes.Bottom.SetMinMax(DateTime.FromOADate(tChart1[0].XValues.Minimum), DateTime.FromOADate(tChart1[0].XValues.Maximum));
tChart1.Axes.Bottom.MinimumOffset = 1;
tChart1.Axes.Bottom.MaximumOffset = 10;
On the other hand, custom labels are the easiest solution to customize the labels as you want and do as you expect.
Thank,