Page 1 of 1

decimals on axis

Posted: Mon May 21, 2012 11:47 am
by 10546313
Hi,

I use Tchart 8 professional.
I set the decimal to a fix one e.g LeftAxis.AxisValuesFormat:=0.0

If I zoom the axisvalue is always the same : for e.g. 1.1/1.1/1.1
So what can I do, that the format changes so that the last digit is different.
Example : I zoom -> the axis is 1.11/1.12/1.13
I zoom more the axis is 1.111/1.112/1.113 and so on

with best regards
Werner

Re: decimals on axis

Posted: Tue May 22, 2012 2:12 pm
by yeray
Hi Werner,

By default, the AxisValuesFormat is '#.##0,###'. But you can change it as you want adding more decimals if you need them.
You even could calculate the string in the OnZoom event to add more or less decimals. It could be something similar to this:

Code: Select all

procedure TForm1.Chart1Zoom(Sender: TObject);
var Range: Double;
    i: Integer;
    valueFormat: String;
begin
  Range:=(Chart1.Axes.Bottom.Maximum-Chart1.Axes.Bottom.Minimum);
  Chart1.Draw;

  valueFormat:='#,##0.#';
  i:=1;
  while ((Range / Chart1.Axes.Bottom.Items.Count) * (i*10) < 1) do
  begin
    Inc(i);
    valueFormat:=valueFormat+'#';
  end;

  Chart1.Axes.Bottom.AxisValuesFormat:=valueFormat;
end;