Recent

Author Topic: minimum interval [SOLVED]  (Read 593 times)

bbd666

  • New Member
  • *
  • Posts: 14
minimum interval [SOLVED]
« on: February 27, 2024, 03:43:25 pm »
Hi all,
How to set a minimum value for the bottomaxis interval ?
For instance I want my chart to display intervals no lower than 1.
Thks for any reply.
« Last Edit: February 28, 2024, 10:38:45 am by bbd666 »

wp

  • Hero Member
  • *****
  • Posts: 11912
Re: minimum interval
« Reply #1 on: February 27, 2024, 04:12:20 pm »
In Laz 3.0, the axis Intervals.Options have a new element, apiInteger. When you add this, only integer values will be allowed for axis labels.

bbd666

  • New Member
  • *
  • Posts: 14
Re: minimum interval
« Reply #2 on: February 27, 2024, 04:22:02 pm »
thks for your anwer
I'm using  Laz v2.2.4 :(
is it possible to upgrade with no loss in terms of configuation (packages and so on) ?

wp

  • Hero Member
  • *****
  • Posts: 11912
Re: minimum interval
« Reply #3 on: February 27, 2024, 04:47:10 pm »
Depending whether your Lazarus source files are in a directory to which you can write this can be easy - or difficult. I looked at the git changelog when this feature was introduced, and you can easily make the following changes (if you are allowed to modify the source files):
  • Go to folder components/tachart of your Lazarus installation
  • Open file taintervalsources.pas in the IDE or an external editor
  • Scroll down to the implementation of procedure TIntervalChartSource.CalculateIntervals
  • Add the following highlighted code between the lines "bestCount := 0" and "if aipUseNiceSteps in Params.Options"
Code: Pascal  [Select][+][-]
  1. var
  2.   minCount, maxCount, bestCount: Integer;
  3.   s, sv: Double;
  4. begin
  5.   CalcMinMaxCount(minCount, maxCount);
  6.   bestCount := 0;
  7.   if aipInteger in Params.Options then begin
  8.     ABestStart := Int(AParams.FMin);
  9.     ABestStep := 1.0;
  10.     bestCount := Round(AParams.FMax) - round(ABestStart);
  11.     if bestCount <= maxCount then
  12.       exit;
  13.   end;
  14.   if aipUseNiceSteps in Params.Options then begin
  15. [...]
  • Save
  • Now open the unit tacustomsource.pas.
  • Near the top there is the type declaration of TAxisIntervalParamOption.
  • Before the closing bracket, add aipInteger. The entire type declaration now should be
Code: Pascal  [Select][+][-]
  1. type
  2.   TAxisIntervalParamOption = (
  3.     aipGraphCoords,
  4.     aipUseCount, aipUseMaxLength, aipUseMinLength, aipUseNiceSteps,
  5.     aipInteger);
  • Save
  • Now recompile the IDE: In Lazarus, go to "Tools" > "Build Lazarus with profile ...". After a while the IDE restarts and you should be ready to go.
Since there is always a chance that I forgot something so that the patch cannot be compiled with your version absolutely make a backup copy of the to-be-changed files before starting.


bbd666

  • New Member
  • *
  • Posts: 14
Re: minimum interval
« Reply #4 on: February 27, 2024, 05:22:24 pm »
Great ! I'll try this.
Thks so much

bbd666

  • New Member
  • *
  • Posts: 14
Re: minimum interval
« Reply #5 on: February 28, 2024, 10:38:02 am »
That works fine !!!
Thank you very much, your instructions were crystal clear.

 

TinyPortal © 2005-2018