Hi,
I'm tryng to define manually the marks position in my chart ( TBarSeries ). I'm having troubles when I do a horizontal scrolling in the chart. The marks don't 'scroll' with the bars. This is the code :
procedure TfSGEIS_SHOW.ChartAfterDraw(Sender: TObject);
Var i,j:Integer;
lAlterna : Boolean;
begin
lAlterna := False;
if true then //just testing
begin
For i:= 0 to Chart.SeriesCount-1 do
begin
If Chart.Series.Marks.Positions[0] <> Nil then
begin
For j:=0 To Chart.Series.Marks.Positions.Count-1 do
begin
With Chart.Series.Marks.Positions[j] do
begin
Custom:=true;
If lAlterna then
LeftTop.Y:= LeftTop.Y + 10
else
LeftTop.Y:= LeftTop.Y - 10
end
lAlterna := Not lAlterna;
end;
end
end;
lFirst := True;
Chart.Refresh;
end
end;
What can I do to solve this ?
Regards
Marcelo ( Brazil )
Marks plus Scroll
Hi Marcelo,
you can use similar code to the following :
you can use similar code to the following :
Code: Select all
procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
DoAlignMarks(Series1);
end;
procedure TForm1.DoAlignMarks(Series: TBarSeries);
var sx, sy : integer;
i : integer;
begin
for i:=0 to Series.Count-1 do
begin
sx := Series.CalcXPos(i);
sy := Series.CalcYPos(i);
With Series.Marks.Positions.Position[i] do
Begin
Custom:=True;
LeftTop.x := sx;
LeftTop.y := sy - 12;
end;
end;
Series.Repaint;
end;
Pep Jorge
http://support.steema.com
http://support.steema.com
Thanks Pep, your code solve my problem , but I didn't get move the arrows. What I need to do ? It's possible to hide those arrows ?
tks.
Marcelo
tks.
Marcelo
Pep wrote:Hi Marcelo,
you can use similar code to the following :Code: Select all
procedure TForm1.Chart1AfterDraw(Sender: TObject); begin DoAlignMarks(Series1); end; procedure TForm1.DoAlignMarks(Series: TBarSeries); var sx, sy : integer; i : integer; begin for i:=0 to Series.Count-1 do begin sx := Series.CalcXPos(i); sy := Series.CalcYPos(i); With Series.Marks.Positions.Position[i] do Begin Custom:=True; LeftTop.x := sx; LeftTop.y := sy - 12; end; end; Series.Repaint; end;
Hi Marcelo,
yes, you can hide them using :
Series.Marks.Arrow.Hide;
or set the ArrowFrom and ArrowTo values.
yes, you can hide them using :
Series.Marks.Arrow.Hide;
or set the ArrowFrom and ArrowTo values.
Pep Jorge
http://support.steema.com
http://support.steema.com
Hi PepPep wrote:Hi Marcelo,
yes, you can hide them using :
Series.Marks.Arrow.Hide;
or set the ArrowFrom and ArrowTo values.
It's worked. Thanks.
One more question : In code below, I have to call the Chart.refresh method to new marks positions work. Only using the Repaint didn't work.
But when I use the Refresh method in Windows 98 workstations, a GPF happens (Stack Overflow). What can I do ?
Code: Select all
procedure TfSGEIS_SHOW.ChartAfterDraw(Sender: TObject);
Var i:Integer;
lAlterna,lAlternaOld : Boolean;
begin
For i:= 0 to Chart.SeriesCount-1 do
begin
DoAlignMarks(TBarSeries(Chart.Series[i]),lAlterna);
lAlterna := Not lAlterna
end;
Chart.Refresh;
end;
procedure TfSGEIS_SHOW.DoAlignMarks(Series: TBarSeries;var lAlterna : Boolean);
var sx, sy : integer;
i : integer;
begin
if (Series.ClassName <> 'TBarSeries') or (Series.MultiBar = mbStacked) or (Series.MultiBar = mbStacked100) then
Exit;
for i:=0 to Series.Count-1 do
begin
sx := Series.CalcXPos(i);
sy := Series.CalcYPos(i);
With Series.Marks.Positions.Position[i] do
If (Series.Marks.Positions.Position[i] <> nil) then
Begin
try
Series.Marks.Arrow.Visible := True;
Custom:=True;
Series.Marks.Arrow.Color := clBlack;
ArrowFrom.x := sx+12;
ArrowFrom.y := sy;
ArrowTo.x := ArrowFrom.x;
LeftTop.x := sx;
If lAlterna then
begin
LeftTop.Y:= sy - 35;
ArrowTo.y := sy-22;
end
else
begin
LeftTop.Y:= sy - 20;
ArrowTo.y := sy-10;
end
except
end;
end
else
Break;
end;
Series.Repaint;
end;
Hi Marcelo,
it should work without the Refresh, also it's not a good place to run it. Better to place it in hte DoAlignMarks procedure. How can I reproduce what the results you're getting ? Could you please post a simple example in the steema.public.attachments newsgroup so I can see what you refer ?
it should work without the Refresh, also it's not a good place to run it. Better to place it in hte DoAlignMarks procedure. How can I reproduce what the results you're getting ? Could you please post a simple example in the steema.public.attachments newsgroup so I can see what you refer ?
Pep Jorge
http://support.steema.com
http://support.steema.com