Displaying labels overlap

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
TMuijsert
Newbie
Newbie
Posts: 5
Joined: Tue Jan 09, 2007 12:00 am

Displaying labels overlap

Post by TMuijsert » Thu Apr 05, 2007 11:30 am

I have a problem with displaying labels on the top-axis.
I am using the top axis to show 2 times, which are very close to each other, but because there is too much overlap, TeeChart hides the second label and it doesn't shows the vertical line, while those are both crucial lines. The AlternateLabels property won't work either for my problem, is there any way I can still show both labels and their vertical lines, using different Y-positions?

Kind regards,
Thomas

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

Post by Narcís » Thu Apr 05, 2007 1:45 pm

Hi Thomas,

You could try using the other suggestions made here.

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
Image Image Image Image Image Image
Instructions - How to post in this forum

TMuijsert
Newbie
Newbie
Posts: 5
Joined: Tue Jan 09, 2007 12:00 am

Post by TMuijsert » Wed Apr 11, 2007 6:45 am

Thank you.

A combination of the LabelsAlternate (true) and LabelsSeperation (0) solved the problem very well!

TMuijsert
Newbie
Newbie
Posts: 5
Joined: Tue Jan 09, 2007 12:00 am

Post by TMuijsert » Wed Apr 11, 2007 1:32 pm

I thought my problems were solved with overlapping labels, but I just ran into a new problem. :(

Image

(Note the top axis, in which the times to the right are gracefully alternated!)

The 2 times (marked with a red circle), should always be shown and are placed in a seperate Series:

Code: Select all

TChartSeries *serBottomText;
The times in between are put in another series (TLineSeries), but the problem is that it always first draws the serBottomText, and then it draws the other series, and then it doesn't matters if there is any overlap (I think it has something to do with the draw orders of the labels, because they are in different series).

Is there a way I can fix this, so that no overlap takes place (here it happens on the right side, but there are also cases where it happens on the left side). Setting LabelsSeperation to 0 and LabelsAlternate to true is also no option, because there can be over 200 times on the x-axis so it's already hiding most of the x-values.

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 Apr 11, 2007 2:08 pm

Hi TMuijsert,

Could you please send us a little bit more information about your application and specifically how are those labels created? Do you use overlapped axes? Do you use custom labels?

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
Image Image Image Image Image Image
Instructions - How to post in this forum

TMuijsert
Newbie
Newbie
Posts: 5
Joined: Tue Jan 09, 2007 12:00 am

Post by TMuijsert » Thu Apr 12, 2007 6:32 am

Thanks for the fast reply, I will post some relevant code in the order it's being executed and I hope it can tell enough about the problem:

Notes:
- iTimeScale is an integer used to scale times, I still have to try out the EncodeTime method
- The x-value will always be between 0 and iTimeScale, so it can never cross the left or right border
- I omitted the y-value, because it comes from a big data structure
- strAnsiTime are all the times between the first and the last time, the times that are causing the overlap!

Code: Select all

/* Header */
TChart *chData;
TChartSeries *serBottomText;
String *strStartTime;
String *strTerminateTime;
/* End Header */

/* Construction */
serBottomText = new TChartSeries(chData);
serBottomText->HorizAxis = aBottomAxis;
serBottomText->ShowInLegend = false;

serBottomText->AddX(0, *strStartTime, clBlack);
serBottomText->AddX(iTimeScale, *strTerminateTime, clBlack);

chData->AddSeries(serBottomText);
/* End Construction */

/* Building the graph (in the case of 1 line) */
TLineSeries *serData = new TLineSeries(Owner);
chData->AddSeries(serData);

// This happens in a double for-loop
serData->AddXY(x-value, y-value, strAnsiTime, clBlack);
/* End Building the graph */
I hope this information clears up enough of the problem :)

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

Post by Narcís » Thu Apr 12, 2007 7:31 am

Hi TMuijsert,

It is still not clear to me how labels are added to horizontal axes. By default, TeeChart draws the labels for first series. You said that bottom axis first and last labels where always visible and the rest of the labels vary, is that correct? If so, how many axes do you have in your project and how are labels added to them? Are they added automatically, do you use custom labels?

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
Image Image Image Image Image Image
Instructions - How to post in this forum

TMuijsert
Newbie
Newbie
Posts: 5
Joined: Tue Jan 09, 2007 12:00 am

Post by TMuijsert » Tue Apr 17, 2007 7:17 am

Hi Narcís,

Sorry for the late reply, but I had to change some things in the code, to make the complication a little easier to understand (and hopefully to solve).

Instead of times, I am now showing times in minutes and I've added all the numbers in 1 serie on the horizontal axis.

However, three problems occur with this:

1) I want to display the realtime below the first and the last time, as multiline labels, but I can't get this to work.

2) I want the labels to show at a constant distance, right now, the amount of labels shown are determined by the width of the labels, but it would be better if there are about 10 points drawn in between the first and the last label.

3) It doesn't always shows the last label anymore, only when there is the space to draw it, LabelsSeperation doesn't work here, because there can be about 200 numbers on the bottom axis, I only want to show a limited number on a constant distance.

Image

Code: Select all

TChartSeries *serBottomText; // Declaration

serBottomText = new TChartSeries(chData); // Initialisation
serBottomText->HorizAxis = aBottomAxis;
serBottomText->ShowInLegend = false;

serBottomText->AddX(0, "", clBlack); // Scaling with a margin
serBottomText->AddX(iMargin, "0", clBlack);
serBottomText->AddX(iMargin + iLast, String(iLast / 60), clBlack);
serBottomText->AddX(iLast + 2 * iMargin, "", clBlack);

// Looping through all the data and adding it to the serie
for (int i = 0; i < iCountMeasurements; ++i)
{
  for (int j = 0; j < iNumPoints; ++j)
  {
    int iTime = data[i][j]; // Time in seconds
    serBottomText->AddXY(iMargin + iTime, 0, String(iTime) / 60), clBlack);
  }
}
the only relevant axis here in the bottom axis, labels are added to them automatically, from the serBottomText serie, no custom labels are used.

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

Post by Narcís » Tue Apr 17, 2007 10:14 am

Hi TMuijsert,
1) I want to display the realtime below the first and the last time, as multiline labels, but I can't get this to work.
It works fine for me here adding labels as shown in the code below. Another option would be manually parsing labels in the OnGetAxisLabel event.

Code: Select all

  Series1.Add(2,'First Line'+#13+'SecondLine',clTeecolor);
  Series1.Add(3,'First Line'+TeeLineSeparator+'SecondLine',clTeecolor);
2) I want the labels to show at a constant distance, right now, the amount of labels shown are determined by the width of the labels, but it would be better if there are about 10 points drawn in between the first and the last label.
You could try setting LabelsSeparation, setting axis Increment or using custom labels to achieve that.
3) It doesn't always shows the last label anymore, only when there is the space to draw it, LabelsSeperation doesn't work here, because there can be about 200 numbers on the bottom axis, I only want to show a limited number on a constant distance.
You could try what's shown in the What's new?\Welcome!\New in Axis\First and Last labels example at the features demo.

You'll find the demo at TeeChart's program group.
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

Post Reply