TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
-
xsLiu
- Newbie
- Posts: 33
- Joined: Wed May 22, 2019 12:00 am
Post
by xsLiu » Wed Sep 09, 2020 12:16 pm
Although the following codes are used, Axis Labels of Increment, Minimum and Maximum values does not show a "rounded" value. What's the story?
Code: Select all
for i := 0 to aChart.Axes.Count - 1 do
begin
with Axes[i] do
begin
……
Automatic := true;
RoundFirstLabel := true;
MinimumRound := true;
MaximumRound := true;
……
end;
end;
-
Attachments
-
- AxisLabels.jpg (17.87 KiB) Viewed 11060 times
-
Yeray
- Site Admin
- Posts: 9617
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Thu Sep 10, 2020 2:03 pm
Hello,
I'm trying to reproduce the problem without success.
Could you please arrange a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.
-
xsLiu
- Newbie
- Posts: 33
- Joined: Wed May 22, 2019 12:00 am
Post
by xsLiu » Fri Sep 11, 2020 1:12 am
Got the problem. The reason is that the following code is used for TChart.Axes.
LabelsSeparation := 0;
So, TChartAxis skip calculating overlapping labels.
By default, Axis Labels are often too sparse. Is there a better way to mark Axis Labels as closely as possible? Except, LabelsSeparation := 1.
-
Yeray
- Site Admin
- Posts: 9617
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Tue Sep 15, 2020 6:58 am
Hello,
xsLiu wrote: ↑Fri Sep 11, 2020 1:12 am
Is there a better way to mark Axis Labels as closely as possible? Except, LabelsSeparation := 1.
I'm afraid the only alternative would be to manually populate the labels yourself. Ie:
Code: Select all
var lHeight: Integer;
curVal: Double;
dif: Double;
begin
Chart1.AddSeries(TPointSeries).FillSampleValues(10);
lHeight:=Chart1.Axes.Left.LabelHeight(Chart1[0].YValues.MaxValue);
Chart1.Draw;
dif:=Chart1.Axes.Left.CalcPosPoint(Chart1.Axes.Left.CalcPosValue(Chart1[0].YValues.MaxValue)+lHeight)-Chart1[0].YValues.MaxValue;
curVal:=Chart1[0].YValues.MaxValue;
Chart1.Axes.Left.Items.Clear;
while curVal>=Chart1[0].YValues.MinValue do
begin
Chart1.Axes.Left.Items.Add(curVal, FormatFloat('#.##0,##', curVal));
curVal:=curVal+dif;
end;
Chart1.Axes.Left.Items.Add(curVal, FormatFloat('#.##0,##', curVal));
end;