Measure axis size (inlc. title, labels, etc..)
Posted: Wed Jul 20, 2016 12:45 pm
Hi,
I am creating vertical axes in runtime and I would like to know how can I measure how much place one axis will take (including labels, title etc..)?
Now I use constant 70px (experimentaly defined) for each axis... and then setup Chart.MarginLeft = N * 70 where N is number of axes I create. However this is quite clumsy solution and I would like to make it more flexible because font size of title and axis labels can change and that affects overall axis width thus chart.MarginLeft.
My idea is to calculate Chart.MarginLeft according to all axes aligned each to other.
I attached two images. Width.png shows alignment for single axis and constant 70px of Chart.MarginLeft. Second picture aligned_axes.png shows two axes aligned left and they are aligned at same 70px spacing (relative to each other) which is not OK as you can see orange axis is overlapping title of purple one. So I would like o calculate the size to set up chart.LeftMargin properly so that axes will be positioned properly according to font size etc..
Just for the idea my code was:
But I always get less than 70px so I guess I am missing something here. Can you help me with that, please.
I am creating vertical axes in runtime and I would like to know how can I measure how much place one axis will take (including labels, title etc..)?
Now I use constant 70px (experimentaly defined) for each axis... and then setup Chart.MarginLeft = N * 70 where N is number of axes I create. However this is quite clumsy solution and I would like to make it more flexible because font size of title and axis labels can change and that affects overall axis width thus chart.MarginLeft.
My idea is to calculate Chart.MarginLeft according to all axes aligned each to other.
I attached two images. Width.png shows alignment for single axis and constant 70px of Chart.MarginLeft. Second picture aligned_axes.png shows two axes aligned left and they are aligned at same 70px spacing (relative to each other) which is not OK as you can see orange axis is overlapping title of purple one. So I would like o calculate the size to set up chart.LeftMargin properly so that axes will be positioned properly according to font size etc..
Just for the idea my code was:
Code: Select all
Result := Chart.CustomAxes[AxIdx].MaxLabelsWidth +
Chart.CustomAxes[AxIdx].TickLength +
Chart.CustomAxes[AxIdx].Shape.Height + 7; // height - because orientation is 90 deg... so height is basically width of 90 deg rotate title