Situation: Chart with two series of kind TBarJoinSeries which are stacked 100%.
I want to display the value of each bar within the bar itself. Is that possible and how would I do this?
TeeChart is version 7.02 for Delphi 7.
Marks within Bars
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi sm,
Yes, one easy way of doing that is setting marks arrowlength to a negative value like in the example below:
Yes, one easy way of doing that is setting marks arrowlength to a negative value like in the example below:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
Chart1.AddSeries(TBarJoinSeries.Create(self));
Chart1.AddSeries(TBarJoinSeries.Create(self));
for i:=0 to Chart1.SeriesCount-1 do
With Chart1[i] do
begin
FillSampleValues();
Marks.Arrow.Visible:=false;
Marks.ArrowLength:=-50;
end;
(Chart1[0] as TBarJoinSeries).MultiBar:=mbStacked100;
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 |
Thanks! But I would still have to calculate the arrow length by myself if I I want to center the marks. Also a hardcoded value for ArrowLength would not work if the bars values can be very small (the mark would slip into another bar).narcis wrote:Hi sm,
Yes, one easy way of doing that is setting marks arrowlength to a negative value like in the example below:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject); var i: Integer; begin Chart1.AddSeries(TBarJoinSeries.Create(self)); Chart1.AddSeries(TBarJoinSeries.Create(self)); for i:=0 to Chart1.SeriesCount-1 do With Chart1[i] do begin FillSampleValues(); Marks.Arrow.Visible:=false; Marks.ArrowLength:=-50; end; (Chart1[0] as TBarJoinSeries).MultiBar:=mbStacked100; end;
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi sm,
Ok, you can play with series values positions in the chart, ChartRect settings, series marks positions, etc. Find an example below:
Ok, you can play with series values positions in the chart, ChartRect settings, series marks positions, etc. Find an example below:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
Chart1.AddSeries(TBarJoinSeries.Create(self));
Chart1.AddSeries(TBarJoinSeries.Create(self));
(Chart1[0] as TBarJoinSeries).MultiBar:=mbStacked100;
for i:=0 to Chart1.SeriesCount-1 do
Chart1[i].FillSampleValues();
Chart1.Draw;
CustomSeriesMarks;
end;
procedure TForm1.CustomSeriesMarks;
var
i,j: Integer;
APosition:TSeriesMarkPosition;
begin
APosition:=TSeriesMarkPosition.Create;
try
for j:=0 to Chart1.SeriesCount-1 do
for i:=0 to Chart1[j].Count-1 do
begin
APosition.Custom:=True;
APosition.LeftTop.X:=Chart1[j].Marks.Positions[i].LeftTop.X;
if (j=0) then
APosition.LeftTop.Y:=Chart1[j].CalcYPos(i) +
((Chart1[j+1].CalcYPos(i) -
Chart1[j].CalcYPos(i)) div 2)
else
APosition.LeftTop.Y:=Chart1[j].CalcYPos(i) +
((Chart1.ChartRect.Bottom -
Chart1[j].CalcYPos(i)) div 2);
Chart1[j].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 |