Changing behaviour of legend checkboxes

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Andrew S
Newbie
Newbie
Posts: 42
Joined: Wed Jul 28, 2004 4:00 am

Changing behaviour of legend checkboxes

Post by Andrew S » Mon Feb 20, 2006 7:32 pm

Is it possible to change the default behaviour of the legend's checkboxes? I understand that currently checking or unchecking the checkboxes will display/hide the associated series in the chart.

Currently, I am drawing a horizontal line in the OnAfterDraw event which denotes the min and max values observed in the Series. I would like the checkboxes to instead show/hide this min/max line. I want my series to always be visible.

Thanks in advance,

Andrew

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Feb 21, 2006 8:43 am

Hi Andrew,

The only way I can think of is doing something like the All Features\Welcome!\Miscellaneous\Legend\Multiple Legens example or All Features\Welcome!\Miscellaneous\Legend\Drawing more text at the TeeChart features demo. The demo can be found at TeeChart's program group. Then you should set the checkbox in the examples to enable or disable that view and the line being drawn in the canvas.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Andrew S
Newbie
Newbie
Posts: 42
Joined: Wed Jul 28, 2004 4:00 am

Post by Andrew S » Tue Feb 21, 2006 3:29 pm

Narcís,

Thanks for the tip, I'll give that a try.

I'm having another strange problem at the moment. I enabled the Chart1.Legend.CheckBoxes on my chart, and the checkboxes now display properly, and are checked. If I set the Series.Visible property the series' checkboxes check and uncheck properly. However, clicking on the legend doesn't do anything. It doesn't hide/show the series.

After a little troubleshooting, it turns out that when I click on the legend, it's the OnClickBackground event that's getting called, and OnClickLegend doesn't get called at all. I suspect that this has something to do with the fact that I've set legend.visible := false, and manually call chart.drawlegend in the OnAfterDraw event so that it is drawn on top of the horizontal min/max lines I mentioned in my previous post.

Does this make sense to you? Can you think of a way that I can re-enable clicking on my legend to hide/show my series?

Thanks in advance,

Andrew

Andrew S
Newbie
Newbie
Posts: 42
Joined: Wed Jul 28, 2004 4:00 am

Post by Andrew S » Tue Feb 21, 2006 4:06 pm

Actually, I think I got it...

I just added a line in my OnClickBackground that checks to see if RSSIChart.Legend.Clicked(x,y) <> -1. If it is, I call my own routine which uses the chart1.legend.items.Top parameter to determine which series was clicked, then I set Series.Visible := not(Series.Visible). Seems to work quite well, and I get to keep drawing my legend manually :)

Andrew

Post Reply