Page 1 of 1

Value Labels

Posted: Mon Jan 31, 2011 5:00 pm
by 16556556
Good morning,
I have the following problem with the value labels.
1 - LegendActive.JPG
1 - Legend Active.
1 - LegendActive.JPG (116 KiB) Viewed 1862 times
2 - LegendInactive.JPG
Legend inactive and Changing Position of the Label Value.
2 - LegendInactive.JPG (121.28 KiB) Viewed 1851 times
3 - ActivatingLegendAgain.JPG
3 - Activating legend again.
3 - ActivatingLegendAgain.JPG (117.29 KiB) Viewed 1858 times
await solution, thanks.

Re: Value Labels

Posted: Wed Feb 02, 2011 12:52 pm
by yeray
Hi José,

As the mark has been moved, it has to be recalculated if the chart changes. You could call a method like following when the legend visibility changes:

Code: Select all

procedure TForm1.RecalcMarks;
var i, tmpx, dx: Integer;
    pos: TSeriesMarkPosition;
begin
  for i:=0 to Chart1[0].Count-1 do
  begin
    tmpx:=Chart1[0].CalcXPos(i) + (Chart1[0] as TBarSeries).BarWidth div 2;

    pos:=Chart1[0].Marks.Positions[i];
    if (tmpx <> pos.ArrowFrom.X) then
    begin
      dx:=pos.ArrowTo.X - pos.ArrowFrom.X;
      pos.ArrowFrom.X:=tmpx;
      pos.ArrowTo.X:=tmpx + dx;
      pos.LeftTop.X:=tmpx + dx - (pos.Width div 2);
    end;
  end;

  Chart1.Repaint;
end;