Conditional Color Axis Label Color
Posted: Thu Dec 09, 2010 4:22 pm
I have a user's request to change the color of an axis label based on the value that the label represents.
I tried the following code:
but it didn't change the font colors--they are always black.
How can I change individual axis label font colors?
Thank you,
Ed Dressel
I tried the following code:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(20);
Series2.FillSampleValues(20);
Chart1.BottomAxis.OnDrawLabel := DrawBottomAxis;
end;
procedure TForm1.DrawBottomAxis(Sender:TChartAxis; var X,Y,Z:Integer; var Text:String;
var DrawLabel:Boolean);
var
lValue: Integer;
begin
lValue := StrToIntDef(Text, -1);
if lValue < 0 then
Sender.LabelsFont.Color := clRed
else
if ((lValue mod 2) = 1) then
Sender.LabelsFont.Color := clGreen
else
Sender.LabelsFont.Color := clYellow;
end;
How can I change individual axis label font colors?
Thank you,
Ed Dressel