Bar Chart vertical self-stacked title position
Posted: Wed Dec 07, 2022 4:05 am
Good afternoon
I have a persistent problem with placing a title above self-stacked bar charts. My code works correctly if the bottom axis has specified scaling, but not if the scaling is automatic. The (edited) procedure I use is shown below.
The PlaceWellNames procedure is called in ChartBeforeDrawSeries, ChartAfterDraw as well as Zoom, UndoZoom and ChartScroll.
Thanks and regards
Errol
I have a persistent problem with placing a title above self-stacked bar charts. My code works correctly if the bottom axis has specified scaling, but not if the scaling is automatic. The (edited) procedure I use is shown below.
Code: Select all
procedure TPBQuickGraph.PlaceWellNames;
var
h, LLeft, LWidth, LHeight: integer;
LAcross: integer;
LRect: TRect;
for h := 1 to fIntervalQueryCollection.SeriesListB.Count - 1 do
begin
with (Chart.Tools[h] as TAnnotationTool) do
begin
Shape.CustomPosition := true;
Shape.Pen.Color := clWhite;
Shape.Transparent := true;
Shape.Font.Size := fBarNameFont;
Shape.Font.Style := Shape.Font.Style + [fsBold];
Shape.Angle := fBarNameDir;
PositionUnits := muPixels;
Text := aWellName[h];
// centre of bar, I think
LLeft := TUnitBarSeries(fIntervalQueryCollection.SeriesListB.Objects[h]).CalcXPos(0);
LWidth := Width; // width of shape??
LAcross := LWidth div 2 // half title width
if Chart.BottomAxis.Automatic then
begin
Left := LLeft - LAcross + fBarWidth Div 2; // this sort of works but varies according to bar width
end
else
Left := LLeft - LAcross; // this is correct for non-automatic scaling
end;
end;
Thanks and regards
Errol