Page 1 of 1

How to check if custom axis is visible

Posted: Mon Nov 14, 2016 6:51 am
by 16578912
Hi,

I try to manage custom axis on a screen. To prepare free space for axis I had to detect if it's visible on the screen. I know that axis should have visible property set to true and It should have active series attache to.
But there is one situation that I can't figure out. When eg. I have 3 series each one is connected to another axis, then I deactivate series one by one the axis from last deactivated series stays visible (when there is no active series).

How to check if custom axis is really visible?

Best Regards,
Grzegorz

Re: How to check if custom axis is visible

Posted: Mon Nov 14, 2016 1:30 pm
by yeray
Hello Grzegorz,

I've tried to reproduce the problem with the simple example below but it seems to work fine for me here.
I'm adding several series, each one with its custom vertical axis. I'm hiding the walls and all the axes except the bottom axis and the custom vertical axes. Then, I've added a checkbox that deactivates/activates all the series, the custom vertical axes and the bottom axis:

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
    tmpAxis: TChartAxis;
begin
  Chart1.Legend.Visible:=false;
  Chart1.View3D:=false;
  CheckBox1.Checked:=true;

  for i:=0 to Chart1.AxesList.Count-1 do
    if Chart1.Axes[i]<>Chart1.Axes.Bottom then
      Chart1.Axes[i].Visible:=false;

  for i:=0 to 3 do
  begin
    tmpAxis:=Chart1.CustomAxes.Add;
    tmpAxis.Horizontal:=false;

    with Chart1.AddSeries(TFastLineSeries) as TFastLineSeries do
    begin
      FillSampleValues;
      CustomVertAxis:=tmpAxis;
    end;
  end;

  Chart1.Walls.Visible:=false;
  Chart1.MarginLeft:=10;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
var i: Integer;
begin
  for i:=0 to Chart1.SeriesCount-1 do
  begin
    Chart1[i].Active:=CheckBox1.Checked;
    Chart1[i].CustomVertAxis.Visible:=Chart1[i].Active;
  end;

  Chart1.Axes.Bottom.Visible:=CheckBox1.Checked;
end;

Re: How to check if custom axis is visible

Posted: Tue Nov 15, 2016 12:04 pm
by 16578912
Hello

Ok now I see what I'm doing wrong. When custom axis doesn't have active series attached are hidden, but when there is no active series on a chart all axis are visible, but I didn't notice this because they all have the same position and they overlap each other.

Best Regards,
Grzegorz