Chart display question

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
lkuderick
Newbie
Newbie
Posts: 5
Joined: Wed Apr 09, 2003 4:00 am

Chart display question

Post by lkuderick » Tue Jan 23, 2007 8:05 pm

Hello,

I've taken over a project from another developer and I'm looking for a answer to a problem that we have had reported.

We have a simple distribution chart. Typical values on the left axis range from 0 to infinity. When the chart is displayed, using the scroll wheel on the mouse scrolls the chart upwards and downwards. The problem arises from scrolling the chart up. When this happens, the chart shows negative values and I cannot figure out how to make the chart not scroll pass 0.

I am using a standard TChart, programming in delphi 7. I've tried setting the LeftAxis.AutomaticMinimum to False and setting a minimum of zero. But that doesn't work. I suspect I can catch this behavior in the OnScroll event, but I have no idea what to test for.

Anyone? I would greatly appreciate the help. Thanks![/img]

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

Post by Narcís » Wed Jan 24, 2007 8:43 am

Hi lkuderick,

You could tried doing something like this:

Code: Select all

procedure TForm1.Chart1Scroll(Sender: TObject);
begin
  With Chart1.Axes.Left do
    if Minimum < 0 then
    begin
      AutomaticMinimum:=false;
      Minimum:=0;
    end
    else
      Automatic:=true;
end;
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

lkuderick
Newbie
Newbie
Posts: 5
Joined: Wed Apr 09, 2003 4:00 am

Post by lkuderick » Wed Jan 24, 2007 4:13 pm

Narcis,

Thank you for the reply. That almost works. However, when the chart attempts to move below 0 using the scroll wheel, the ticks on the left axis adjust the scale of the graph.

The ticks on the left axis presently scaled every 50 units. Once you start to scroll the chart negatively, the scales start to change and zoom the chart. I'm not 100% positive that some other code is effecting this however, I have disabled everything I have found relating to this chart.

At this point, I'm making an assumption that this is designed behavior that the chart rescales. If there is a property I haven't quite been able to locate it yet.

I only got this project a couple of weeks ago and have only started to read the documentation about this component, so please bear with me.

Is there a method to quickly reset to the original scale?

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 Jan 25, 2007 9:17 am

Hi lkuderick,

Yes, an easy way to unzoom a chart is letting the axes to automatically scale to best fit the series on their drawing area:

Code: Select all

  Chart1.Axes.Left.Automatic:=true;
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

lkuderick
Newbie
Newbie
Posts: 5
Joined: Wed Apr 09, 2003 4:00 am

Post by lkuderick » Fri Jan 26, 2007 7:28 pm

Narcis,

Thank you for all your help. I really appreciate it. I have another question and problem that I have been unable to resolve.

Using the Zoom feature of the chart I can use the mouse to grab a region of the chart and focus in on that portion. This works well as long as the region that is selected is above 0 on the Y axis.

However, when a user grabs a region around the 0 axis the zoomed region shows a area below the 0 axis that shouldn't exist. Is there any way to limit these 'grabs' to not display information below the 0 axis?

Again, thank you for your help?

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

Post by Narcís » Mon Jan 29, 2007 8:03 am

Hi lkuderick,

Yes, as I suggested in my first post, you should try setting axes minimum and/or maximum values in the OnScroll event.
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

Post Reply