Good morning to all,
i'm trying to work with FNCChart and, im my case, is not so easy.
What i need is show some data (money value) reported to 24h per selected day.
Now i have one arrary [0..23] that rapresent the 24 hours of a day.
My chart is inizialized with
procedure TFM.ImpostaGrafico;
var S : TTMSFNCChartSerie;
I : Integer;
PT : TTMSFNCChartPoint;
begin
Chart1.BeginUpdate;
Chart1.Clear;
S := Chart1.Series.Add;
S.Mode := smStatistical;
S.AutoXRange := arEnabled;
S.AutoYRange := arEnabledZeroBased;
for I := 0 to Length(FPointArray) - 1 do
begin
PT := S.Points.Add;
PT.XValueText := FormatFloat('#0',I + 1);
PT.YValue:=10000;
end;
Chart1.EndUpdate;
end;
Good morning Pieter,
can you give a simple example on how to work in a correct way with chart?
I have this procedure to "prepare" the chart:
procedure TFM.ImpostaGrafico;
var S : TTMSFNCChartSerie;
I : Integer;
PT : TTMSFNCChartPoint;
begin
Chart1.BeginUpdate;
Chart1.Clear;
S := Chart1.Series.Add;
S.Mode := smStatistical;
S.AutoXRange := arEnabled;
S.AutoYRange := arEnabledZeroBased;
FPointArray[9]:=500;
FPointArray[10]:=650;
FPointArray[11]:=450;
Chart1.EndUpdate;
end;
Where
FPointArray : array [0..23] of Double;
and to show the chart i have:
procedure TFM.Chart1GetNumberOfPoints(Sender: TObject;
ASerie: TTMSFNCChartSerie; var ANumberOfPoints: Integer);
begin
ANumberOfPoints := Length(FPointArray);
end;
procedure TFM.Chart1GetPoint(Sender: TObject; ASerie: TTMSFNCChartSerie;
AIndex: Integer; var APoint: TTMSFNCChartPointVirtual);
begin
if (AIndex >= 1) and (AIndex <= Length(FPointArray)) then
Begin
if FPointArray[AIndex]>0 then
Begin
APoint.YValue := FPointArray[AIndex];
APoint.XValue:= AIndex;
End;
End;
end;
procedure TForm1.Chart1GetPoint(Sender: TObject; ASerie: TTMSFNCChartSerie;
AIndex: Integer; var APoint: TTMSFNCChartPointVirtual);
begin
if (AIndex >= 0) and (AIndex <= Length(FPointArray) - 1) then
Begin
if FPointArray[AIndex] > 0 then
Begin
APoint.YValue := FPointArray[AIndex];
APoint.XValue := AIndex;
End
else
APoint.Undefined := True;
End;
end;
As you see i loose all other day hours.
The picture shows the correct result but, in the same time, i need to show the hours on x axis.
There's a way to get a chart like this ?
Your auto-range for the X-Axis is arEnabled, which means it will only take the valid points. change it to arDisabled and specify minimum and maximum boundaries