Bring TSeriesMarkPosition to front

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Timeware AG
Newbie
Newbie
Posts: 10
Joined: Thu Nov 06, 2003 5:00 am
Location: Switzerland
Contact:

Bring TSeriesMarkPosition to front

Post by Timeware AG » Mon Nov 24, 2003 3:30 pm

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

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Nov 25, 2003 8:38 pm

Hi Pascal,

could you please attach the code that you are using to reproduce the problem ?

Josep Lluis Jorge
http://support.steema.com

Timeware AG
Newbie
Newbie
Posts: 10
Joined: Thu Nov 06, 2003 5:00 am
Location: Switzerland
Contact:

Post by Timeware AG » Wed Nov 26, 2003 9:36 am

Pep wrote: could you please attach the code that you are using to reproduce the problem ?
Sure:

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;

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Nov 26, 2003 11:37 am

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

Timeware AG
Newbie
Newbie
Posts: 10
Joined: Thu Nov 06, 2003 5:00 am
Location: Switzerland
Contact:

Post by Timeware AG » Wed Nov 26, 2003 1:24 pm

Pep wrote: I'm sorry, I cannot reproduce the problem here using the code
Here is some example code that you can use to create the bars:

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;
Now, the 0 in the "Fourth Item" is hidden behind the "Fourth Item" Bar of the "Second Series" bar.
Pep wrote: [img]
http://80.32.235.114/hola/stack.jpg
[/img]
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.

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Nov 27, 2003 11:51 am

>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

Jim
Newbie
Newbie
Posts: 8
Joined: Fri Nov 15, 2002 12:00 am

Post by Jim » Sat Dec 06, 2003 5:33 pm

Hi,

>>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. <<

This also occurs with other type series in 2d mode. So, how to fix?

Thanks

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Dec 09, 2003 12:20 pm

>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

Post Reply