Increase 'OnClickAxis' activation area?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Dave A. Law
Newbie
Newbie
Posts: 5
Joined: Fri Oct 15, 2004 4:00 am

Increase 'OnClickAxis' activation area?

Post by Dave A. Law » Wed Jun 01, 2005 9:19 pm

Is there a way to increase the area which will activate the 'OnClickAxis' function? I would have thought that simply clicking the numbers would work but you have to click within the tick size range.

- Dave A. Law
NuFlo Measurement Systems

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

Post by Narcís » Thu Jun 02, 2005 9:23 am

Hi Dave,

I'm afraid not. However you may implement it using MouseDown event and checking if the clicked point (X,Y coordinates provided by the event) is within a rectangle you may define from axis IStartPos, IEndPos and PosAxis. This could be something like:

Code: Select all

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  Top,Bottom,Left,Right: Integer;
begin
  Top:=Chart1.LeftAxis.IStartPos;
  Bottom:=Chart1.LeftAxis.IEndPos;
  Left:=Chart1.LeftAxis.PosAxis-30;
  Right:=Chart1.LeftAxis.PosAxis;

  if ((X>=Left) and (X<=Right) and (Y>=Top) and (Y<=Bottom)) then
    Chart1.Title.Text[0]:='Left Axis Clicked!'
  else Chart1.Title.Text[0]:= '';
end;
Please notice that this code works for a vertical axis. If you want to do it for an horizontal one you'll have to assigne IStartPos and IEndPost to Left and Right values respectively and use PosAxis for Top and Bottom values.
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

James J. Gold
Newbie
Newbie
Posts: 8
Joined: Wed Jun 01, 2005 4:00 am
Location: San Jose, California USA
Contact:

Post by James J. Gold » Fri Jun 10, 2005 8:52 am

Narcis:

Along these lines, is there a way of allowing the user to click on an axis caption and have an easily-identifiable event for the program to use to respond to the click?

What I am thinking of is a simple 2-D chart with the X axis labeled as months, and when the user clickes on, say, the "Feb 2005" label, the program can display information relating to that time period (not extracted from the chart, just responding for that general x-location on the chart.

In other words, the TeeChart program allows the user to do wonderful things at runtime, and because of that the locations of points on the axes can shift on the screen. What I want is to be able to identify a (shifted) location within the displayed data where the user clicks and respond to that. I don't need to get XY coordinates for data points clicked on, just which axis label is closest. It would be nice if each label was in an invisible box and if I clicked in the box I could read out the label as a string.

This would be worth upgrading from Std to Pro for me.

Thanks for reading this and thinking about it.

-- Jim Gold --
jim@goha.com

Post Reply