Hi:
I would like to locate the legend box in the upper right of my graphs. I found the "left" and "top" attributes, but since the legend auto-sizes the width by how wide the text elements are, and there's no "width" attribute, I'm not sure how to proceed.
Do you have any suggestions?
Thanks,
Matt
Legend box positioning
Hi Matt,
These properties give you the four legend corners:
These properties give you the four legend corners:
Code: Select all
TChart1.Legend.ShapeBounds.Left
TChart1.Legend.ShapeBounds.Top
TChart1.Legend.ShapeBounds.Right
TChart1.Legend.ShapeBounds.Bottom
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Hi Matt,
Yes, legend box is sized based on the width of the text elements. So, if you want to have the legend always at the same distance of the right of the chart, I recommend you to use them to obtain legend's width. And then, you could set legend's left property to move it. Something like this:
Yes, legend box is sized based on the width of the text elements. So, if you want to have the legend always at the same distance of the right of the chart, I recommend you to use them to obtain legend's width. And then, you could set legend's left property to move it. Something like this:
Code: Select all
Private Sub TChart1_OnResize()
TChart1.Environment.InternalRepaint
With TChart1.Legend
.Left = TChart1.ChartBounds.Right - (.ShapeBounds.Right - .ShapeBounds.Left) - 5
End With
End Sub
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Hi Matt,
If you want to set a right margin according to the legend width, you could do as follows:
If you want to set a right margin according to the legend width, you could do as follows:
Code: Select all
Private Sub Form_Load()
With TChart1
.AddSeries scBar
.Series(0).FillSampleValues 25
.Legend.Top = 0
TChart1_OnResize
.Environment.InternalRepaint
.Panel.MarginUnits = muPixels
End With
With TChart1.Legend.ShapeBounds
TChart1.Panel.MarginRight = .Right - .Left + 15
End With
End Sub
Private Sub TChart1_OnResize()
TChart1.Environment.InternalRepaint
With TChart1.Legend.ShapeBounds
TChart1.Legend.Left = TChart1.ChartBounds.Right - (.Right - .Left) - 5
End With
End Sub
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |