Minor Grids on tChart Logarithmic

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
HansWolfgang
Newbie
Newbie
Posts: 3
Joined: Mon Oct 15, 2012 12:00 am

Minor Grids on tChart Logarithmic

Post by HansWolfgang » Tue Feb 05, 2013 4:54 am

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!

Yeray
Site Admin
Site Admin
Posts: 8973
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Minor Grids on tChart Logarithmic

Post by Yeray » Tue Feb 05, 2013 11:39 am

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

HansWolfgang
Newbie
Newbie
Posts: 3
Joined: Mon Oct 15, 2012 12:00 am

Re: Minor Grids on tChart Logarithmic

Post by HansWolfgang » Tue Feb 05, 2013 1:13 pm

Yeray, could you point me to method of manually drawing minor grid lines.

Yeray
Site Admin
Site Admin
Posts: 8973
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Minor Grids on tChart Logarithmic

Post by Yeray » Tue Feb 05, 2013 2:50 pm

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.

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,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply