custom AxisLabels overlap
custom AxisLabels overlap
I have a chart with custom log labels on the left and bottom axis.
My problem is that when the chart is resized the labels can overlap each other.
I looked at the demo All Features -> Welcome ! -> Axes -> Labels -> Custom Labels and Custom logarithmic labels and they overlap as well.
I've tried using the GetAxisDrawLabel event but how do I detect if the label being drawn is going to overlap one of the adjacent labels?
My problem is that when the chart is resized the labels can overlap each other.
I looked at the demo All Features -> Welcome ! -> Axes -> Labels -> Custom Labels and Custom logarithmic labels and they overlap as well.
I've tried using the GetAxisDrawLabel event but how do I detect if the label being drawn is going to overlap one of the adjacent labels?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi johnk,
I haven't been able to reproduce what you report. Could you please tell me the exact steps to reproduce this behaviour?
BTW: You could try avoid overlapping labels by incresing its size or axis increment:
I haven't been able to reproduce what you report. Could you please tell me the exact steps to reproduce this behaviour?
BTW: You could try avoid overlapping labels by incresing its size or axis increment:
Code: Select all
tChart1.Axes.Bottom.Labels.CustomSize=30;
tChart1.Axes.Bottom.Increment=10;
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 |
To see this problem you can start the Steema demo and look at
Welcome !\Axes\Labels\Custom labels. There are custom labels on the left axis. When you resize the application so that the Chart becomes smaller you can see that the bottom axis will drop labels when they get too close. The left axis however does not drop any labels and they will overlap.
I tried both CustomSize and Increment and they have no affect.
Welcome !\Axes\Labels\Custom labels. There are custom labels on the left axis. When you resize the application so that the Chart becomes smaller you can see that the bottom axis will drop labels when they get too close. The left axis however does not drop any labels and they will overlap.
I tried both CustomSize and Increment and they have no affect.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi johnk,
Thanks for the information. I've been able to reproduce the problem here. Which behaviour do you suggest for this? Which of the 4 labels would you expect to see when the chart is very small?
Thanks for the information. I've been able to reproduce the problem here. Which behaviour do you suggest for this? Which of the 4 labels would you expect to see when the chart is very small?
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 |
-
- Newbie
- Posts: 17
- Joined: Mon Dec 08, 2003 5:00 am
turn 90 degrees
Hi all,Hi johnk,
Thanks for the information. I've been able to reproduce the problem here. Which behaviour do you suggest for this? Which of the 4 labels would you expect to see when the chart is very small?
I got the same problem as well.
I'd suggest to turn the label 90 degrees, if you can't fit it in.
How about that?
Nice regards
Werner
Turning them 90 degrees will not work for my situation. I'd like a way to detect if a label will overlap another label. Then I can apply my own algorithm to the labels.
I was looking at GetAxisDrawLabel but there is no way for me to tell what the previous label and the next label are and if they will overlap with the current label. Is there anything obvious that I'm missing?
I was looking at GetAxisDrawLabel but there is no way for me to tell what the previous label and the next label are and if they will overlap with the current label. Is there anything obvious that I'm missing?
-
- Newbie
- Posts: 17
- Joined: Mon Dec 08, 2003 5:00 am
exception
Probably it would be best to throw an exception.
So one could truncate or turn 90 degrees or do whatever....
Would that be possible?
Or would it be possible to still show them - even if they overlap?
Nice regards
Werner
So one could truncate or turn 90 degrees or do whatever....
Would that be possible?
Or would it be possible to still show them - even if they overlap?
Nice regards
Werner
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hello everyone,
You could implement something like the code below in the OnAfterDraw event and do what you want when labels overlap.
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,
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 |
Thanks for the help but I ended up using GetAxisDrawLabel.
In the eventargs for this event I have the label text and its location. I look up the label in my AxisLabelItems collection so I can find the previous and next labels. I get the rectangle for next and previous and see if they overlap. Then all I do is set the flag in the EventArgs called DrawLabel to true or false.
In the eventargs for this event I have the label text and its location. I look up the label in my AxisLabelItems collection so I can find the previous and next labels. I get the rectangle for next and previous and see if they overlap. Then all I do is set the flag in the EventArgs called DrawLabel to true or false.
-
- Newbie
- Posts: 17
- Joined: Mon Dec 08, 2003 5:00 am
Hi narcis!
Thanks for your example.
I tried your code, but tChart1.Chart.Axes.Bottom.Labels.Items.Count is zero. What am I doing wrong?
Besides you might want to correct these errors I found in your example (for other users with the same problem)
- instead of tChart1 one should use tChart1.Chart instead
- Is it necessary to reset the header text as well or is just an example of yours?
- CurrentLabel does not have the property Height or Width, you need to use CurrentLabel.Size instead
Thanks
Werner
Thanks for your example.
I tried your code, but tChart1.Chart.Axes.Bottom.Labels.Items.Count is zero. What am I doing wrong?
Besides you might want to correct these errors I found in your example (for other users with the same problem)
- instead of tChart1 one should use tChart1.Chart instead
- Is it necessary to reset the header text as well or is just an example of yours?
- CurrentLabel does not have the property Height or Width, you need to use CurrentLabel.Size instead
Thanks
Werner
Hello everyone,
You could implement something like the code below in the OnAfterDraw event and do what you want when labels overlap.
Code:
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;
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;
}
}
}
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Werner,
With which TeeChart version have you tested that?
Thanks in advance.
With which TeeChart version have you tested that?
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 |
-
- Newbie
- Posts: 17
- Joined: Mon Dec 08, 2003 5:00 am
-
- Newbie
- Posts: 17
- Joined: Mon Dec 08, 2003 5:00 am
Probably it is the same problem as described in
http://www.teechart.net/support/modules ... c5657e4791
I will also try with GetAxisDrawLabel I guess.
Nice regards
Werner
http://www.teechart.net/support/modules ... c5657e4791
I will also try with GetAxisDrawLabel I guess.
Nice regards
Werner
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Werner,
If you are not using custom labels that will be the matter.
When do you need to use this, you should be able to use tChart1.
It's just my example because I didn't want the header having several lines.
Those properties are available in TeeChart for .NET v2.
If you are not using custom labels that will be the matter.
- instead of tChart1 one should use tChart1.Chart instead
When do you need to use this, you should be able to use tChart1.
- Is it necessary to reset the header text as well or is just an example of yours?
It's just my example because I didn't want the header having several lines.
- CurrentLabel does not have the property Height or Width, you need to use CurrentLabel.Size instead
Those properties are available in TeeChart for .NET v2.
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 |
-
- Newbie
- Posts: 17
- Joined: Mon Dec 08, 2003 5:00 am
I tried to work with GetAxisDrawLabel, but I could not get it to work.
Could you please give me some code snippets of how to do that?
I also tried what is described in the FAQ at:
http://www.teechart.net/support/modules ... 0Labelling
But when I do:
it only displays the first value.
When I tryit does not find Dock
Now all labels are displayed and overlap if there is too less space.
Could you please give me some code snippets of how to do that?
I also tried what is described in the FAQ at:
http://www.teechart.net/support/modules ... 0Labelling
But when I do:
Code: Select all
WebChartProdukt.Chart.Axes.Bottom.Automatic = false;
When I try
Code: Select all
WebChartProdukt.Chart.Dock = System.Windows.Forms.DockStyle.Fill;
Now all labels are displayed and overlap if there is too less space.