Page 1 of 1

TeeChartScrollbar: problem with zoom in

Posted: Tue Feb 05, 2008 2:42 pm
by 9349757
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.

Posted: Tue Feb 05, 2008 3:09 pm
by narcis
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!

Posted: Wed Feb 06, 2008 1:45 pm
by 9349757
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.

Posted: Fri Feb 08, 2008 10:25 am
by narcis
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.