Page 1 of 1

Logarithmic Axis labels overlaps

Posted: Thu Feb 23, 2006 7:57 am
by 8572678
Fill a candle series as below:

var
i:integer;
h,cl,open,low:double;
begin

for i:=0 to 600 do
begin
low:=1+i/100;
open:=low+0.2;
cl:=low+0.4;
h:=cl+0.2;
series1.AddCandle(date+i,open,h,low,cl);
end;

LeftAxis.Logarithmic is true;
Also min and max is auto.

Posted: Thu Feb 23, 2006 10:10 am
by narcis
Hello,

I've been able to reproduce this issue when scrolling down the series and added the defect (TV52011275) to our bug list to be fixed for future releases. Can you please confirm this is the behaviour you get?

In the meantime, you can solve that problem by not displaying all labels using OnGetAxisLabel event and something like this:

Code: Select all

var
  Form1: TForm1;
  count: Integer;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  i:integer;
  h,cl,open,low:double;
begin
  for i:=0 to 600 do
  begin
    low:=1+i/100;
    open:=low+0.2;
    cl:=low+0.4;
    h:=cl+0.2;
    series1.AddCandle(date+i,open,h,low,cl);
  end;

  Chart1.Axes.Left.Logarithmic:=true;

  count:=0;
end;

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
begin
  if ((Sender=Chart1.Axes.Left) and
      ((count mod 2=0) or (count mod 3=0) or (count mod 5=0))) then
    LabelText:='';

  inc(count);
end;

Logarithmic Labels overlaps

Posted: Thu Feb 23, 2006 11:08 am
by 8572678
Problem occurs in

TChartAxis.CalcLabelsIncrement


if LabelsSeparation>0 then
Repeat
tmp:=IRange/result;
if Abs(tmp)<MaxLongint then
begin
{ TempNumLabels:=Round(tmp);
if TempNumLabels>MaxNumLabels then
if Logarithmic then
result:=result*LogarithmicBase
else
result:=TeeNextStep(result);
}
TempNumLabels:=Round(tmp);
if TempNumLabels>MaxNumLabels then
if Logarithmic then
result:=result*LogarithmicBase
else
result:=TeeNextStep(result);

end
else
if Logarithmic then
result:=result*LogarithmicBase
else
result:=TeeNextStep(result);

tmpInf:=IsInfinite(result);

Until (TempNumLabels<=MaxNumLabels) or (result>IRange) or tmpInf;
{
let FDesiredIncrement =0.01
let LogarithmicBase=10

CalcLabelsIncrement may result in 10 multiple of FDesiredIncrement
So CalcLabelsIncrement may result 10 times less or more.
and labels' frequency 10 times more or less.

}

Posted: Thu Feb 23, 2006 3:09 pm
by narcis
Hello,

Thanks for your suggestion. I've added it to the issue I opened to be considered.