Dates Range on the bottom axis - properties
Dates Range on the bottom axis - properties
Hello,
I have a chart that the bottom axis is dates range .I set the "Increment" property to show days, but sometimes when the range is too big and it may include 2-3 months. In this case the chart don't show some of the days since we don't have enough space. How can we make the chart to show always the first and the last day in the given range?
Can you please tell me what property to change in order to show always the first and the last date of the range in the bottom axis.
Thanks
Kety
I have a chart that the bottom axis is dates range .I set the "Increment" property to show days, but sometimes when the range is too big and it may include 2-3 months. In this case the chart don't show some of the days since we don't have enough space. How can we make the chart to show always the first and the last day in the given range?
Can you please tell me what property to change in order to show always the first and the last date of the range in the bottom axis.
Thanks
Kety
Re: Dates Range on the bottom axis - properties
Hello gcrnd,
I made a simple example of dateTime that you can use in your application, please check next code works as you want.
I hope will helps.
Thanks.
I made a simple example of dateTime that you can use in your application, please check next code works as you want.
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Styles.Bar bar1;
private void InitializeChart()
{
bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
Random rnd = new Random();
DateTime today = DateTime.Today;
TimeSpan oneDay = TimeSpan.FromDays(15);
bar1.XValues.DateTime = true;
for (int i = 1; i <= 25; ++i)
{
bar1.Add(today, rnd.Next(100), Color.Red);
today += oneDay;
}
tChart1.Axes.Bottom.Labels.Angle = 90;
Steema.TeeChart.Axis bottomAxis = tChart1.Axes.Bottom;
bottomAxis.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.TwoDays);
}
Thanks.
Best Regards,
Sandra Pazos / 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: Dates Range on the bottom axis - properties
Hi Sandra,
My code is similar to your bu in the increment property I set it to one day.
If the range of the data is a few days - it works ok , since it show me all the days.
The problems is when the range have data from dates of a few month.
Then I see only part of the dates since we don't have enough space.
I want set the chart properties to display always the first and the last day in the range
Thanks
Kety
My code is similar to your bu in the increment property I set it to one day.
If the range of the data is a few days - it works ok , since it show me all the days.
The problems is when the range have data from dates of a few month.
Then I see only part of the dates since we don't have enough space.
I want set the chart properties to display always the first and the last day in the range
Thanks
Kety
Re: Dates Range on the bottom axis - properties
Hello Kety,
I think that you should customize that using the GetNextAxisLabel event as shown in the examples on those threads:
http://www.teechart.net/support/viewtopic.php?t=8392
http://www.teechart.net/support/viewtopic.php?t=4552
Hope this helps.
Thanks,
I think that you should customize that using the GetNextAxisLabel event as shown in the examples on those threads:
http://www.teechart.net/support/viewtopic.php?t=8392
http://www.teechart.net/support/viewtopic.php?t=4552
Hope this helps.
Thanks,
Best Regards,
Sandra Pazos / 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: Dates Range on the bottom axis - properties
Hi,
They have a different problem then mine, in the other case they have always the problem.
In mine case it appears only when the range is large ( not related to offset) and there is no place to draw all the legends.
You can see in attachments 1.bmp (the first day do not appears in the bottom axis) and in 2.bmp (it is OK)
My code is per day, since I want to see the date format in days:
m_thresholdValuesChart.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneDay);
m_thresholdValuesChart.Axes.Left.Increment = 1;
m_thresholdValuesChart.Axes.Left.Labels.ValueFormat = "0";
They have a different problem then mine, in the other case they have always the problem.
In mine case it appears only when the range is large ( not related to offset) and there is no place to draw all the legends.
You can see in attachments 1.bmp (the first day do not appears in the bottom axis) and in 2.bmp (it is OK)
My code is per day, since I want to see the date format in days:
m_thresholdValuesChart.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneDay);
m_thresholdValuesChart.Axes.Left.Increment = 1;
m_thresholdValuesChart.Axes.Left.Labels.ValueFormat = "0";
Re: Dates Range on the bottom axis - properties
Hello gcrnd,
Thanks,
In that case, and as mentioned on the threads I pointed, we recommend using custom axis labels. You may also be interested on reading the thread below which covers most possibilities about label customization. Please notice it's a multiple page thread and what you are looking for may not appear in first pages http://www.teechart.net/support/viewtop ... f=4&t=2989In mine case it appears only when the range is large ( not related to offset) and there is no place to draw all the legends.
You can see in attachments 1.bmp (the first day do not appears in the bottom axis) and in 2.bmp (it is OK)
Thanks,
Best Regards,
Sandra Pazos / 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: Dates Range on the bottom axis - properties
Hi ,
I tied to use custom axis labels,this mean that we need to add manually the labels.
I have a new problem , I want to add the label only if I have enough space in the bottom axis.
How can I recognize this case.I want to add a new label, only if it is not interfere on the previous label.
(see the attachment in this case the new label is paint on top of the previous label).
(my code is :
m_thresholdValuesChart.Axes.Bottom.Labels.Items.Clear();
for (int i = 0; i < m_grid.DataSet.Count; i++)
{
IThresholdValue thresholdValue = (IThresholdValue)m_grid.DataSet;
m_thresholdValuesChart.Axes.Bottom.Labels.Items.Add(m_warningSeries.XValues,
thresholdValue.Date.ToShortDateString());
}
) Thanks
I tied to use custom axis labels,this mean that we need to add manually the labels.
I have a new problem , I want to add the label only if I have enough space in the bottom axis.
How can I recognize this case.I want to add a new label, only if it is not interfere on the previous label.
(see the attachment in this case the new label is paint on top of the previous label).
(my code is :
m_thresholdValuesChart.Axes.Bottom.Labels.Items.Clear();
for (int i = 0; i < m_grid.DataSet.Count; i++)
{
IThresholdValue thresholdValue = (IThresholdValue)m_grid.DataSet;
m_thresholdValuesChart.Axes.Bottom.Labels.Items.Add(m_warningSeries.XValues,
thresholdValue.Date.ToShortDateString());
}
) Thanks
Re: Dates Range on the bottom axis - properties
Hi qcrnd,
In the first page in the thread that Sandra pointed to you in the last post there is an example from Narcís where tries to avoid overlapping. Here is what was suggested on that post:
24 Oct 2005 15:08
In the first page in the thread that Sandra pointed to you in the last post there is an example from Narcís where tries to avoid overlapping. Here is what was suggested on that post:
24 Oct 2005 15:08
Narcís wrote:Hello everyone,
You could implement something like the code below in the OnAfterDraw event and do what you want when labels overlap.
Code: Select all
private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g) { tChart1.Header.Text=""; Steema.TeeChart.AxisLabelItem CurrentLabel, PreviousLabel; for (int i=1; i<tChart1.Axes.Left.Labels.Items.Count; ++i) { CurrentLabel = tChart1.Axes.Left.Labels.Items[i]; PreviousLabel = tChart1.Axes.Left.Labels.Items[i-1]; tChart1.Header.Text=tChart1.Header.Text+" "+CurrentLabel.Top.ToString(); if (CurrentLabel.Top+CurrentLabel.Height == PreviousLabel.Top) { CurrentLabel.Visible=false; } } }
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Dates Range on the bottom axis - properties
Hi ,
I try to use the example that you send me and to change it for the bottom axis?(in the example we have the left axis) , but it seems that I am not taking the location of the labels correctly.
My code is the following :
private void OnChartAfterDraw(object sender, Graphics3D g)
{
Steema.TeeChart.AxisLabelItem CurrentLabel, PreviousLabel;
PreviousLabel = m_thresholdValuesChart.Axes.Bottom.Labels.Items[0];
for (int i = 1; i < m_thresholdValuesChart.Axes.Bottom.Labels.Items.Count; ++i)
{
CurrentLabel = m_thresholdValuesChart.Axes.Bottom.Labels.Items;
if (CurrentLabel.Left< PreviousLabel.Left + PreviousLabel.Height)
{
CurrentLabel.Visible = false;
}
else
{
CurrentLabel.Visible = false;
PreviousLabel = CurrentLabel;
}
}
}
I get negative values for "CurrentLabel.Left" and "PreviousLabel.Left".
Thanks
I try to use the example that you send me and to change it for the bottom axis?(in the example we have the left axis) , but it seems that I am not taking the location of the labels correctly.
My code is the following :
private void OnChartAfterDraw(object sender, Graphics3D g)
{
Steema.TeeChart.AxisLabelItem CurrentLabel, PreviousLabel;
PreviousLabel = m_thresholdValuesChart.Axes.Bottom.Labels.Items[0];
for (int i = 1; i < m_thresholdValuesChart.Axes.Bottom.Labels.Items.Count; ++i)
{
CurrentLabel = m_thresholdValuesChart.Axes.Bottom.Labels.Items;
if (CurrentLabel.Left< PreviousLabel.Left + PreviousLabel.Height)
{
CurrentLabel.Visible = false;
}
else
{
CurrentLabel.Visible = false;
PreviousLabel = CurrentLabel;
}
}
}
I get negative values for "CurrentLabel.Left" and "PreviousLabel.Left".
Thanks
Re: Dates Range on the bottom axis - properties
Hello gcrnd,
Please, you could modify your code as next example and check if it works as you want. If you don’t like solution or doesn’t work correctly, please send us a simple project, because we can reproduce exactly issue here and help to solve it.
I hope will helps.
Thanks,
Please, you could modify your code as next example and check if it works as you want. If you don’t like solution or doesn’t work correctly, please send us a simple project, because we can reproduce exactly issue here and help to solve it.
Code: Select all
private Steema.TeeChart.Styles.Bar bar1;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Dock = DockStyle.Fill;
bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.Marks.Visible = false;
Random rnd = new Random();
DateTime today = DateTime.Today;
TimeSpan oneDay = TimeSpan.FromDays(1);
bar1.XValues.DateTime = true;
for (int i = 1; i <= 55; ++i)
{
bar1.Add(today, rnd.Next(100), Color.Red);
today += oneDay;
}
tChart1.Axes.Bottom.Labels.Items.Clear();
for (int i = 0; i <bar1.Count ; i++)
{
tChart1.Axes.Bottom.Labels.Items.Add(bar1.XValues[i], DateTime.FromOADate(bar1.XValues[i]).ToShortDateString());
}
tChart1.Axes.Bottom.Labels.Angle = 90;
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneDay);
tChart1.AfterDraw +=new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
tChart1.Draw();
}
private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
tChart1.Header.Text = "";
Steema.TeeChart.AxisLabelItem CurrentLabel, PreviousLabel;
for (int i = 1; i < tChart1.Axes.Bottom.Labels.Items.Count; ++i)
{
CurrentLabel = tChart1.Axes.Bottom.Labels.Items[i];
PreviousLabel = tChart1.Axes.Bottom.Labels.Items[i - 1];
if (CurrentLabel.Left+CurrentLabel.Height == PreviousLabel.Left)
{
CurrentLabel.Visible = false;
}
}
}
Thanks,
Best Regards,
Sandra Pazos / 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: Dates Range on the bottom axis - properties
Hi
See the attache project example in order to reproduce the problem.
When we enlarge the dialog the dates are ok , when we change the dialog to small size the dates are not clear.
Thanks
See the attache project example in order to reproduce the problem.
When we enlarge the dialog the dates are ok , when we change the dialog to small size the dates are not clear.
Thanks
- Attachments
-
- WindowsFormsApplication.zip
- (23.48 KiB) Downloaded 675 times
Re: Dates Range on the bottom axis - properties
Hello gcrnd,
Please, see this thread where there are explained everything must be done to solve the problem of overlapping axis labels. I recommend to go concretely at third, fourth and fifth pages.
Those examples look if overlapping labels and paint as much as possible without being over-write. If you want to paint all labels you must do the range of the chart axes smaller or larger chart as being done in thread examples.
Thanks,
Please, see this thread where there are explained everything must be done to solve the problem of overlapping axis labels. I recommend to go concretely at third, fourth and fifth pages.
Those examples look if overlapping labels and paint as much as possible without being over-write. If you want to paint all labels you must do the range of the chart axes smaller or larger chart as being done in thread examples.
Thanks,
Best Regards,
Sandra Pazos / 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: Dates Range on the bottom axis - properties
Hi
Maybe I misunderstand the solution, but how the "gauge" property is related the my problem?
As you see in the example that I send you , I want to know on "OnChartAfterDraw" method ,which label to set to visible and which to set to be invisible.
On resizing it will be change -because it depends if I have enough space to draw all the label.The only problem is that I don't know to check if the new label will be paint on top of the previous or a new location on the screen.
Maybe I misunderstand the solution, but how the "gauge" property is related the my problem?
As you see in the example that I send you , I want to know on "OnChartAfterDraw" method ,which label to set to visible and which to set to be invisible.
On resizing it will be change -because it depends if I have enough space to draw all the label.The only problem is that I don't know to check if the new label will be paint on top of the previous or a new location on the screen.
Re: Dates Range on the bottom axis - properties
Hello gcrnd,
Sorry!
I apologize for my confusion; I have suggested an incorrect thread.Please see this thread now if that is correct.
Thanks,
Sorry!
I apologize for my confusion; I have suggested an incorrect thread.Please see this thread now if that is correct.
Thanks,
Best Regards,
Sandra Pazos / 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 |