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]
Chart display question
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi lkuderick,
You could tried doing something like this:
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 |
Instructions - How to post in this forum |
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?
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?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
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:
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 |
Instructions - How to post in this forum |
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?
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?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi lkuderick,
Yes, as I suggested in my first post, you should try setting axes minimum and/or maximum values in the OnScroll event.
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 |
Instructions - How to post in this forum |