When the axis is logarithmic the minor grid intervals are not sensible. Minor grid lines should be at log2, log5, etc.
In log space, if the number of minor grids is 1 it should be at 3; if 2, at 2, 5; if 3, at 2, 5, 8, etc. This could be the default. Users may want to have other choices. Best would be to make it user-specific.
Alternative: can you show me how user can specify a custom grid line?
Comments welcome!
Minor Grids on tChart Logarithmic
-
- Newbie
- Posts: 3
- Joined: Mon Oct 15, 2012 12:00 am
Re: Minor Grids on tChart Logarithmic
Hi Hans,
The algorithm that calculates where to place the MinorTicks, does it in function of the LogarithmicBase and the number of MinorTicks to draw. It's actually dividing the distance between Ticks between the MinorTicks Count, but considering the distances as logarithmic.
If you want to use a different algorithm to this, you can always hide the MinorTicks and draw them manually where you want.
The algorithm that calculates where to place the MinorTicks, does it in function of the LogarithmicBase and the number of MinorTicks to draw. It's actually dividing the distance between Ticks between the MinorTicks Count, but considering the distances as logarithmic.
If you want to use a different algorithm to this, you can always hide the MinorTicks and draw them manually where you want.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 3
- Joined: Mon Oct 15, 2012 12:00 am
Re: Minor Grids on tChart Logarithmic
Yeray, could you point me to method of manually drawing minor grid lines.
Re: Minor Grids on tChart Logarithmic
Hi Hans,
Here you have an example where I set the MinorTicks Color and Length. Then I hide them but I use the MinorTicks Color and Length properties to set the Canvas Pen at the OnAfterDraw event, just before drawing the line that will be my custom MinorTick.
Here you have an example where I set the MinorTicks Color and Length. Then I hide them but I use the MinorTicks Color and Length properties to set the Canvas Pen at the OnAfterDraw event, just before drawing the line that will be my custom MinorTick.
Code: Select all
uses Series, TeCanvas;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
Chart1.View3D:=false;
Chart1.Legend.Visible:=false;
with Chart1.AddSeries(TFastLineSeries) do
for i:=1 to 100 do
AddXY(i, i*i);
Chart1.Axes.Left.Logarithmic:=true;
Chart1.Axes.Left.TickLength:=10;
Chart1.Axes.Left.MinorTickLength:=5;
Chart1.Axes.Left.MinorTicks.Color:=clRed;
Chart1.Axes.Left.MinorTicks.Visible:=false;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var tmpY: Integer;
begin
with Chart1.Canvas, Chart1.Axes.Left do
begin
Pen.Color:=MinorTicks.Color;
tmpY:=CalcPosValue(5);
Line(PosAxis-MinorTickLength, tmpY, PosAxis, tmpY);
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |