Page 1 of 1

EOverflow exception while loading a data to Chart

Posted: Fri Nov 24, 2006 11:44 am
by 9347416
Hello.

I have a problem with loading "zero" values to TeeChart. EOverflow exception raising when data contains only "zero" values. It's raise at line 2695 {TeEngine.pas}

Code: Select all

Procedure TChartAxis.InternalCalcRange;
begin
  IRange:=IMaximum-IMinimum;
  IRangeZero:=IRange=0;
  if IRangeZero then IAxisSizeRange:=0
                       else IAxisSizeRange:=IAxisSize/IRange; {line 2695}
when IRange is very small (like IRange = 4.0403223612e-311), then result of IAxisSize/IRange is very big (more then MaxDouble). As the result is rasing of EOverflow exception.

I think it's can be correct this way:

Code: Select all

Procedure TChartAxis.InternalCalcRange;
begin
  IRange:=IMaximum-IMinimum;
  IRangeZero:=IRange=0;
  if IRangeZero then IAxisSizeRange:=0
  else
    try
      IAxisSizeRange:=IAxisSize/IRange;
    except
      on E: EOverflow do
        IAxisSizeRange := MaxDouble;
      else
        raise
    end;

Posted: Fri Nov 24, 2006 12:25 pm
by narcis
Hi arthemy,

Which TeeChart version are you using? Could you please send us some code or a simple example we can run "as-is" to reproduce the problem here?

You can post your files at news://www.steema.net/steema.public.attachments newsgroup.

Thanks in advance.

Posted: Fri Nov 24, 2006 12:52 pm
by 9347416
I'm usinng TeeChart 7.07 Pro with source

For regret, I can't connect to news://www.steema.net/steema.public.attachments newsgroup.

The example is very simple. It's a form with TeeChart and button.

Code: Select all

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart, StdCtrls;

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Series1: TBarSeries;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses Math;

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
  x,y: Double;
begin
  Series1.Clear;
  X := 100;
  Y := MinDouble;
  for i := 0 to 1000 do
  begin
    Series1.AddXY(X,Y);
    X := X + i/1000; 
  end;
end;

end.