I've a stacked bar and want to print a TSeriesMarkPosition from one stack over *another* stack. The problem is that the TSeriesMarkPosition is printed *behind* the stack. Is there a way to say that the TSeriesMarkPosition should be printed in front of *any* stacks?
Thanks in advance
Pascal
Bring TSeriesMarkPosition to front
-
- Newbie
- Posts: 10
- Joined: Thu Nov 06, 2003 5:00 am
- Location: Switzerland
- Contact:
Hi Pascal,
could you please attach the code that you are using to reproduce the problem ?
Josep Lluis Jorge
http://support.steema.com
could you please attach the code that you are using to reproduce the problem ?
Josep Lluis Jorge
http://support.steema.com
-
- Newbie
- Posts: 10
- Joined: Thu Nov 06, 2003 5:00 am
- Location: Switzerland
- Contact:
Sure:Pep wrote: could you please attach the code that you are using to reproduce the problem ?
Code: Select all
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
if BarSeries.UseYOrigin then BarBottom := BarSeries.CalcYPosValue(0.0)
else BarBottom := BarSeries.GetHorizAxis.PosAxis;
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.SeriesBeforeDrawValues(Sender: TObject);
begin
PositionChartMarks(Sender as TBarSeries);
end;
I'm sorry, I cannot reproduce the problem here using the code I post in y other reply. How are you stack the bars ? Getting the results as in the following image I am able to print the Chart and see all the Marks in front of the Bars :
[img]
http://80.32.235.114/hola/stack.jpg
[/img]
Josep Lluis Jorge
http://support.steema.com
[img]
http://80.32.235.114/hola/stack.jpg
[/img]
Josep Lluis Jorge
http://support.steema.com
-
- Newbie
- Posts: 10
- Joined: Thu Nov 06, 2003 5:00 am
- Location: Switzerland
- Contact:
Here is some example code that you can use to create the bars:Pep wrote: I'm sorry, I cannot reproduce the problem here using the code
Code: Select all
function CreateSeries(aTitle: string; aColor: TColor): TBarSeries;
begin
Result := TBarSeries.Create(Chart);
with Result do begin
ParentChart := Chart;
Title := aTitle;
MultiBar := mbStacked;
SeriesColor := aColor;
Marks.Style := smsValue;
Marks.Frame.Visible := False;
Marks.Transparent := True;
Marks.ShadowSize := 0;
Marks.Arrow.Visible := False;
AutoMarkPosition := True;
BeforeDrawValues := SeriesBeforeDrawValues;
end;
end;
with Chart do begin
Title.Visible := False;
BevelInner := bvNone;
BevelOuter := bvNone;
Color := clWhite;
View3D := False;
Legend.Alignment := laBottom;
Legend.ShadowSize := 0;
Legend.Frame.Visible := False;
BottomAxis.Grid.Visible := False;
end;
Chart.RemoveAllSeries;
with CreateSeries('First Series', clBlue) do begin
AddXY(0, 27, 'First Item', clTeeColor);
AddXY(1, 118, 'Second Item', clTeeColor);
AddXY(2, 95, 'Third Item', clTeeColor);
AddXY(3, 0, 'Fourth Item', clTeeColor);
end;
with CreateSeries('Second Series', clGreen) do begin
AddXY(0, 58, 'First Item', clTeeColor);
AddXY(1, 13, 'Second Item', clTeeColor);
AddXY(2, 26, 'Third Item', clTeeColor);
AddXY(3, 100, 'Fourth Item', clTeeColor);
end;
I get a timeout error when I try to view the image
I could you also send an example application, but I wasn't able to find your email address.
>Now, the 0 in the "Fourth Item" is hidden behind the "Fourth Item" Bar of the "Second Series" bar.
Yes, I see the problem now. It's a known defect (the labels are hidden in 2D mode, it works fine using 3D), if's already added on our defect list and a fix for it will be considered to inclusion for the next releases.
In meantime a solution could be to change the marks position manually for the Marks which need to get a part of the other stacked series.
Josep Lluis Jorge
http://support.steema.com
Yes, I see the problem now. It's a known defect (the labels are hidden in 2D mode, it works fine using 3D), if's already added on our defect list and a fix for it will be considered to inclusion for the next releases.
In meantime a solution could be to change the marks position manually for the Marks which need to get a part of the other stacked series.
Josep Lluis Jorge
http://support.steema.com
>This also occurs with other type series in 2d mode. So, how to fix?
I think the best way around is to do the same as I told you, set the marks position manually for the hidden marks.
Josep Lluis Jorge
http://support.steema.com
I think the best way around is to do the same as I told you, set the marks position manually for the hidden marks.
Josep Lluis Jorge
http://support.steema.com