Customizing a vertical axis

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
MarcusR
Newbie
Newbie
Posts: 1
Joined: Fri Nov 15, 2002 12:00 am

Customizing a vertical axis

Post by MarcusR » Sat Apr 10, 2004 3:04 am

Hello!

I am having some problems in my technical application. It shows in the same chart both oscilloscope-like plots for analog signals and digital plots for digital signals. Each signal is contained in its own series and shown using a limited number of custom horizontal axis.

I am having problems with labeling the y-axis for the digital signals.

I would like this:

true .............+------------------------+
false ---------+...............................+-------------------"

true
false --------------------------------------------------------

true ---------------------------------+...........................
false.........................................+----------------------

true ----------------------------------------------------------
false

but get something this:

<nada>...........+------------------------+
<nada>---------+..............................+-------------------

<nada>
<nada>--------------------------------------------------------

true.....---------------------------------+
false.............................................+----------------------

true..... ----------------------------------------------------------
<nada>

Note missing labels.

The graph is used both for real-time plotting and for viewing
recorded files. In the first case the labels ("true"/"false") flicker on an off
as the data scrolls by. In the non realtime mode the same thing happens
when scrolling the chart using the mouse.

The digital signals share the same y-axis like this:
- let's assume I have 4 digital signals indexed 0-3 (each can have the value 0 or 1 )
- when adding a value to the series I add it with x-value = sample time and y-value = signal.index*2+signal.value
- so y = 0 corresponds to signal 0 having a 0 value
- so y = 1 corresponds to signal 0 having a 1 value
- so y = 2 corresponds to signal 1 having a 0 value
- and so on..

This works fine but my problem is getting the labels on the y-axis to appear. I want these labels:
for:
y=0 label "false"
y=1 label "true"
y=2 label "false"
y=3 label "true"
y=4 label "false"

and so on

I know how many signals I have so I would expect to be able to load an array with the labels statically but cannot figure out how to do that. I want all labels to be shown att all times (independent of the data in the series).

I have set the axis Automatic = false, defined the Increment, Minimum, Maximum etc, LabelStyle = talText.

Now, I am using AddXY( ...., "false" )/AddXY( ...., "true" ) to add points with labels but what happens is that even though I can see in the Chart that a signal has both a 0 and a 1 value there is only randomly a label on the axis (and a random gridline in the chart).

Any pointers how what I should do?

PS.

I tried using the OnGetAxisLabel and the OnGetNextLabel (quite sure these are not the right names for the event handlers, but I dont have the code in front of me) but with the same effect.

In all my attempts it seems that the axis does not think the added points are at major tick points/label points so it turns off showing the label and the corresponding grid line. I have set the property TickOnLabelsOnly=false and LabelsSeparation=0 and RoundFirstLabel = false.

This is funny since in this case I know that the y-value of each point is an exact value 0,1,2,3 .... and I have set the Increment etc correctly. I could understand some rounding problem since the coordinates are double, but each signal's labels flickers on off simply depending on *horizontal* scroll (meaning its impossible the y-coordinate may have changed). Sometimes only one "true" and "false" label is shown, often for the bottom signal but sometimes up to 4 or 5 labels are shown.

I am using TChart 6.01 and BCB5.

Have also tried making the labels unique by naming them "f0", "t0", "f1", "t1", etc but the result is the same (thought it might be a problem that there were dupliacte labels)

DS.


Pleeeeeaaaase Heeeeeeeeeeeeeeelpp before I go crazy!!!!

/Marcus

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Thu Apr 15, 2004 5:02 pm

Hi, Marcus.

If you're using Teechart v6 (and above) then I think the easiest solution is to use the custom axis labels. There is an example if this feature available in TeeChart demo. Check the "Axes -> Labels -> Custom labels" example. Looking at your specs, the following code might do the trick:

Code: Select all

  with Chart1.Axes.Left do
  begin
    Items.Clear;  // remove all custom labels

    // add custom labels
    Items.Add(0,'false');
    Items.Add(1,'true');
    Items.Add(2,'false');
    Items.Add(3,'true');

    Items.Add(4,'false');
    Items.Add(5,'true');
    // ... etc
  end;
This is very simplified code. You can use more refined algorihm (perhaps a single for loop with / and % operators to define true or false variables).
Marjan Slatinek,
http://www.steema.com

Post Reply