Merged Axes, Legend Placement and Popup Accessibility

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Errol
Newbie
Newbie
Posts: 29
Joined: Mon Jul 08, 2019 12:00 am

Merged Axes, Legend Placement and Popup Accessibility

Post by Errol » Wed Nov 16, 2022 3:05 am

I use TeeChart to plot two data sets on a common axis - see Two_Graphs.jpg. The second graph uses custom axes.
When the top axis is used in one graph and the bottom axis in the other, I can merge the two graphs into a single graph. If I set the bottom axis LabelStyle to talNone, the legend is placed correctly, but the units popup does not work on the bottom axis - see Single_Graph_Correct_Legend_no_popup.jpg. If I set BottomAxis.Visible to false, the units popup is activated but the legend is misplaced - see Single_Graph_Legend_Misplaced.jpg.
Any help with this would be greatly appreciated.
Thanks and regards
Errol
Attachments
Two_Graphs.jpg
Two_Graphs.jpg (95.43 KiB) Viewed 740 times
Single_Graph_Correct_Legend_no_popup.jpg
Single_Graph_Correct_Legend_no_popup.jpg (97.82 KiB) Viewed 740 times
Single_Graph_Legend_misplaced.jpg
Single_Graph_Legend_misplaced.jpg (95.98 KiB) Viewed 740 times

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

Re: Merged Axes, Legend Placement and Popup Accessibility

Post by Yeray » Wed Nov 16, 2022 9:42 am

Hello,

I see no difference in the legend for all the screenshots you've posted. I assume you mean the bottom axis title.
Errol wrote:
Wed Nov 16, 2022 3:05 am
If I set the bottom axis LabelStyle to talNone, the legend is placed correctly, but the units popup does not work on the bottom axis - see Single_Graph_Correct_Legend_no_popup.jpg
I'm not sure to understand. In that screenshot, I see the labels in the bottom axis.
Errol wrote:
Wed Nov 16, 2022 3:05 am
If I set BottomAxis.Visible to false, the units popup is activated but the legend is misplaced - see Single_Graph_Legend_Misplaced.jpg.
How are you showing that popup? If that depends on the axis visibility, I'd expect that behaviour.

Here the simple example I'm using to test this. Feel free to modify it to reproduce the problems:

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.Align:=alClient;

  Chart1.View3D:=False;
  Chart1.Legend.Hide;

  Chart1.Color:=clWhite;
  Chart1.Gradient.Visible:=False;
  Chart1.Walls.Back.Color:=clWhite;
  Chart1.Walls.Back.Gradient.Visible:=False;

  Chart1.Axes.Top.Grid.Hide;
  Chart1.Axes.Top.Title.Text:='Top axis title';
  Chart1.Axes.Bottom.Title.Text:='Bottom axis title';

  Chart1.OnClickAxis:=ChartClickAxis;

  with Chart1.AddSeries(TLineSeries) do
  begin
    Color:=clBlack;

    HorizAxis:=aTopAxis;
    FillSampleValues(40);
    for i:=0 to Count-1 do
        XValue[i]:=40+i;
  end;

  with Chart1.AddSeries(TLineSeries) do
  begin
    Color:=clRed;
    FillSampleValues(200);
    for i:=0 to Count-1 do
        XValue[i]:=50+i;
  end;

  //Chart1.Axes.Bottom.LabelStyle:=talNone; // With this, I see no labels at the bottom axis, but the bottom axis line is still drawn and the OnClickAxis is still fired when I click on it
  //Chart1.Axes.Bottom.Visible:=False;      // With this, the OnClickAxis event isn't fired. Expected behaviour
end;

procedure TForm1.ChartClickAxis(Sender:TCustomChart; Axis:TChartAxis; Button:TMouseButton;
                                Shift: TShiftState; X, Y: Integer);
begin
  if Axis=Chart1.Axes.Bottom then
     ShowMessage('Bottom axis clicked');
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

Errol
Newbie
Newbie
Posts: 29
Joined: Mon Jul 08, 2019 12:00 am

Re: Merged Axes, Legend Placement and Popup Accessibility

Post by Errol » Thu Nov 17, 2022 12:37 am

Hi Yeray

I am sorry my explanation was not clear. In the merged chart, there are two overlaid axes, BottomAxis and CustomAxes[5].
In both cases, BottomAxis.LabelStyle is set to talNone.

If BottomAxis.Visible is True, the chart Legend is correctly placed below the BottomAxis title, but the units popup acts on BottomAxis and does not fire because there is no data associated with BottomAxis.

If BottomAxis.Visible is False, the units popup acts on CustomAxes[5] and fires correctly.. However, in this case. the chart Legend is not placed correctly, and obscures the BottomAxis title.

As far as I can see, I need show the BottomAxis to get the legend to be placed correctly. Is it possible to either place CustomAxes[5] on top of BottomAxis so the Units Popup is triggered by CustomAxes[5], or to associate the chart Legend with CustomAxes[5]?

I look forward to your comments.

Regards

Errol

Errol
Newbie
Newbie
Posts: 29
Joined: Mon Jul 08, 2019 12:00 am

Re: Merged Axes, Legend Placement and Popup Accessibility

Post by Errol » Fri Nov 18, 2022 3:19 am

Good afternoon Yeray

I am pleased to report that I fixed the Popup problem by checking that the selected Popup had any items. If not, and if it was a dual graph, the Popup for the bottom axis of the second graph was called. It is all working fine now.

Thanks and regards

Errol

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

Re: Merged Axes, Legend Placement and Popup Accessibility

Post by Yeray » Wed Nov 23, 2022 9:03 am

Hello Errol,
Errol wrote:
Fri Nov 18, 2022 3:19 am
It is all working fine now.
I'm glad to hear that!
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