OnGetLegendText - Format Values using ValueFormat property
Posted: Wed Aug 27, 2008 9:03 pm
How can I format series values in the OnGetLegendText event using the ValueFormat mask. I have tried using Delphi's FormatMaskText function, but it doesn't format the string correctly.
The ValueFormat property for the series is always set to either '#,##0' or '#,##0.00'. If I don't use GetLegendText, the values are formatted correctly, so I know the ValueFormat mask is set correctly.
Below is a simple example of what I am trying to do.
The ValueFormat property for the series is always set to either '#,##0' or '#,##0.00'. If I don't use GetLegendText, the values are formatted correctly, so I know the ValueFormat mask is set correctly.
Below is a simple example of what I am trying to do.
Code: Select all
procedure TForm.DBChart1GetLegendText(Sender: TCustomAxisPanel;
LegendStyle: TLegendStyle; Index: Integer; var LegendText: String);
var
vValueMask : String;
begin
if LegendStyle = lsValues then
begin
vValueMask := FChart.SeriesList[0].ValueFormat;
LegendText := FormatMaskText(vValueMask, FloatToStr(FChart.SeriesList[0].YValue[Index])) + #6
+ FChart.SeriesList[0].Labels[Index];
end; {if}
end;