Marks text with angle 90 not aligned with arrow

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
SteveP
Advanced
Posts: 132
Joined: Sun Sep 07, 2003 4:00 am

Marks text with angle 90 not aligned with arrow

Post by SteveP » Tue Mar 01, 2005 8:00 pm

When Marks angle is 90 or 270 degrees so that the mark text is drawn vertically, the center of the mark text is not aligned with its arrow. The text is positioned slightly to the right. When printed, the arrow is almost at the left edge of the text.

I was not able to use Series1.Marks.Positions.Position[ValueIndex].LeftTop.X to shift it. Can this be used and where (GetMarkText or After Draw Series or Chart) ?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Mar 02, 2005 9:56 am

Hi SteveP,
When Marks angle is 90 or 270 degrees so that the mark text is drawn vertically, the center of the mark text is not aligned with its arrow. The text is positioned slightly to the right. When printed, the arrow is almost at the left edge of the text.
Yes, you are right. I've included this item to our defect/wish list to be enhanced for future releases.
I was not able to use Series1.Marks.Positions.Position[ValueIndex].LeftTop.X to shift it. Can this be used and where (GetMarkText or After Draw Series or Chart) ?
Below there's a code example on how to customize marks position.

Code: Select all

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var sx, sy : integer;
    i      : integer;
begin
   with series1 do
   begin
     for i := 0 to Marks.Positions.Count - 1 do
     begin
       sx := Series1.CalcXPos(i);
       sy := Series1.CalcYPos(i);
       Marks.Positions.Position[i].Custom := True;
       Marks.Positions.Position[i].LeftTop.X := sx+50;
     end;
   end;
    Chart1.AutoRepaint:= true;
    Chart1.Repaint;
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
Image Image Image Image Image Image
Instructions - How to post in this forum

SteveP
Advanced
Posts: 132
Joined: Sun Sep 07, 2003 4:00 am

Post by SteveP » Wed Mar 02, 2005 3:12 pm

Narcis,

Your code overlooked including :
Marks.Positions.Position.LeftTop.Y := sy;

This results in individual marks being shifted by slightly different amounts for each mark. Some get aligned to the arrow line, others are not.

When the chart is then zoomed, the mark text zooms correctly but the arrow lines remain where they were and do not move.

The
Chart1.AutoRepaint:= true;
Chart1.Repaint;
causes the chart response to become very slow, due to recursion ?

Steve

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Mar 03, 2005 2:47 pm

Hi Steve,
Your code overlooked including :
Marks.Positions.Position.LeftTop.Y := sy;


Yes, but it doesn't mind, just didn't customized the Y postion.

This results in individual marks being shifted by slightly different amounts for each mark. Some get aligned to the arrow line, others are not.


No, what happens is that some marks are almost placed where the next mark would originally be.

When the chart is then zoomed, the mark text zooms correctly but the arrow lines remain where they were and do not move.


In the example below the arrow line also move.

The
Chart1.AutoRepaint:= true;
Chart1.Repaint;
causes the chart response to become very slow, due to recursion ?


Then you can try chart.draw and series.repaint combination as here:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(10);
Chart1.Draw();
end;

procedure TForm1.DoAlignSeries(Series: TLineSeries);
var sx, sy : integer;
    i      : integer;
begin
     for i := 0 to Series.Count-1 do
     begin
       sx := Series.CalcXPos(i);
       sy := Series.CalcYPos(i);
       Series.Marks.Positions.Position[i].Custom := True;
       Series.Marks.Positions.Position[i].LeftTop.X := sx+50;
       Series.Marks.Positions.Position[i].LeftTop.Y := sy;
     end;
    Series1.Repaint;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  DoAlignSeries(Series1);
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
Image Image Image Image Image Image
Instructions - How to post in this forum

SteveP
Advanced
Posts: 132
Joined: Sun Sep 07, 2003 4:00 am

Post by SteveP » Fri Mar 04, 2005 4:36 pm

This code does not show shifted mark position until a chart repaint is done.

When zoom or pan, the mark text moves but the arrow line still does not (D7 with TChart 7.04).

After unzoom uisng mouse drag, the chart must be repainted for the marks to be repositioned to their original locations.

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Mar 07, 2005 4:58 pm

Hi Steve,

Since series marks custom positions are expressed in screen pixels, they stay the same if you zoom/scroll. A workoarund is to express and store series marks positions in axis values (doubles) and then in one of the TChart events read and translate these values back to screen pixels. This way custom positions will be updated with zoom/scroll (whenever chart is repainted).
There are several ways how to do this (derive new tool, store values in separate array, ...). I think we already have this on our to-do list for next major release.

Another thing you can do is to use the TSeriesMarks method. If you want to reset series marks when the Mark is dragged, you could do this by calling the following code:

Series1.Marks.ResetPositions;

or if you have multiple series:

for i := 0 to Chart1.SeriesCount -1 do
Chart1.Series.Marks.ResetPositions;

Post Reply