hi,
I want to reposition the marks on a horizontal bar chart, I tried setting the "Marks.Positions" property of THorizBarSeries, but it caused a side effect, the chart resizes in an unexpected way, it gets proportionally smaller as we resize it to a smaller size. I mean it starts using less and less of the available area for drawing the chart.
Any Ideas?
regards,
Milton
Custom marks positions for Horizontal bar charts
Hi Milton,
sorry for delay !.. a simple example to which reposition the Marks could be :
It center the Marks for a Stacked Bar Chart.
sorry for delay !.. a simple example to which reposition the Marks could be :
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
series1.FillSampleValues(5);
Series2.FillSampleValues(5);
Series3.FillSampleValues(5);
end;
procedure TForm1.PositionChartMarks(BarSeries: TBarSeries);
var
i: integer;
YPos: integer;
BarTop: integer;
BarBottom: integer;
XPos: integer;
MarkPos: TSeriesMarkPosition;
begin
MarkPos := TSeriesMarkPosition.Create;
try
for i := 0 to BarSeries.Count - 1 do begin
// just an example, you can do further customization here
MarkPos.Width := BarSeries.BarWidth;
MarkPos.Height := 16;
BarTop := BarSeries.CalcYPos(i); // get y screen pixel coordinate
BarBottom := BarSeries.CalcYPosValue(BarSeries.PointOrigin(i,false));
YPos := (BarTop + BarBottom - MarkPos.Height) div 2;
// Make sure that the value isn't painted below the X Axis
if YPos > (BarSeries.GetHorizAxis.PosAxis - (MarkPos.Height)) then begin
YPos := BarSeries.GetHorizAxis.PosAxis - (MarkPos.Height);
end;
XPos := BarSeries.CalcXPos(i);
MarkPos.Custom := True;
MarkPos.LeftTop.X := XPos;
MarkPos.LeftTop.Y := YPos;
BarSeries.Marks.Positions[i] := MarkPos;
end;
finally
MarkPos.Free;
end;
BarSeries.Repaint;
end;
procedure TForm1.Series1BeforeDrawValues(Sender: TObject);
begin
PositionChartMarks(Sender as TBarSeries);
end;
Pep Jorge
http://support.steema.com
http://support.steema.com