Jump to content
dummzeuch

Making both vertical axis visible at all times in TeeChart

Recommended Posts

I am using TeeChart for drawing multiple series with two different vertical axis. One set of series uses the left axis, the others use the right axis. The legend contains check boxes that allow the user to turn a series on and off.

image.thumb.png.a6e5e14522eeb7e5a362145455da3f11.png

 

Everything works fine but there is one small problem that I can't get solved: When all series associated with one of the axis are turned off, this axis is not shown.

Right Axis missing:

 

image.thumb.png.96e9f76bdfc56ef47c422748f1b3207a.png

 

Left axis missing:

 

image.thumb.png.20bdc1e34c2f41ff8e7d09383019db5f.png

 

I don't want that. Both axes should always be shown, regardless of which series are visible. But I found no way to change this behavior. Any hint?

Edited by dummzeuch

Share this post


Link to post

Perhaps draw invisible point belonging to the axis?

Share this post


Link to post
1 hour ago, Sherlock said:

Perhaps draw invisible point belonging to the axis?

Invisible point? You mean a point series, that is visible but does no contain any data? Or one that contains data but is set to be drawn invisibly?

I thought about that, but I was really hoping that I am just missing some setting.

Edited by dummzeuch

Share this post


Link to post

Visible but without data, best describes what I meant. I currently don't use TChart but had to, several years ago. I remember the necessity for trickery like that to reach the expected outcome. But my brain is not good at storing code...sorry.

Share this post


Link to post

Is it possible to use the Afterdraw event to force the axis to be visible?

 

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  if not Chart1.Axes.Left.Visible then
    Chart1.Axes.Left.Visible := True;
  if not Chart1.Axes.Right.Visible then
    Chart1.Axes.Right.Visible := True;
end;

 

Share this post


Link to post
1 hour ago, Die Holländer said:

Is it possible to use the Afterdraw event to force the axis to be visible?


procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  if not Chart1.Axes.Left.Visible then
    Chart1.Axes.Left.Visible := True;
  if not Chart1.Axes.Right.Visible then
    Chart1.Axes.Right.Visible := True;
end;

 

Interesting idea, but unfortunately it doesn't work either. I also tried to just set them visible unconditionally and tried the BeforeDrawAxes event.

Share this post


Link to post

Adding two empty point series, one associated with each axis, and not shown in the legend, does the trick.

 

This still feels too much like a hack. So if anybody else has an idea... ?

 

I used to have an account for Steema's support forum, but my credentials don't seem to work any more.

Edited by dummzeuch

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×