Hey guys,
I 'm using teechart 7 vcl for my project. I noticed that on stack bar charts I made, if i have multiple series, the marks of previous series are always overlapped and hidden by the bars of next series. Any thoughts on that?
thanks!
Default mark position of stack bar charts
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Frank,
You can reposition the marks by doing something like this:
You can reposition the marks by doing something like this:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
for i:=0 to Chart1.SeriesCount-1 do
begin
Chart1[i].FillSampleValues();
Chart1[i].Marks.ArrowLength:=-30;
Chart1[i].Marks.Arrow.Visible:=false;
end;
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Thank you for the quick reply, Narcis.
However, i see another issue with stack bar charts. What if i want to display the marks in the middle of bars? Do i have to find out the length of bar first and then specifiy the arrowlength base on that? If that's the case i guess i need to specify different arrowlengths for marks that in the same series, am i right?
However, i see another issue with stack bar charts. What if i want to display the marks in the middle of bars? Do i have to find out the length of bar first and then specifiy the arrowlength base on that? If that's the case i guess i need to specify different arrowlengths for marks that in the same series, am i right?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Frank,
Yes, or you can also use custom marks as shown here:
Yes, or you can also use custom marks as shown here:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
APosition:TSeriesMarkPosition;
begin
Series1.FillSampleValues();
Chart1.Draw();
APosition:=TSeriesMarkPosition.Create;
try
for i:=0 to Series1.Count-1 do
begin
APosition.Custom:=True;
APosition.LeftTop.X:=Series1.Marks.Positions[i].LeftTop.X;
APosition.LeftTop.Y:=Series1.Marks.Positions[i].LeftTop.Y-35;
Series1.Marks.Positions[i]:=APosition;
end;
finally
APosition.Free;
end;
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi Frank,
yes, you can check where a specified point (bar) starts and ends using the code below. This example shows how to position Marks in the middle of each stacked Bar Series :
yes, you can check where a specified point (bar) starts and ends using the code below. This example shows how to position Marks in the middle of each stacked Bar Series :
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;
end.
Pep Jorge
http://support.steema.com
http://support.steema.com