TLineSeries Marks Arrows go through callout.

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
ChuckHutchings
Newbie
Newbie
Posts: 9
Joined: Wed Jul 08, 2009 12:00 am

TLineSeries Marks Arrows go through callout.

Post by ChuckHutchings » Thu May 02, 2013 5:39 pm

If the callout is below the line series and the callout is transparent, the arrow is drawn up through the box/text to the line. Is there a property I'm missing to have the arrow originate at the top of the callout box?

(I'm using version 7.06. Yes. I know. It's a long story.)

Thanks,

Chuck

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TLineSeries Marks Arrows go through callout.

Post by Yeray » Fri May 03, 2013 3:05 pm

Hi Chuck,

I understand you have something like this, isn't it?

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;

  with Chart1.AddSeries(TPointSeries) do
  begin
    FillSampleValues(10);
    Marks.Visible:=true;
    Marks.Callout.Length:=-50;
    Marks.Arrow.Color:=clRed;
    Marks.Transparent:=true;
  end;
end;
test.png
test.png (18.68 KiB) Viewed 9480 times
In that case, what you could do is to manually set the marks ArrowTo.Y positions as in the following example:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
    tmpPos: TseriesMarkPosition;
begin
  Chart1.View3D:=false;

  with Chart1.AddSeries(TPointSeries) do
  begin
    FillSampleValues(10);
    Marks.Visible:=true;
    Marks.Callout.Length:=-50;
    Marks.Arrow.Color:=clRed;
    Marks.Transparent:=true;
  end;

  Chart1.Draw;

  with Chart1[0] as TPointSeries do
  begin
    for i:=0 to Count-1 do
    begin
      tmpPos:=Marks.Positions.Position[i];
      tmpPos.Custom:=true;
      tmpPos.ArrowTo.Y:=tmpPos.LeftTop.Y;
    end;
  end;
end;
test2.png
test2.png (17.81 KiB) Viewed 9470 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

ChuckHutchings
Newbie
Newbie
Posts: 9
Joined: Wed Jul 08, 2009 12:00 am

Re: TLineSeries Marks Arrows go through callout.

Post by ChuckHutchings » Fri May 03, 2013 4:46 pm

Yep. That's what I was looking for.

Thanks,
Chuck

ChuckHutchings
Newbie
Newbie
Posts: 9
Joined: Wed Jul 08, 2009 12:00 am

Re: TLineSeries Marks Arrows go through callout.

Post by ChuckHutchings » Tue May 14, 2013 7:16 pm

They decided to leave the labels opaque so I never verified the above fix. Now I have to do it for another reason and it's not working - I'm getting an exception.

In the onGetMarkText event I'm setting the arrow length and if I detect it's going below the line I have:

tmpPos := Sender.Marks.Positions.Position[ ValueIndex ];
tmpPos.Custom := True;
tmpPosArrowTo.Y := tmpPos.LeftTop.Y;

Unfortunately, tmpPos is nil.

(Note that I'm using a TLineSeries, not a TPointSeries.)

ChuckHutchings
Newbie
Newbie
Posts: 9
Joined: Wed Jul 08, 2009 12:00 am

Re: TLineSeries Marks Arrows go through callout.

Post by ChuckHutchings » Wed May 15, 2013 4:47 pm

Well, I figured out that the Positions haven't been created when onGetMarkText is called so I've moved the logic into the AfterDrawValues procedure. The code is executing without error and seems to be doing what I want but the arrow is still going to the bottom of the label.

ChuckHutchings
Newbie
Newbie
Posts: 9
Joined: Wed Jul 08, 2009 12:00 am

Re: TLineSeries Marks Arrows go through callout.

Post by ChuckHutchings » Wed May 15, 2013 7:17 pm

I copy/pasted your example code into my project and it doesn't work either. Is this maybe a bug in my version of TeeChart?

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TLineSeries Marks Arrows go through callout.

Post by Yeray » Thu May 16, 2013 4:13 pm

Hello,

What about this? I've made it with TeeChart v7 and Delphi 7.

Code: Select all

//...
  private
    { Private declarations }
    procedure CalcMarks;
//...
uses Series;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;

  with Chart1.AddSeries(TPointSeries) do
  begin
    FillSampleValues(10);
    Marks.Visible:=true;
    Marks.Callout.Length:=-50;
    Marks.Arrow.Color:=clRed;
    Marks.Transparent:=true;
  end;

  CalcMarks;
end;

procedure TForm1.CalcMarks;
var i: Integer;
    tmpPos: TseriesMarkPosition;
begin
  Chart1.Draw;

  with Chart1[0] as TPointSeries do
  begin
    for i:=0 to Count-1 do
    begin
      tmpPos:=Marks.Positions.Position[i];
      tmpPos.Custom:=true;
      tmpPos.ArrowFrom.X:=GetHorizAxis.CalcPosValue(XValues[i]);
      tmpPos.ArrowFrom.Y:=GetVertAxis.CalcPosValue(YValues[i]);
      tmpPos.ArrowTo.X:=tmpPos.ArrowFrom.X;
      tmpPos.ArrowTo.Y:=tmpPos.ArrowFrom.Y-Marks.Callout.Length-tmpPos.Height;
      tmpPos.LeftTop.X:=tmpPos.ArrowFrom.X-(tmpPos.Width div 2);
      tmpPos.LeftTop.Y:=tmpPos.ArrowTo.Y;
    end;
  end;
end;

procedure TForm1.Chart1Scroll(Sender: TObject);
begin
  CalcMarks;
end;

procedure TForm1.Chart1UndoZoom(Sender: TObject);
begin
  CalcMarks;
end;

procedure TForm1.Chart1Zoom(Sender: TObject);
begin
  CalcMarks;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

ChuckHutchings
Newbie
Newbie
Posts: 9
Joined: Wed Jul 08, 2009 12:00 am

Re: TLineSeries Marks Arrows go through callout.

Post by ChuckHutchings » Thu May 16, 2013 6:03 pm

Thanks, I finally figured it out - I had to make a final call to Chart.Draw after setting the Y value.

Post Reply