Problem with moving Marks
Posted: Wed Nov 29, 2006 11:16 pm
Delphi 6 Enterprise, TeeChart 7.07
I have been asked to provide a way for the users to control where the Marks are displayed on a chart. I checked through the forum and found the following link: http://www.teechart.net/support/viewtopic.php?t=2230 offered as advice on doing this. Unfortunately, I seem to have missed something because once the marks start to move, the display becomes very eratic. The following is my code:
From what I understand, this should simply move the marks UP 35 pixels each time my Button1 is clicked.
Before the button is clicked, my chart looks like:
Normal enough. However, when I click the button the chart becomes:
Kind of a disaster. For some reason,
This time, the marks DID move up 35 pixels, as I originally expected. If I keep clicking the button, the marks will now keep moving up until they leave the screen.
But I have to ask, WHY did all the rest of those items happen? Even if the marks themselves did not move to the correct locations, shouldn't the line that was associated with them have moved WITH THEM to their new location?
I have been asked to provide a way for the users to control where the Marks are displayed on a chart. I checked through the forum and found the following link: http://www.teechart.net/support/viewtopic.php?t=2230 offered as advice on doing this. Unfortunately, I seem to have missed something because once the marks start to move, the display becomes very eratic. The following is my code:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
APosition:TSeriesMarkPosition;
begin
APosition:=TSeriesMarkPosition.Create;
with Chart1 do
try
for i:=0 to Series1.Count-1 do
begin
APosition.Custom:=True;
APosition.LeftTop.X:=Series1.Marks.Positions[i].LeftTop.X;
APosition.LeftTop.Y:=Series1.Marks.Positions[i].LeftTop.Y-35;
Series1.Marks.Positions[i]:=APosition;
end;
finally
APosition.Free;
end;
Chart1.Invalidate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(6);
Chart1.Draw;
end;
Before the button is clicked, my chart looks like:
Normal enough. However, when I click the button the chart becomes:
Kind of a disaster. For some reason,
- 1. my marks have become transparent, although the Transparent property is FALSE
2. my mark text has become centered on the associated symbol
3. the line between my mark text and the chart has moved, now starting from the upper left corner of my chart background
4. the marks themselves did not move as expected. Rather than move UP, they kind of moved outward from some centerpoint.
This time, the marks DID move up 35 pixels, as I originally expected. If I keep clicking the button, the marks will now keep moving up until they leave the screen.
But I have to ask, WHY did all the rest of those items happen? Even if the marks themselves did not move to the correct locations, shouldn't the line that was associated with them have moved WITH THEM to their new location?