Logrithm bug? or I am just confused

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Fang
Newbie
Newbie
Posts: 66
Joined: Wed Oct 13, 2004 4:00 am

Logrithm bug? or I am just confused

Post by Fang » Fri Apr 21, 2006 1:32 pm

hi,
sorry about raise another question, but i think it's related to SetMinMax question.

Set axis automatic to be false.

Code: Select all

        // axis automatic is false here
        // set all values to be position, just for testing
	for (int i=0; i<Series1->Count(); i++) {
		if (Series1->YValue[i]<=0) Series1->YValue[i]=1;
	}
        // change axis to logarithm.
	Chart1->LeftAxis->SetMinMax(1e-3,100);
	Chart1->LeftAxis->Logarithmic=true;
Correct me if any of the following is wrong. First of all, if automatic is false, the min and max is not updated so SetMinMax is required. But I got very confused here about Data Min(or Max) invisible and Axis Min (or Max) visible.

But SetMinMax has to be called before Logarithmic=true; and once set the axis can't be negative!! But the range of the axis shouldn't be the same of the data range, how do I set my range of axis to be (-1,100) while all of my data is actually all positive?

Thanks

Fang
Newbie
Newbie
Posts: 66
Joined: Wed Oct 13, 2004 4:00 am

Post by Fang » Fri Apr 21, 2006 1:41 pm

I thought the following two lines should do the same thing, but the first one doesn't do anything for now if automatic is false.

Code: Select all

	Chart1->LeftAxis->AdjustMaxMin();
	Chart1->LeftAxis->SetMinMax(Series1->MinYValue(), Series1->MaxYValue()) ;

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Apr 28, 2006 12:03 am

Hi Fang,

I'm sorry, I'm not sure which is the problem. Using the following code seems to work fine here :

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
   chart1.Axes.Left.Automatic:=false;
   // set all values to be position, just for testing
   for i:=0 to Series1.Count()-1 do
      if (Series1.YValue[i]<=0) then Series1.YValue[i]:=1;

   // change axis to logarithm.
   Chart1.Repaint;
   Chart1.LeftAxis.SetMinMax(1e-3,100);
   Series1.GetVertAxis.AdjustMaxMin;
   Chart1.LeftAxis.Logarithmic:=true;
end;
Could you please show me what should you get ?

Fang
Newbie
Newbie
Posts: 66
Joined: Wed Oct 13, 2004 4:00 am

Post by Fang » Fri Apr 28, 2006 12:53 pm

I thought axis range can start from negtive while data is all positive. But obvious I am wrong, LOL.

Sorry about that.

Post Reply