Custom Label Separation Problems

TeeChart for ActiveX, COM and ASP
Post Reply
Falcondl
Newbie
Newbie
Posts: 2
Joined: Tue Sep 12, 2006 12:00 am

Custom Label Separation Problems

Post by Falcondl » Wed Oct 04, 2006 3:23 am

I've been using a stacked bar chart, which forced me to clear out and add my own X axis labels because I couldn't come up with an automatic way of displaying them with TeeChart.

The problem I'm having is that when I define my own labels (.GetLabels().Add(etc...)) TeeChart does not do the automatic label intervals when there are too many labels on the screen. I reeaally don't want to write the code to calculate the bounds/separation of the labels myself...

Does anyone know how I can have it auto-separate the labels even when you've added them yourself?

(I've tried OnGetAxisLabel - the fact that it is a stacked bar chart seems to cause problems with it, or at the very least, I cannot get the right labels to show up properly on the x axis).

Thanks for the help..

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Oct 04, 2006 9:02 am

Hi Falcondl,

You could try reading this TeeChart for .NET topic speaking of the same problem. The same approach could be achieved with TeeChart ActiveX.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Falcondl
Newbie
Newbie
Posts: 2
Joined: Tue Sep 12, 2006 12:00 am

Post by Falcondl » Thu Oct 05, 2006 6:14 pm

The post was helpful, but I can't help but wonder why I can't grab this information directly from TeeChart, even for custom labels? To have OnGetAxisLabel event fire would be useful also.

Even using the technique described in the other post, I have no way of determining the vertical offset of the label from the axis (although it worked well for labels that were at the same vertical level.)

(Code for future reference, which works to calculate the size of the label...)

Code: Select all

   CAxisLabelsItem lblItem=m_Chart.GetAxis().GetBottom().GetLabels().GetItem(i);
   Font font(T2W(lblItem.GetFont().GetName()), lblItem.GetFont().GetSize());
   PointF origin(0.0f, 0.0f);
   StringFormat format = StringFormat::GenericTypographic();
   RectF boundRect;
   
   graphics.MeasureString(T2W(lblItem.GetText()), lblItem.GetText().GetLength(), &font, origin, &format, &boundRect);
For instance, when alternating labels are on, or a label takes up multiple lines, the problem is that there is no way to check if one label is actually above another label, and thus not obstructing the view of the label below it, despite the horizontal overlap.

I tried GetShapeBounds(), but this doesn't seem to work on Custom Labels either.

Basically, I'm a little confused why I don't have access to these properties, events, etc., or even have TeeChart handle sizing, even if they're custom labels.

Regardless, is there really no better way of determining overlap?

Post Reply