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) ?
Marks text with angle 90 not aligned with arrow
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi SteveP,
Yes, you are right. I've included this item to our defect/wish list to be enhanced for future releases.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.
Below there's a code example on how to customize marks position.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) ?
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 |
Instructions - How to post in this forum |
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
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
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Steve,
Yes, but it doesn't mind, just didn't customized the Y postion.
No, what happens is that some marks are almost placed where the next mark would originally be.
In the example below the arrow line also move.
Then you can try chart.draw and series.repaint combination as here:
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 |
Instructions - How to post in this forum |
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;
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;
Pep Jorge
http://support.steema.com
http://support.steema.com