I have build a unit conversion componenten that changes the labels of the chartaxis so that I can switch from meters to millimeters or feet.
I do this unit conversion in the GetAxisLabel function like this
Code: Select all
Procedure TUnitconv.GetAxisLabel(Sender: TChartAxis; Series: TChartseries; ValueIndex: Integer; var LabelText: string);
var FUCF:double;
DS:Toracledataset;
SN:TChartAxis;
Tag:integer;
begin
inherited;
SN:=Sender;
try
if assigned(Series) then
begin
DS:=Toracledataset(Series.DataSource);
//Hier irgendwie herausbekommen ob es die vertikale oder die horizontale achse ist
if (Series.GetVertAxis =SN) then
begin
if DS.FieldByName(Series.YValues.ValueSource).Tag>0 then
begin
//get the unit conversion factor
FUCF:=Funits[Funititems[Toracledataset(Series.datasource).FieldByName(Series.YValues.ValueSource).Tag,2]].CFaktor;
Labeltext := Floattostr(strtofloat(Labeltext)/FUCF); //calculate the new label
end;
end;
if (Series.GetHorizAxis =SN) then
begin
if DS.FieldByName(Series.xValues.ValueSource).Tag>0 then
begin
//get the unit conversion factor
FUCF:=Funits[Funititems[Toracledataset(Series.datasource).FieldByName(Series.XValues.ValueSource).Tag,2]].CFaktor;
Labeltext := Floattostr(strtofloat(Labeltext)/FUCF);//calculate the new label
end;
end;
end;
Except
end;
end;
TChartseries(parent.Components[j]).ParentChart[sindex].GetVertAxis.LabelStyle:=talText;
Then the unit conversion works well but the ditance between the axis labels is not equal.
If I switch to
TChartseries(parent.Components[j]).ParentChart[sindex].GetVertAxis.LabelStyle:=talValue;
then the distance of the labels is equal bit then the unit isn't converted.
Is there a way to get the unit conversion with equal label distances run?