TeeChartScrollbar: problem with zoom in

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Marcel
Newbie
Newbie
Posts: 2
Joined: Wed Apr 04, 2007 12:00 am

TeeChartScrollbar: problem with zoom in

Post by Marcel » Tue Feb 05, 2008 2:42 pm

Hello,

i've a problem with the TeeChartScrollBar. I've got a simple dataset with two fields: X (TDateTime) and Y (Integer). The minimum of X is today, the maximum is 100 days from today. I've connected a TeeChartScrollbar to the chart with the following properties: Axis = sbDefault; Align = alBottom; Kind = sbHorizontal. When I run the application everything looks good, but when i zoom in on the chart the values on the X-axis change to dates around 1900. The same things happened when I changed the X-axis from TDateTime to integer values, but it only occurs with large numbers (>30000).

I've tried to track the problem and it seems that the ScrollAxis(Axis:TChartAxis) inline procedure sets uncorrect values for my X-axis.

Can you explain how I can fix this problem? Im using TeeChart Pro 7.12. If necessary I can provide you with an example which you can run "as is".

Greetings,

Marcel.

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 05, 2008 3:09 pm

Hi Marcel,

This is because TChartScrollBar is not using DateTime range. You could try setting its maximum to 50000 at designtime and then use this code:

Code: Select all

uses DateUtils, Math;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var i: integer;
begin
  Series1.XValues.DateTime:=true;

  for i:=0 to 100 do
  begin
    Series1.AddXY(Today + i, random);
  end;

  ChartScrollBar1.Min := Trunc(Series1.MinXValue);
  ChartScrollBar1.Max := Trunc(Series1.MaxXValue);

  Chart1.Title.Text[0]:=IntToStr(ChartScrollBar1.Max);
end;
Hope this helps!
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

Marcel
Newbie
Newbie
Posts: 2
Joined: Wed Apr 04, 2007 12:00 am

Post by Marcel » Wed Feb 06, 2008 1:45 pm

narcis wrote:Hi Marcel,

This is because TChartScrollBar is not using DateTime range. You could try setting its maximum to 50000 at designtime and then use this code:

Code: Select all

uses DateUtils, Math;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var i: integer;
begin
  Series1.XValues.DateTime:=true;

  for i:=0 to 100 do
  begin
    Series1.AddXY(Today + i, random);
  end;

  ChartScrollBar1.Min := Trunc(Series1.MinXValue);
  ChartScrollBar1.Max := Trunc(Series1.MaxXValue);

  Chart1.Title.Text[0]:=IntToStr(ChartScrollBar1.Max);
end;
Hope this helps!
Hi Narcis,

thanks for the quick response. Your suggestion works to a certain extent in my sample application. However it can't get it to right in my main application. Ill try to see if there's a difference between the two.

Thanks,

Marcel.

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

Post by Narcís » Fri Feb 08, 2008 10:25 am

Hi Marcel,

Your problem seems the same as described here. For now, the solution is using TScrollBar instead of TChartScrollBar. I have sent you an e-mail with and example using TScrollBar.
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