Recent

Author Topic: Chart.LeftAxis.LabelSize and Chart.BottomAxis.LabelSize return zeroes  (Read 3445 times)

CM630

  • Hero Member
  • *****
  • Posts: 1195
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
It occurs that Chart.LeftAxis.LabelSize and Chart.BottomAxis.LabelSize return nothing but zero.
In https://wiki.freepascal.org/TAChart_documentation#Graphical_explanation there is 5 - Chart1.LabelSize, but I guess there is a mistake there and it should be Chart1.xxxAxis.LabelSize, since it does not make sense to have only one value for both axises, and indeed there is no Chart1.LabelSize property.
Is there a bug or am I doing something wrong?


(a snippet is attached)


Edit: I did some fiddling.
It occurs that Chart1.xxxAxis.LabelSize is not what is displayed on the figure with 5.
LabelSize is a statically set value, which is 0 by default. When it is zero the label and the scale are not overlapped.
When Chart1.xxxAxis.LabelSize > 0 the axises get overlapped (higher value results in higher overlapping).
So I need some other parameter.

Chart1.xxxAxis.Marks.GetTextRect. Top, Bottom, etc. also return nothing but zeroes.
« Last Edit: April 26, 2024, 10:32:06 am by CM630 »
Лазар 4,0RC1 32 bit (sometimes 64 bit); FPC3,2,2

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: Chart.LeftAxis.LabelSize and Chart.BottomAxis.LabelSize return zeroes
« Reply #1 on: April 26, 2024, 11:57:30 am »
You are right: A property "Chart1.LabelSize" does not exist, it is "Chart1.XXXAxis.LabelSize". Fixed the typo in the wiki, https://wiki.freepascal.org/TAChart_documentation#Graphical_explanation.

LabelSize is not a function which returns the size of the axis labels, but a property to define the space reserved for the labels: https://wiki.freepascal.org/TAChart_documentation#Axis_LabelSize. When LabelSize is 0 the size is auto-calculated. This is sufficient in most cases. Only when there are several charts, maybe stacked vertically above each other, you want to make sure that the left axes of these charts are always at the same place. In this case you can set the LabelSize of the LeftAxes to the width of the longest axis label.

There is an extension to the TChartLink property which does exactly this: property AlignSides - https://wiki.freepascal.org/TAChart_documentation#Linked_extents
« Last Edit: April 26, 2024, 12:17:03 pm by wp »

CM630

  • Hero Member
  • *****
  • Posts: 1195
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Chart.LeftAxis.LabelSize and Chart.BottomAxis.LabelSize return zeroes
« Reply #2 on: April 29, 2024, 09:11:55 am »
I want to overlap a memo over the bottom axis title, but I do not know how to find out the top of the memo (i.e. where is the bottom of the marks)(the last screenshot bottom axis title.png).

...There is an extension to the TChartLink property which does exactly this: property AlignSides - https://wiki.freepascal.org/TAChart_documentation#Linked_extents
This seems to solve my most insolvable issue with TaChart!  :P

But there seems to be something wrong when one of the titles contains no lines or Title.Visible = False, in other cases it seems just fine.
There are some more screenshots in the attachment with the snippet.
« Last Edit: April 29, 2024, 11:00:14 am by CM630 »
Лазар 4,0RC1 32 bit (sometimes 64 bit); FPC3,2,2

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: Chart.LeftAxis.LabelSize and Chart.BottomAxis.LabelSize return zeroes
« Reply #3 on: April 29, 2024, 12:34:15 pm »
I want to overlap a memo over the bottom axis title, but I do not know how to find out the top of the memo (i.e. where is the bottom of the marks)(the last screenshot bottom axis title.png).
Provided access to the polygon used for filling the axis title box in Laz/main: property TChartAxis.TitlePolygon. This should help you.

But there seems to be something wrong when one of the titles contains no lines or Title.Visible = False, in other cases it seems just fine.
I think I found it. Should be fixed in Laz/main.

CM630

  • Hero Member
  • *****
  • Posts: 1195
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Chart.LeftAxis.LabelSize and Chart.BottomAxis.LabelSize return zeroes
« Reply #4 on: April 30, 2024, 08:55:21 am »
TitlePolygon looks fine. Maybe, since you have started, if there is MarksPolygon, you could make it visible, too, in case that this info becomes necessary.

However, there seem to be some issues with the alignment.
I have updated the snippet. When I set the spinedit to 5 something is wrong.
Also, maybe ClipRect is wrong when spinedit is set to 6.
Лазар 4,0RC1 32 bit (sometimes 64 bit); FPC3,2,2

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: Chart.LeftAxis.LabelSize and Chart.BottomAxis.LabelSize return zeroes
« Reply #5 on: April 30, 2024, 10:54:49 pm »
Another try in Laz/main... It addresses the cases when an axis title is empty and/or hidden, when Axis.Title.Attachment = maCenter, and when different Axis.Title.Distance values are used.

As for the inconsistent ClipRect: Like any other dimensions and quantities, ClipRect is determined during painting. You must make sure that the chart has been redrawn immediately before you access ClipRect. If you want to buffer ClipRect, the best place to catch it is in the OnAfterPaint event of the chart:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Chart1AfterPaint(ASender: TChart);
  2. begin
  3.   Label1.Caption := 'Chart1.ClipRect.Left = ' + IntToStr(Chart1.ClipRect.Left);
  4. end;
  5.  
  6. procedure TForm1.Chart2AfterPaint(ASender: TChart);
  7. begin
  8.   Label2.Caption := 'Chart2.ClipRect.Left = ' + IntToStr(Chart2.ClipRect.Left);
  9. end;

CM630

  • Hero Member
  • *****
  • Posts: 1195
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Thanks, it seems to work properly now!
Лазар 4,0RC1 32 bit (sometimes 64 bit); FPC3,2,2

CM630

  • Hero Member
  • *****
  • Posts: 1195
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Just wondering, is there a schedule when these changes will be availabe in a offical build?
I have installed Lazarus 3.4, they are not there.
Лазар 4,0RC1 32 bit (sometimes 64 bit); FPC3,2,2

wp

  • Hero Member
  • *****
  • Posts: 12459
Just wondering, is there a schedule when these changes will be availabe in a offical build?
I have installed Lazarus 3.4, they are not there.
What do you mean? The test project "align_axes" in reply #1 compiles and runs fine with Laz 3.4.

CM630

  • Hero Member
  • *****
  • Posts: 1195
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
That is what I get, I will try on another PC and feedback:


EDIT: I tried on another PC, it is the same, the TitlePolygon property is missing (see the second screenshot):
« Last Edit: June 04, 2024, 07:48:50 am by CM630 »
Лазар 4,0RC1 32 bit (sometimes 64 bit); FPC3,2,2

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: Chart.LeftAxis.LabelSize and Chart.BottomAxis.LabelSize return zeroes
« Reply #10 on: June 04, 2024, 10:11:55 am »
Ah, TitlePolygon... This was committed on April 29, 2024, but Laz 3.0 had its first release candidate on July 03, 2023. All the following releases (v3.2, v3.4) have been bugfixes, while the TitlePolygon is a new feature and must wait for the next major release, v.4.0.

 

TinyPortal © 2005-2018