Hi,
I would like to list the legend items horizontally, not vertically. Then I would like to place the legend next to the header text. How to realize such a legend?
Thank you very much!
David
How to list legend items horizontally?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi David,
You can use custom legend position doing something like this:
You can use custom legend position doing something like this:
Code: Select all
Private Sub Form_Load()
TChart1.Series(0).FillSampleValues 10
'InternalRepaint call to make the chart objects being drawn
TChart1.Environment.InternalRepaint
TChart1.Legend.Alignment = laTop
TChart1.Legend.CustomPosition = True
TChart1.Legend.Left = TChart1.Header.ShapeBounds.Right + 10
TChart1.Legend.Top = TChart1.Header.ShapeBounds.Top
End Sub
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, Narcís,
Following your code, the legend is listed horizontally, but it is at the top left corner. Anything wrong? I figured out some code as
m_chart2.GetLegend().SetAlignment(laTop);
m_chart2.GetLegend().SetCustomPosition(TRUE);
long x = m_chart2.GetWidth()/2.0 - 50;
long y = m_chart2.GetHeader().GetShapeBounds().GetTop() + 24;
m_chart2.GetLegend().SetLeft(x);
m_chart2.GetLegend().SetTop(y);
And now it is listed right below the header text. Another question is when I should use the internal repaint? Under what circumstances should the repaint be used?
Thank you very much!
Daivd
Following your code, the legend is listed horizontally, but it is at the top left corner. Anything wrong? I figured out some code as
m_chart2.GetLegend().SetAlignment(laTop);
m_chart2.GetLegend().SetCustomPosition(TRUE);
long x = m_chart2.GetWidth()/2.0 - 50;
long y = m_chart2.GetHeader().GetShapeBounds().GetTop() + 24;
m_chart2.GetLegend().SetLeft(x);
m_chart2.GetLegend().SetTop(y);
And now it is listed right below the header text. Another question is when I should use the internal repaint? Under what circumstances should the repaint be used?
Thank you very much!
Daivd
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi David,
This is most likely to happen because you are not using InternalRepaint method. As I commented in my code snippet, this is used to force the chart being drawn so all elements have valid values as header shape bounds in that case as otherwise, since the chart hasn't been drawn those properties have not been set. This is necessary when setting properties like those in the OnFormLoad event for example, instead of in the OnAfterDraw event.
This is most likely to happen because you are not using InternalRepaint method. As I commented in my code snippet, this is used to force the chart being drawn so all elements have valid values as header shape bounds in that case as otherwise, since the chart hasn't been drawn those properties have not been set. This is necessary when setting properties like those in the OnFormLoad event for example, instead of in the OnAfterDraw event.
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 |