Dates Range on the bottom axis - properties
Re: Dates Range on the bottom axis - properties
Hi
Can you please summarize the code that I should use?
Since there is a lot of code there of ( changing the axis with angle 90 or 0 and definition of chart) that is not relevant to me.
Thanks
Can you please summarize the code that I should use?
Since there is a lot of code there of ( changing the axis with angle 90 or 0 and definition of chart) that is not relevant to me.
Thanks
Re: Dates Range on the bottom axis - properties
Hi ,
I tried to understand the code in the linked thread , but I don't think that it is the same problem.
Can you please assist ? Did you download the example project that I send you?
Thanks.
I tried to understand the code in the linked thread , but I don't think that it is the same problem.
Can you please assist ? Did you download the example project that I send you?
Thanks.
Re: Dates Range on the bottom axis - properties
Hello gcrnd,
I understood that your problem basically is that labels overlap in the bottom axis and this cause when the chart is done smaller, labels are not seen clearly. Please you can say it is your problem?
If it is your problem, please tell us what problems you can find a solution to the thread that we will propose.
If it isn't your problem, please, can you what explain is your problem exactly, because we can reproduce here and help you.
Thanks,
I understood that your problem basically is that labels overlap in the bottom axis and this cause when the chart is done smaller, labels are not seen clearly. Please you can say it is your problem?
If it is your problem, please tell us what problems you can find a solution to the thread that we will propose.
If it isn't your problem, please, can you what explain is your problem exactly, because we can reproduce here and help you.
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 try to understand and to use the code in the tread, but it is not working form me.
I need some method like "on draw" that will calculate all over again where the label are draw and to decide if to show the label or not.
Can you please see the example that I send you in order to reproduce the problem and tell how to solve it.
This behavior already exist in tee chart the only thing that I want is to add the start and the end date.
The perfect solution for me is , if I can use the automatic generated labels by tee chart and to add in addition the first and the last date.
Can you pleas show me how to do it?
Thanks
I try to understand and to use the code in the tread, but it is not working form me.
I need some method like "on draw" that will calculate all over again where the label are draw and to decide if to show the label or not.
Can you please see the example that I send you in order to reproduce the problem and tell how to solve it.
This behavior already exist in tee chart the only thing that I want is to add the start and the end date.
The perfect solution for me is , if I can use the automatic generated labels by tee chart and to add in addition the first and the last date.
Can you pleas show me how to do it?
Thanks
Re: Dates Range on the bottom axis - properties
Hello gcrnd,
I made two examples that I think you can use in your application. The first example is using GetNextAxisLabel Event and second using GetAxisLabel Event
First example using GetNextAxisLabel:
Second example with GetAxisLabel Event:
I hope will helps.
Thanks,
I made two examples that I think you can use in your application. The first example is using GetNextAxisLabel Event and second using GetAxisLabel Event
First example using GetNextAxisLabel:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Styles.Bar bar1;
private bool first = true;
double newValue;
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();
bar1.XValues.DateTime = true;
tChart1.Panel.MarginBottom = 20;
for (int i = 0; i < 50; ++i)
{
bar1.Add(DateTime.Now.AddDays(i), rnd.Next(100), Color.Red);
}
tChart1.Axes.Bottom.Labels.Angle = 90;
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.TwoDays);
tChart1.GetNextAxisLabel += new Steema.TeeChart.GetNextAxisLabelEventHandler(tChart1_GetNextAxisLabel);
}
void tChart1_GetNextAxisLabel(object sender, Steema.TeeChart.GetNextAxisLabelEventArgs e)
{
double seriesIncrement = tChart1[0].XValues[1] - tChart1[0].XValues[0];
if ((sender as Steema.TeeChart.Axis).Equals(tChart1.Axes.Bottom))
{
e.Stop = false;
if (first)
{
newValue = e.LabelValue;
first = false;
}
else
{
newValue += seriesIncrement;
}
if (e.LabelIndex == 0)
{
e.LabelValue = tChart1.Axes.Bottom.CalcPosPoint(tChart1.Axes.Left.Position);
DateTime.FromOADate(e.LabelValue).ToShortDateString();
}
else
{
if (e.LabelIndex == tChart1[0].Count)
{
e.LabelValue = tChart1.Axes.Bottom.CalcPosPoint(tChart1.Axes.Bottom.IEndPos);
DateTime.FromOADate(e.LabelValue).ToShortDateString();
}
else
{
if (e.LabelIndex < tChart1[0].Count)
{
e.LabelValue = newValue;
DateTime.FromOADate(e.LabelValue).ToShortDateString();
}
else
{
e.Stop = true;
first = true;
}
}
}
}
}
Second example with GetAxisLabel Event:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Styles.Bar bar1;
private bool first = true;
double newValue;
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();
bar1.XValues.DateTime = true;
tChart1.Panel.MarginBottom = 20;
for (int i = 0; i < 50; ++i)
{
bar1.Add(DateTime.Now.AddDays(i), rnd.Next(100), Color.Red);
}
tChart1.Axes.Bottom.Labels.Angle = 90;
tChart1.Axes.Bottom.Labels.Style = Steema.TeeChart.AxisLabelStyle.Mark;
tChart1.GetAxisLabel += new Steema.TeeChart.GetAxisLabelEventHandler(tChart1_GetAxisLabel);
}
void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
{
if (sender.Equals(tChart1.Axes.Bottom))
{
if (e.ValueIndex != -1)
{
if (e.ValueIndex == bar1.Count - 2)
{
e.LabelText = DateTime.FromOADate(e.Series.XValues[e.ValueIndex + 1]).ToShortDateString();
}
else
{
e.LabelText = DateTime.FromOADate(e.Series.XValues[e.ValueIndex]).ToShortDateString();
}
}
}
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,
I think you don't understand the problem that I have, since I tried to use the code that you send , and in the both of them have the problems that I already told you.
Example 1 : draw all the dates , but when the window is too small the dates are drown on top of each other.( see I marked it in blue). Example 2 :The dates look ok, but the first and the last date in the range does not appear all the time . (I marked in blue the missing date) I want to marge between them - I want to see clearly the dates as in ex2 , but I want the first and the last label always to be shown.
I think you don't understand the problem that I have, since I tried to use the code that you send , and in the both of them have the problems that I already told you.
Example 1 : draw all the dates , but when the window is too small the dates are drown on top of each other.( see I marked it in blue). Example 2 :The dates look ok, but the first and the last date in the range does not appear all the time . (I marked in blue the missing date) I want to marge between them - I want to see clearly the dates as in ex2 , but I want the first and the last label always to be shown.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Dates Range on the bottom axis - properties
Hi qcrnd,
We have slightly modified the 1st example Sandra posted in her last thread. Now GetNextAxisLabel event takes into account bottom axis increment. This works fine for us here using latest TeeChart for .NET v2009 release available at the client area. Which is the exact TeeChart version you are using? Can you please check if it works fine at your end? You can set bottom axis increment to fit your needs.
We have slightly modified the 1st example Sandra posted in her last thread. Now GetNextAxisLabel event takes into account bottom axis increment. This works fine for us here using latest TeeChart for .NET v2009 release available at the client area. Which is the exact TeeChart version you are using? Can you please check if it works fine at your end? You can set bottom axis increment to fit your needs.
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Styles.Bar bar1;
private bool first = true;
double newValue;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Dock = DockStyle.Fill;
bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.Marks.Visible = false;
bar1.XValues.DateTime = true;
Random rnd = new Random();
for (int i = 0; i < 50; ++i)
{
bar1.Add(DateTime.Now.AddDays(i), rnd.Next(100), Color.Red);
}
tChart1.Panel.MarginBottom = 20;
tChart1.Axes.Bottom.Labels.Angle = 90;
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.TwoDays);
tChart1.GetNextAxisLabel += new Steema.TeeChart.GetNextAxisLabelEventHandler(tChart1_GetNextAxisLabel);
}
void tChart1_GetNextAxisLabel(object sender, Steema.TeeChart.GetNextAxisLabelEventArgs e)
{
double seriesIncrement = tChart1.Axes.Bottom.Increment;
if (sender.Equals(tChart1.Axes.Bottom))
{
e.Stop = false;
if (first)
{
newValue = e.LabelValue;
first = false;
}
else
{
newValue += seriesIncrement;
}
if (e.LabelIndex == 0)
{
e.LabelValue = tChart1.Axes.Bottom.CalcPosPoint(tChart1.Axes.Left.Position);
DateTime.FromOADate(e.LabelValue).ToShortDateString();
}
else
{
if (e.LabelIndex == tChart1[0].Count)
{
e.LabelValue = tChart1.Axes.Bottom.CalcPosPoint(tChart1.Axes.Bottom.IEndPos);
DateTime.FromOADate(e.LabelValue).ToShortDateString();
}
else
{
if (e.LabelIndex < tChart1[0].Count)
{
e.LabelValue = newValue;
DateTime.FromOADate(e.LabelValue).ToShortDateString();
}
else
{
e.Stop = true;
first = true;
}
}
}
}
}
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: Dates Range on the bottom axis - properties
Hi ,
I tried to use the new example , but I still have the same problem in the range is big.
If I don't try to change the label ,in resizing the tee chart is smart and know how to show part of the labels on redraw and it looks good.
I want the same behavior an on addition always to add the first and the last date in the range.
In all the examples that you send me - you shows custom labels, and when we add the custom labels on resizing there is a problem, the labels are draw on top of each other.
see the attached pic - with last example you send me
I tried to use the new example , but I still have the same problem in the range is big.
If I don't try to change the label ,in resizing the tee chart is smart and know how to show part of the labels on redraw and it looks good.
I want the same behavior an on addition always to add the first and the last date in the range.
In all the examples that you send me - you shows custom labels, and when we add the custom labels on resizing there is a problem, the labels are draw on top of each other.
see the attached pic - with last example you send me
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Dates Range on the bottom axis - properties
Hi qcrnd,
Have you tried bottom axis increment as I told you? Last example I posted doesn't add custom labels to the chart. They are modified in the GetNextAxisLabel event but no custom labels added.
Thanks in advance.
Have you tried bottom axis increment as I told you? Last example I posted doesn't add custom labels to the chart. They are modified in the GetNextAxisLabel event but no custom labels added.
Thanks in advance.
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: Dates Range on the bottom axis - properties
Hi
You can see the example project I used.
I copied your code to my example, try to resizing the dialog.
Thanks
You can see the example project I used.
I copied your code to my example, try to resizing the dialog.
Thanks
Re: Dates Range on the bottom axis - properties
Hello gcrnd,
We check your project, and the only problem we have seen, is that last two labels are overlapping. You can solve it changing value of increment, in its case change TwoDays for ThreeDays, as next example:
Please, could you say it changing increment, your project works as you want?
I hope will helps.
Thanks,
We check your project, and the only problem we have seen, is that last two labels are overlapping. You can solve it changing value of increment, in its case change TwoDays for ThreeDays, as next example:
Code: Select all
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.ThreeDays);
I hope will 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 ,
This solution is not good for me , I want the Increment to be one day since when the range is only 3-4 days I want to see all the days.
And when the range of the data is 3-5 months , I want to see the first and the last date and only part of the dates in the middle.
In the solution that you suggest I also have problem on resizing the dialog ( see the images that I already attached in my previous comments).
This solution is not good for me , I want the Increment to be one day since when the range is only 3-4 days I want to see all the days.
And when the range of the data is 3-5 months , I want to see the first and the last date and only part of the dates in the middle.
In the solution that you suggest I also have problem on resizing the dialog ( see the images that I already attached in my previous comments).
Re: Dates Range on the bottom axis - properties
Hello gcrnd,
I recommend that you use default labels, but put first and last dates as annotation tools, because there are same properties with labels manually dates. Please, check if annotation tools solve your problem.
I hope will helps.
Thanks,
I recommend that you use default labels, but put first and last dates as annotation tools, because there are same properties with labels manually dates. Please, check if annotation tools solve your problem.
I hope will 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
Since the solution that you gave is not working for me (you can see the attachments that I send you) .
Can you please tell how can I set the chart to show only the dates that we have data for them in the series?
Thanks
Since the solution that you gave is not working for me (you can see the attachments that I send you) .
Can you please tell how can I set the chart to show only the dates that we have data for them in the series?
Thanks
Re: Dates Range on the bottom axis - properties
Hello gcrnd,
I hope will helps.
Thanks,
I have made a simple code that I think, you could use in your project. Please, check next code works as you want.Can you please tell how can I set the chart to show only the dates that we have data for them in the series?
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Line line = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line.Marks.Visible = false;
line.XValues.DateTime = true;
line.Pointer.Visible = true;
Random rnd = new Random();
for (int i = 0; i < 10; ++i)
{
line.Add(DateTime.Now.AddDays(i), rnd.Next(100),DateTime.Now.AddDays(i).ToShortDateString(), Color.Red);
}
tChart1.Panel.MarginBottom = 20;
tChart1.Axes.Bottom.Labels.Angle = 90;
I hope will 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 |