Recent

Author Topic: [SOLVED] TAChart.AxisList[*].ForcedSize  (Read 930 times)

CM630

  • Hero Member
  • *****
  • Posts: 1700
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
[SOLVED] TAChart.AxisList[*].ForcedSize
« on: March 19, 2026, 02:41:24 pm »
Finally I have found a way to fix an issue that bothers me for more than ten years.
I added a property ForcedSize in TChartAxis (in tachartaxis.pas).
It is applied in procedure TChartAxis.Measure:

Code: Pascal  [Select][+][-]
  1.   with AMeasureData do begin
  2.     FSize := Max(sz, FSize);
  3.     if (ForcedSize < 0)
  4.       then FTitleSize := Max(TitleSize, FTitleSize)
  5.       else FTitleSize := FForcedSize;
  6.     FMargin := Max(Margin, FMargin);
  7.   end;

Now when ForcedSize ≥ 0 a custom size of the TitleLabel is used and together with some other settings the size of the chart does not depend on the content of the TAChart.AxisList[✱].Title.Caption.

A snippet is attached, the magic comes when the button is clicked.
« Last Edit: March 23, 2026, 04:46:49 pm by CM630 »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

wp

  • Hero Member
  • *****
  • Posts: 13578
Re: TAChart.AxisList[*].ForcedSize
« Reply #1 on: March 21, 2026, 12:59:20 am »
Good idea. Committed to Laz/main (https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/bffc6a53389d844cc5626c9b8aac8aecf3af96b6) with a few changes:
  • Made it a property of TAChartTitle (I think that's where it belongs to) and renamed it to "FixedSize".
  • Extended the wordwrap capabilities of the chart title so that wordwrap is active also in rotated directions when FixedSize is active (i.e. a long y axis title written horizontally is wrapped when FixedSize has some specific value).

CM630

  • Hero Member
  • *****
  • Posts: 1700
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: TAChart.AxisList[*].ForcedSize
« Reply #2 on: March 21, 2026, 09:22:13 am »
Thanks!
I submitted the property as Published(it was easier to test), but maybe just Public is fine.
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

wp

  • Hero Member
  • *****
  • Posts: 13578
Re: TAChart.AxisList[*].ForcedSize
« Reply #3 on: March 21, 2026, 10:55:29 am »
It should be changeable at designtime, just like TChartAxis.LabelSize - the published section is correct.

I updated the wiki documentation and the v5.0 release notes.

CM630

  • Hero Member
  • *****
  • Posts: 1700
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: TAChart.AxisList[*].ForcedSize
« Reply #4 on: March 23, 2026, 08:55:09 am »
I installed the update from GitLab.
What I noticed first is that the default value of FixedSize is zero, instead of -1.

Wiki says:

Quote
Axis titles
If the property TextFormat is switched to tfHTML then HTML entities and tags can be embedded for special formatting of axis titles, such as subscripts/superscripts or greek characters. See HTML for details.

In v4.99 and newer, property FixedSize, if greater than 0, reserves this amount of space for the title perpendicular to the axis direction (see sketch below). Together with Axis.LabelSize this allows for nicer alignment of multiple charts, independent of the count of title lines and the length of axis labels.

The property Wordwrap, if set to true, allows to wrap extra long axis titles into multiple lines. Note that when FixedSize is 0, this feature works only when the title is written parallel to the axis direction. Moreover, html-formatted text is not yet supported for word-wrapping.

This way, how can the user set FixedSize to 0?

Edit: Indeed, I can just set Title.Visible := False.

I also added a sample in the wiki.
« Last Edit: March 23, 2026, 11:19:06 am by CM630 »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

wp

  • Hero Member
  • *****
  • Posts: 13578
Re: TAChart.AxisList[*].ForcedSize
« Reply #5 on: March 23, 2026, 04:37:08 pm »
Yes, I was wondering what the purpose of Title.FixedSize should be. I selected the default value 0 (rather than -1) because TAChart has other size-related properties which are measured automatically when their value is 0.

 

TinyPortal © 2005-2018