Page 1 of 1

Switching axes

Posted: Mon Nov 21, 2016 1:20 pm
by 16479009
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?

Re: Switching axes

Posted: Tue Nov 22, 2016 9:50 am
by yeray
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.

Re: Switching axes

Posted: Tue Nov 22, 2016 10:32 am
by 16479009
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.

Re: Switching axes

Posted: Tue Nov 22, 2016 11:40 am
by yeray
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;