Customizing legend values at runtime
Customizing legend values at runtime
I am graphing data which is stored as SI values in database tables (e.g. pressure in pascals - Pa). The data is plotted in SI, with axes adjusted to show user values (e.g. pressure in bar or atmosphere). However, the legend displays the values in underlying SI units. What is the best way to modify the legend values at runtime (In your tutorials you have a link to "Customising Legend content at runtime" but it seems to be broken.)
Re: Customizing legend values at runtime
Hello,
Wanting to show a set of values in two different units at the axes, marks or legend can be done by adding the values with the unit you want to show in the axis and with the other unit as Labels. Then you can set series' marks or legend to display values or labels. Ie:
I'm not sure if OnGetLegendText event will fit your requirements or not, but note you can find an online version of the documentation here. Direct link to the section you mention here.Errol wrote:I am graphing data which is stored as SI values in database tables (e.g. pressure in pascals - Pa). The data is plotted in SI, with axes adjusted to show user values (e.g. pressure in bar or atmosphere). However, the legend displays the values in underlying SI units. What is the best way to modify the legend values at runtime (In your tutorials you have a link to "Customising Legend content at runtime" but it seems to be broken.)
Wanting to show a set of values in two different units at the axes, marks or legend can be done by adding the values with the unit you want to show in the axis and with the other unit as Labels. Then you can set series' marks or legend to display values or labels. Ie:
Code: Select all
uses Series;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
v1, v2: double;
begin
with Chart1.AddSeries(TBarSeries) as TBarSeries do
begin
for i:=0 to 5 do
begin
v1:=25+random*75; //value in units A
v2:=v1*1000; //transform from units A to units B
Add(Round(v1), FormatFloat('#,##0.##', v2));
end;
Marks.Style:=smsLabel; //smsValue;
end;
Chart1.Legend.TextStyle:=ltsPlain; //ltsValue;
Chart1.Axes.Bottom.LabelStyle:=talValue;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |