How to change Mark position
How to change Mark position
Hi,
Is it possible to change the Mark position at all?
I tried to do that using Serie.Marks.Positions.Position[ind].LeftTop.X := somevalue; but always got access violation error message.
Thanks in advance,
droid
Is it possible to change the Mark position at all?
I tried to do that using Serie.Marks.Positions.Position[ind].LeftTop.X := somevalue; but always got access violation error message.
Thanks in advance,
droid
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi Narcis,narcis wrote:Hi droid,
Yes, this is possible. Please read this old message explaining how to do that.
thanks a lot, that code helped me a lot but I still have troubles.
I can feel it is a timing ussue.
I need to display marks in GanttChart not in the middle of the bar(default) but at the end of it.
I use the following code to achieve this:
Gantt := TGanttSeries(Chart1.Series[0]);
For ind := 0 to Gantt.Count-1 do
begin
Gantt.Marks.Positions.Position[Ind].Custom := true;
Gantt.Marks.Positions.Position[Ind].LeftTop.X := Gantt.CalcXPosValue(Gantt.EndValues[ind]);
end;
Gantt.Repaint;
It works as expected but only if I, say, have a button on the form and invoke the code above on ButtonClick event.
My idea is to do that automatically every time chart gets re-drawn.
So I put the code above into Chart1AfterDraw event. But it will not work that way because mark will appear in a wrong place!
Can you give me any idea what I'm doing wrong?
thanks,
droid
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi droid,
If you use the code in the OnAfterDraw event you can add a Chart1.Draw; call at the end in the OnFormCreate event so that the chart is forced to be repainted and thus marks properly positioned.
If you use the code in the OnAfterDraw event you can add a Chart1.Draw; call at the end in the OnFormCreate event so that the chart is forced to be repainted and thus marks properly positioned.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
That's exactly the way I'm doing it!narcis wrote:Hi droid,
If you use the code in the OnAfterDraw event you can add a Chart1.Draw; call at the end in the OnFormCreate event so that the chart is forced to be repainted and thus marks properly positioned.
I build chart, then do chart.draw but it won't work !
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi droid,
Could you please send us an example we can run "as-is" to reproduce the problem here?
You can post your files at news://www.steema.net/steema.public.attachments newsgroup.
Thanks in advance.
Could you please send us an example we can run "as-is" to reproduce the problem here?
You can post your files at news://www.steema.net/steema.public.attachments newsgroup.
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
How would you move a mark that was just added? I add lines to a series whos marks need moved a calculated distance away from the add line each time one is added. If I place similar code like that above in a button event, it works fine..but when I try to place it in OnAfterDraw, I get an access violation error. Have also tried sFLines.AfterDrawValue, OnAfterAdd, OnGetMarkText, etc.
procedure TForm1.MoveLineMark(Num: integer);
begin
if Num > sFLines.Count-1 then exit;
with sFLines.Marks.Positions[Num] do begin
Custom:=True;
// LeftTop.X:=.LeftTop.X;
LeftTop.Y:=LeftTop.Y-5;
// sFlines.Repaint;
end;
end;
procedure TForm1.MoveLineMark(Num: integer);
begin
if Num > sFLines.Count-1 then exit;
with sFLines.Marks.Positions[Num] do begin
Custom:=True;
// LeftTop.X:=.LeftTop.X;
LeftTop.Y:=LeftTop.Y-5;
// sFlines.Repaint;
end;
end;
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi pssdelphi,
Have you seen the example I posted in the old message I linked on my 10th October 2006 post?
Have you seen the example I posted in the old message I linked on my 10th October 2006 post?
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Yes, that and every other post I could find on the subject. The trouble is that the posts I could find on the topic address the problem mostly based upon having a set series loaded or created at the inital start of the program., ie, placing the Draw method in OnFormCreate. My problem is dealing with marks that are being added to the series dynamically as the user decides to add them. When I try triggering the code OnAfterDraw and other events (as listed in my question) I get an access voilation error. How would I update the position of a mark of a newly added point in a series without getting an access violation?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi pssdelphi,
Could you please send us a simple example project we can run "as-is" to reproduce the problem here?
You can post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Thanks in advance.
Could you please send us a simple example project we can run "as-is" to reproduce the problem here?
You can post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi pssdelphi,
Thanks for the example project.
The Access Violation occurs because MoveLineMark is called before the chart is refreshed after new data is added to the series. You can solve this problem adding a TChart.Refresh call:
Thanks for the example project.
The Access Violation occurs because MoveLineMark is called before the chart is refreshed after new data is added to the series. You can solve this problem adding a TChart.Refresh call:
Code: Select all
procedure TForm1.Chart1ClickSeries(Sender: TCustomChart;
Series: TChartSeries; ValueIndex: Integer; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
xs, ys: double;
begin
xs:=Series1.XScreenToValue(x);
ys:=Series1.YScreenToValue(y);
Series1.AddXY(xs,ys);
Inc(NumAdded);
// if NumAdded > 0 then
Chart1.Refresh;
MoveLineMark(Series1.Count-1);
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
That does prevent the error, but the results are very erratic. What the sample program I sent was intended to do was to move the mark of the newly added point. What it seems to be doing is when you add the first point, the mark for that point doesnt change from origional position. When you add a 2nd point, the mark of the previous point moves and this continues till you get to the 8-10th added point, then things get really wierd. Also, once a point mark gets moved it seems disconnected from the point, because if you scroll the chart after a point is added the moved mark is fixed in position and doesnt move with the point.
procedure TForm1.Chart1ClickSeries(Sender: TCustomChart;
Series: TChartSeries; ValueIndex: Integer; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
xs, ys: double;
ja: integer;
begin
xs:=Series.XScreenToValue(x);
ys:=Series.YScreenToValue(y);
ja:=Series1.AddXY(xs,ys);
Chart1.Refresh;
MoveLineMark(ja);
end;
procedure TForm1.Chart1ClickSeries(Sender: TCustomChart;
Series: TChartSeries; ValueIndex: Integer; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
xs, ys: double;
ja: integer;
begin
xs:=Series.XScreenToValue(x);
ys:=Series.YScreenToValue(y);
ja:=Series1.AddXY(xs,ys);
Chart1.Refresh;
MoveLineMark(ja);
end;
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi pssdelphi,
It is not working because you are not repainting the series after marks positions are changed, as my 21st April 2005 post in the thread I mentioned.
It is not working because you are not repainting the series after marks positions are changed, as my 21st April 2005 post in the thread I mentioned.
Code: Select all
procedure TForm1.MoveLineMark(Num: integer);
begin
with Series1 do begin
if Num > Count-1 then exit;
with Marks.Positions[Num] do begin
Custom:=True;
LeftTop.Y:=LeftTop.Y-10;
end;
Repaint;
end;
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |