Switching axes

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Sharpenski
Newbie
Newbie
Posts: 36
Joined: Wed Aug 24, 2016 12:00 am

Switching axes

Post by Sharpenski » Mon Nov 21, 2016 1:20 pm

Is it possible to switch the axes of chart so that x becomes y and vice versa without having to replot it as such - if so, how?

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

Re: Switching axes

Post by Yeray » Tue Nov 22, 2016 9:50 am

Hello,

I'm not sure to understand what do you exactly want to achieve. Could you please expand? Some image can help to understand it.
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

Sharpenski
Newbie
Newbie
Posts: 36
Joined: Wed Aug 24, 2016 12:00 am

Re: Switching axes

Post by Sharpenski » Tue Nov 22, 2016 10:32 am

Basically the X and Y of a grid are oriented incorrectly.

X is currently on the left axis, Y on the bottom axis.
X should be on the bottom axis and Y on the left axis.

0 0 1 1
0 0 0 0
1 1 1 1
0 1 0 1

... should become...

1 0 1 1
1 0 1 0
0 0 1 1
0 0 1 0

so basically X is now on the bottom and inverted, y is on the left.

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

Re: Switching axes

Post by Yeray » Tue Nov 22, 2016 11:40 am

Hello,

You should manually manipulate the arrays in order to achieve this. You could use a temporal TColorGrid as follows:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var x, z: Integer;
begin
  Series1.Marks.Visible:=true;

  Series1.AddXYZ(0, 0, 0);
  Series1.AddXYZ(1, 1, 0);
  Series1.AddXYZ(2, 0, 0);
  Series1.AddXYZ(3, 1, 0);

  Series1.AddXYZ(0, 1, 1);
  Series1.AddXYZ(1, 1, 1);
  Series1.AddXYZ(2, 1, 1);
  Series1.AddXYZ(3, 1, 1);

  Series1.AddXYZ(0, 0, 2);
  Series1.AddXYZ(1, 0, 2);
  Series1.AddXYZ(2, 0, 2);
  Series1.AddXYZ(3, 0, 2);

  Series1.AddXYZ(0, 0, 3);
  Series1.AddXYZ(1, 0, 3);
  Series1.AddXYZ(2, 1, 3);
  Series1.AddXYZ(3, 1, 3);
end;

procedure TForm1.Button1Click(Sender: TObject);
var tmpGrid: TColorGridSeries;
    x, z: Integer;
begin
  tmpGrid:=TColorGridSeries.Create(Self);

  for x:=0 to Series1.NumXValues-1 do
    for z:=0 to Series1.NumZValues-1 do
        tmpGrid.AddXYZ((Series1.NumZValues-1)-z, Series1.YValue[(z*Series1.NumXValues)+x], x);

  Series1.DataSource:=tmpGrid;
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

Post Reply