synchronization of two opposite axis

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
odaumas
Newbie
Newbie
Posts: 16
Joined: Tue Feb 18, 2020 12:00 am

synchronization of two opposite axis

Post by odaumas » Wed Mar 04, 2020 5:55 pm

Hello :) ,
First and second of my three problems are shown in the chart joined :
Firstable I need to explain that I fill series as follow :

Code: Select all

Series[0].AddXY(Occurs_No, y, FloatToStrF(Value_Of_x), ffNumber, 7, 2));
because I want to display the record number on BottomAxis, and the value of this record right in front, on TopAxis.

My first problem is that, Doing so, I'm not able to align the two values correctly on the grid, "face to face".
And my second problem is that, as you can see on the chart, when my data source returns only one record, the BottomAxis value is not shown in the middle of the axis, as my dreams would like.
I think the two problems are linked...

Could some one tell me how to resolve my problems, please :? ?
Attachments
SS1_To_Forum.PNG
SS1_To_Forum.PNG (38.74 KiB) Viewed 20598 times

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: synchronization of two opposite axis

Post by Yeray » Thu Mar 05, 2020 8:41 am

Hello,

We'd need a simple example project we can run as-is to reproduce the problem here because I see no problems trying to achieve what I'm understanding you described:
Project1_2020-03-05_09-40-41.png
Project1_2020-03-05_09-40-41.png (9.51 KiB) Viewed 20590 times
Project1_2020-03-05_09-40-45.png
Project1_2020-03-05_09-40-45.png (17.32 KiB) Viewed 20590 times

Code: Select all

uses Series;

procedure TForm1.PopulateSeries(ACount: Integer);
var i: Integer;
begin
  Chart1[0].Clear;
  for i:=0 to ACount-1 do
    Chart1[0].AddXY(i,(i+1*10),'Value of ' + IntToStr(i));
end;

procedure TForm1.BMultipleValuesClick(Sender: TObject);
begin
  PopulateSeries(10);
end;

procedure TForm1.BSingleValueClick(Sender: TObject);
begin
  PopulateSeries(1);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=False;
  Chart1.Legend.Hide;

  Chart1.Axes.Top.LabelStyle:=talText;
  Chart1.Axes.Bottom.LabelStyle:=talValue;

  with TBarSeries(Chart1.AddSeries(TBarSeries)) do
  begin
    ColorEachPoint:=True;
    HorizAxis:=aBothHorizAxis;
    Marks.Hide;
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

odaumas
Newbie
Newbie
Posts: 16
Joined: Tue Feb 18, 2020 12:00 am

Re: synchronization of two opposite axis

Post by odaumas » Thu Mar 05, 2020 9:47 am

Hello Yeray,
It's close to that. But the value I want to display on top axis is not the value of "i", but the value contained in the record number "i" :
DataSource :
1: 1250,30
2: 1360,60
3: 1610,14

Writing this, I realize that top axis must be out of sync from bottom axis. Sorry :?
I'd just like to display
1, 2, 3
on bottom axis and in front of each of these values, on the top axis
1250,30
1360,60
1610,14

Thanks for your help.
Attachments
SS2_To_Forum.png
SS2_To_Forum.png (18.09 KiB) Viewed 20589 times

odaumas
Newbie
Newbie
Posts: 16
Joined: Tue Feb 18, 2020 12:00 am

Re: synchronization of two opposite axis

Post by odaumas » Thu Mar 05, 2020 10:19 am

...and when I define TopAxis.Automatic at False,
it don't show anything anymore :( .

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: synchronization of two opposite axis

Post by Yeray » Thu Mar 05, 2020 12:50 pm

Hello,

I'm using an array to store the values to be displayed on the top but using a datasource should also work:

Code: Select all

var topValues: array of double = [1250.30, 1360.60, 1610.14];

procedure TForm1.PopulateSeries(ACount: Integer);
var i: Integer;
begin
  FormatSettings.DecimalSeparator:=',';
  FormatSettings.ThousandSeparator:='.';

  Chart1[0].Clear;
  for i:=0 to ACount-1 do
    with Chart1[0] do
    if i<Length(topValues) then
       AddXY(i,(i+1*10),FormatFloat('#,##0.##',topValues[i]))
    else
       AddXY(i,(i+1*10));
end;
Project1_2020-03-05_13-48-08.png
Project1_2020-03-05_13-48-08.png (17.34 KiB) Viewed 20580 times
odaumas wrote:
Thu Mar 05, 2020 10:19 am
...and when I define TopAxis.Automatic at False,
it don't show anything anymore :( .
You need to set the axis minimum and maximum values when you don't want it to be automatic.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

odaumas
Newbie
Newbie
Posts: 16
Joined: Tue Feb 18, 2020 12:00 am

Re: synchronization of two opposite axis

Post by odaumas » Thu Mar 05, 2020 1:00 pm

Ah ok, thanks.

odaumas
Newbie
Newbie
Posts: 16
Joined: Tue Feb 18, 2020 12:00 am

Re: synchronization of two opposite axis

Post by odaumas » Thu Mar 05, 2020 4:04 pm

I do a clear chart, before creating the series dynamically.
Maybe I not define something correctly. :roll:

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: synchronization of two opposite axis

Post by Yeray » Fri Mar 06, 2020 8:01 am

Hello,

If you still find problems with it, please try to arrange a simple example project we can run as-is to reproduce the problem here.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply