Time (hours) on x axis

Good morning Pieter,
thank's to your help i've resolved some problems related to chart.
I have on x axis time in hours from 1 to 24 (all day).
How can i do in order to set minor unit in a quarter of hour (15 minutes).
Is rigth set XValues.MinorUnit := 0.15 and, if yes, wich is the rigth method to show 1.15 1.30 .45 2 on X ?

Thank you so much ...

Daniele

Hi,

Because the X-Axis is default in floating point numbers, you need to format it as date-time, unfortunately date-time is not able to display in floating point number format, therefore you'll have to calculate the numbers yourself. If you want to divide the minor unit parts between each hour in 4 parts of 15 minutes, you need to use 0.25 (quarter), and then multiply that by 60, because an hour is 60 minutes, but the x-axis scale is 100 based.

procedure TForm12.FormCreate(Sender: TObject);
begin
  TMSFNCChart1.BeginUpdate;
  TMSFNCChart1.Series[2].Free;
  TMSFNCChart1.Series[1].Free;
  TMSFNCChart1.Series[0].XValues.MinorUnit := 0.25;
  TMSFNCChart1.Series[0].XValues.MinorUnitFormat := '%.2f';
  TMSFNCChart1.Series[0].XValues.Angle := 90;
  TMSFNCChart1.Series[0].AutoXRange := arDisabled;
  TMSFNCChart1.Series[0].MaxX := 24;
  TMSFNCChart1.EndUpdate;
end;

procedure TForm12.TMSFNCChart1GetSerieXValue(Sender: TObject;
  ASerie: TTMSFNCChartSerie; AIndex: Integer;
  AKind: TTMSFNCChartDrawXYValueKind; AValue: Double; var AValueString: string);
begin
  case AKind of
    vkMinor: AValueString := Format(ASerie.XValues.MinorUnitFormat, [Frac(AValue) * 60 / 100 + Int(AValue)]);
  end;
end;
1 Like

Thank you Pieter for your,very well, explanation.
There's a way to set a XPointValue refered to minorunit ?
In your documentation there is:

procedure TForm1.TMSFNCChart1GetSerieXValue(Sender: TObject;
 ASerie: TTMSFNCChartSerie; AIndex: Integer;
 AKind: TTMSFNCChartDrawXYValueKind; AValue: Double; var AValueString:
string);
begin
 if (AKind = vkMajor) and (AValue = 6) then
 AValueString := 'Custom X Value';
end;
procedure TForm1.TMSFNCChart1GetSerieYValue(Sender: TObject;
 ASerie: TTMSFNCChartSerie; AIndex: Integer;
AKind: TTMSFNCChartDrawXYValueKind; AValue: Double; var AValueString:
string);
begin
 if (AKind = vkMinor) and (AValue = 25) then
 AValueString := 'Custom Y Value';
end;

where i can access to minorunit value (in my case on X axis) but how to set?
In the documentation you fill the chart with

 for I := 0 to 9 do
 s.Points.Add;

where fill the major unit array.
In order to fill the minor unit array who is possible?
For example to set a value to 0.5 and 1.5 on x axis (on documentation example).

Thank you again

Daniele

Hi,

The minor unit is an extra calculation based on the range, you can't set the minor unit array on points basis. It's just an additional property used to add a label to the x-axis, but this is aside from the normal x-axis configuration. So unfortunately, you can't specify a minor unit array

Thank you for reply Pieter ...