Page 1 of 1

TLineSeries Marks Arrows go through callout.

Posted: Thu May 02, 2013 5:39 pm
by 10553871
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

Re: TLineSeries Marks Arrows go through callout.

Posted: Fri May 03, 2013 3:05 pm
by yeray
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 9482 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 9472 times

Re: TLineSeries Marks Arrows go through callout.

Posted: Fri May 03, 2013 4:46 pm
by 10553871
Yep. That's what I was looking for.

Thanks,
Chuck

Re: TLineSeries Marks Arrows go through callout.

Posted: Tue May 14, 2013 7:16 pm
by 10553871
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.)

Re: TLineSeries Marks Arrows go through callout.

Posted: Wed May 15, 2013 4:47 pm
by 10553871
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.

Re: TLineSeries Marks Arrows go through callout.

Posted: Wed May 15, 2013 7:17 pm
by 10553871
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?

Re: TLineSeries Marks Arrows go through callout.

Posted: Thu May 16, 2013 4:13 pm
by yeray
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;

Re: TLineSeries Marks Arrows go through callout.

Posted: Thu May 16, 2013 6:03 pm
by 10553871
Thanks, I finally figured it out - I had to make a final call to Chart.Draw after setting the Y value.