TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
-
Rodrigue
- Newbie
- Posts: 23
- Joined: Fri Jan 28, 2005 5:00 am
- Location: Belgium
Post
by Rodrigue » Tue Feb 08, 2005 8:38 pm
Hi,
How to limit the scroll to a range [0,MAX] ?
Here is a code :
Code: Select all
if(Chart1->BottomAxis->Minimum < 0)
Chart1->BottomAxis->SetMinMax(0, Chart1->BottomAxis->Maximum);
if(Chart1->BottomAxis->Maximum > 500)
Chart1->BottomAxis->SetMinMax(Chart1->BottomAxis->Minimum, 500);
it gives a cool effect but not that I've expected ! It limits the range to 0,500 but it stretch the graphic
Thank you in advance for your help !
Cordially,
Rodrigue
-
Marjan
- Site Admin
- Posts: 745
- Joined: Fri Nov 07, 2003 5:00 am
- Location: Slovenia
-
Contact:
Post
by Marjan » Wed Feb 09, 2005 7:22 am
The following code will limit axis minimum to 0 and axis maximum to 500:
Code: Select all
void __fastcall LimitAxisRange(TChartAxis *axis, double amin, double amax)
{
axis->Minimum = Math::Max(axis->Minimum,amin);
axis->Maximum = Math::Min(axis->Maximum,amax);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Chart1BeforeDrawAxes(TObject *Sender)
{
LimitAxisRange(Chart1->BottomAxis,0.0,500);
}
In case you don't want stretched image, you'll have to define the offset and add/subtract it to/from axis minimum/maximum when amin or amax value is reached.
-
Rodrigue
- Newbie
- Posts: 23
- Joined: Fri Jan 28, 2005 5:00 am
- Location: Belgium
Post
by Rodrigue » Wed Feb 09, 2005 12:06 pm
Hi,
Thanks for your reply ! I use C++ Builder 6. I don't know :
I must include a file ?
Cordially,
Rodrigue
-
Marjan
- Site Admin
- Posts: 745
- Joined: Fri Nov 07, 2003 5:00 am
- Location: Slovenia
-
Contact:
Post
by Marjan » Wed Feb 09, 2005 4:00 pm
-
Rodrigue
- Newbie
- Posts: 23
- Joined: Fri Jan 28, 2005 5:00 am
- Location: Belgium
Post
by Rodrigue » Wed Feb 09, 2005 4:18 pm
Sorry,
I've included <math.h> or <Math> but not <Math.hpp>
I test your code but my data are always streched ... maybe it's because I put an offset of 5 pixels on my bottom axe ?
Cordially,
Rodrigue
-
Marjan
- Site Admin
- Posts: 745
- Joined: Fri Nov 07, 2003 5:00 am
- Location: Slovenia
-
Contact:
Post
by Marjan » Fri Feb 11, 2005 10:46 am
Hi.
Not really, axis scales are adjusted exactly as coded (following boolean evaluators I used). If you want different behavior, you'll have to define axis minimum or maximum value as Minimum = Maximum-YourManuallyDefinedOffset OR Maximum = Minimum + YourManuallyDefinedOffset. This way you can ensure chart range will not be "stretched" as it will always show [Minimum, Minimum + offset] or [maximum-offset,maximum] range.