Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Graphics and Multimedia
»
TAChart
(Moderator:
Ask
) »
BottomAxis Height
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
const declaration
by
Joanna from IRC
[
Today
at 06:17:28 am]
H2Pas can't handle EXP CA...
by
Thaddy
[
Today
at 06:09:54 am]
Nested declarations insid...
by
Thaddy
[
Today
at 06:00:28 am]
File operations blocking ...
by
atlatl
[
Today
at 01:12:50 am]
Hustle - A simple task ma...
by
Wesbat
[
Today
at 12:24:34 am]
FP crashes after running ...
by
Martin_fr
[
Today
at 12:15:57 am]
VGM Player
by
Gigatron2
[
Today
at 12:03:16 am]
TImage colors incorrect
by
Jonny
[January 14, 2025, 11:27:29 pm]
SDL2 image rotation Probl...
by
Fred vS
[January 14, 2025, 11:18:08 pm]
[SOLVED]Might have a menu...
by
Tony Stone
[January 14, 2025, 10:39:56 pm]
Troubles when converting ...
by
CM630
[January 14, 2025, 09:58:53 pm]
Batch "publish" of all pr...
by
n7800
[January 14, 2025, 09:39:08 pm]
/lib/x86_64-linux-gnu/lib...
by
DonAlfredo
[January 14, 2025, 09:00:28 pm]
SDL2: Runtime Error 216 o...
by
mischi
[January 14, 2025, 08:05:51 pm]
Iterator on non-existing ...
by
TRon
[January 14, 2025, 07:55:00 pm]
how to find application r...
by
bytebites
[January 14, 2025, 07:49:23 pm]
Out of memory / filter tw...
by
Thaddy
[January 14, 2025, 07:23:20 pm]
test if web site is valid
by
Thaddy
[January 14, 2025, 06:51:18 pm]
Quantize a PNG with TBgra...
by
circular
[January 14, 2025, 05:54:45 pm]
[SOLVED] Highlight commen...
by
artem101
[January 14, 2025, 05:19:04 pm]
Lazarus Release 3.6
by
Fred vS
[January 14, 2025, 03:23:01 pm]
CADSys4 3D.
by
mdadali
[January 14, 2025, 02:53:57 pm]
Color Buttons
by
lainz
[January 14, 2025, 01:04:56 pm]
Repository mirror and Ind...
by
Marc
[January 14, 2025, 12:27:48 pm]
Fpc Updates
by
loaded
[January 14, 2025, 12:19:36 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: BottomAxis Height (Read 1100 times)
kapibara
Hero Member
Posts: 629
BottomAxis Height
«
on:
December 10, 2023, 08:46:39 am »
Is it possible to get the height of a BottomAxis?
The idea is to show BottomAxis only for the bottom pane and not for panes above it. The
Axis height would be used to adjust the height of the panes so the chart in the bottom-most pane doesn't appear smaller than the others because the axis takes up some of the graphs space.
Logged
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit
kapibara
Hero Member
Posts: 629
Re: BottomAxis Height
«
Reply #1 on:
December 12, 2023, 12:15:00 am »
Finding the size of the chart area (where series are plotted, excluding axises and margins) would also work.
TChartAxis and TChartAxisList has a public method named Measure, could that be used to find heights of parts of the chart?
Logged
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit
wp
Hero Member
Posts: 12515
Re: BottomAxis Height
«
Reply #2 on:
December 12, 2023, 12:57:38 am »
You could use the Chart's ClipRect to determine the "plot area" (rectangle enclosed by the axes); however, it can change its value depending on context. I think it is a bit safer to query the chart's CurrentExtent and to convert the two corner points to image coordinates:
Code: Pascal
[Select]
[+]
[-]
function
CalcPlotArea
(
AChart
:
TChart
)
:
TRect
;
var
ext
:
TDoubleRect
;
// requries unit TAChartUtils;
P1
,
P2
:
TPoint
;
begin
ext
:
=
AChart
.
CurrentExtent
;
P1
:
=
AChart
.
GraphToImage
(
ext
.
a
)
;
// left/bottom corner
P2
:
=
AChart
.
GraphToImage
(
ext
.
b
)
;
// right/top corner
Result
:
=
Rect
(
P1
.
X
,
P2
.
Y
,
P2
.
X
,
P1
.
Y
)
;
end
;
But note that this calculation is only successful after the chart has been painted.
Logged
kapibara
Hero Member
Posts: 629
Re: BottomAxis Height
«
Reply #3 on:
December 12, 2023, 06:37:21 am »
Seems to work, thanks! Like you warned, I had to add Application.ProcessMessages before calling CalcPlotArea to avoid EChartError, "scaling not yet initialized".
Logged
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Graphics and Multimedia
»
TAChart
(Moderator:
Ask
) »
BottomAxis Height
TinyPortal
© 2005-2018