TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
-
Test Always
- Newbie

- Posts: 16
- Joined: Mon Dec 05, 2016 12:00 am
Post
by Test Always » Wed May 17, 2017 10:28 pm
In a chart I am creating I have labels that are put with some descriptive text at the bottom of a chart:
The problem is when I make the chart just a little narrower, even though there is plenty of room, a label gets dropped (notice the label under the 4th bar).
Is there any way to modify the margin each label requires? I need to have the labels display.
Ed Dressel
-
Yeray
- Site Admin

- Posts: 9644
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Thu May 18, 2017 10:06 am
Hello Ed,
I've tried to reproduce the problem with the following code and TeeChart v2017.21 but it seems to work fine for me here:
Code: Select all
uses Series;
const
initialBenefit : array[0..3] of double = (5336,6226,7204,8271);
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Align:=alClient;
Chart1.View3D:=False;
Chart1.Legend.Visible:=False;
Chart1.Walls.Visible:=False;
Chart1.Gradient.Visible:=False;
Chart1.Color:=clWhite;
Chart1.Title.Visible:=False;
Chart1.MarginTop:=5;
Chart1.MarginLeft:=5;
Chart1.Axes.Left.Increment:=1000;
Chart1.Axes.Left.Ticks.Visible:=False;
Chart1.Axes.Left.MinorTicks.Visible:=False;
Chart1.Axes.Left.Grid.Style:=psDot;
Chart1.Axes.Left.Title.Text:='Additional Monthly Savings'+sLineBreak+'Needed to Account for Shortfall';
Chart1.Axes.Left.Title.Font.Color:=clBlue;
Chart1.Axes.Left.Title.Font.Style:=[fsBold];
Chart1.Axes.Bottom.Ticks.Visible:=False;
Chart1.Axes.Bottom.MinorTicks.Visible:=False;
Chart1.Axes.Bottom.Grid.Visible:=False;
with Chart1.AddSeries(TBarSeries) as TBarSeries do
begin
Color:=RGB(83,138,175);
Pen.Visible:=False;
Marks.Color:=RGB(211,228,236);
AddBar(3878, 'Age 64', clTeeColor);
AddBar(3880, 'Age 66', clTeeColor);
AddBar(3913, 'Age 68', clTeeColor);
AddBar(3978, 'Age 70', clTeeColor);
OnGetMarkText:=SeriesGetMarkText;
end;
Self.Width:=530;
Self.Height:=350;
end;
procedure TForm1.SeriesGetMarkText(Sender: TChartSeries; ValueIndex: Integer; var MarkText: String);
begin
if Assigned(Sender) and (ValueIndex>-1) and (ValueIndex<Sender.Count) then
MarkText:=MarkText+sLineBreak+FormatFloat('$#,##0.##',Sender.YValue[ValueIndex]);
end;
procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
begin
if (Sender=Chart1.Axes.Bottom) and (ValueIndex>-1) and (ValueIndex<SizeOf(initialBenefit)) then
LabelText:='Initial Benefit:'+sLineBreak+FormatFloat('$#,##0.##',initialBenefit[ValueIndex]);
end;
-
Attachments
-

- labels_overlap.png (11.99 KiB) Viewed 7029 times