Hi,
I'm using version: TeeChart Pro v2013.0.1.4.131120
I have a Legend positioned at the bottom of the chart.
I'm trying to figure out the height of the legend based on the same scale as the chart.
What I'm seeing is that if I have the Legend set to invisible, the Chart is a specific height.
When I make the legend visible the Chart reduces in height to accommodate the legend.
I need to have the TChart get bigger in height, keeping the chart/grid the same vertical size.
The value of the Legend.Height is not the same scale as the TChart.height.
How can I determine the Legend height with respect to the TChart Height?
Thanks
Determine Height of Legend
Re: Determine Height of Legend
Hi Tirby,
This simple example uses the ChartRect and the Legend properties (Left, Top and Right&Bottom or Width&Height) to draw a rectangle around both them.
I'm not sure about what are you exactly trying to achieve, but these properties may help you.
Otherwise, please don't hesitate to let us know and we'll try to help you.
This simple example uses the ChartRect and the Legend properties (Left, Top and Right&Bottom or Width&Height) to draw a rectangle around both them.
Code: Select all
Private Sub Form_Load()
TChart1.AddSeries scLine
TChart1.Series(0).FillSampleValues
TChart1.Legend.Alignment = laBottom
End Sub
Private Sub TChart1_OnAfterDraw()
With TChart1.Canvas
.Brush.Style = bsClear
.Pen.Color = vbRed
.Rectangle TChart1.GetChartRect.Left, TChart1.GetChartRect.Top, TChart1.GetChartRect.Right, TChart1.GetChartRect.Bottom
.Rectangle TChart1.Legend.Left, TChart1.Legend.Top, TChart1.Legend.Left + TChart1.Legend.Width, TChart1.Legend.Top + TChart1.Legend.Height
End With
End Sub
Otherwise, please don't hesitate to let us know and we'll try to help you.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Determine Height of Legend
Yeray,
Thank you for reviewing this.
On the picture below, I have place 2 screen-shots side by side.
I aligned the tops of the grids.
The picture on the left has the Legend set to invisible.
The picture on the right has the Legend set to visible.
Note the positions of the "0" lines.
The difference is highlighted by the purple lines and arrows.
What I need to have happen is regardless of the visible state of the Legend, the Height of the grid needs to remain the same.
Is this more clear now?
Thanks!
Thank you for reviewing this.
On the picture below, I have place 2 screen-shots side by side.
I aligned the tops of the grids.
The picture on the left has the Legend set to invisible.
The picture on the right has the Legend set to visible.
Note the positions of the "0" lines.
The difference is highlighted by the purple lines and arrows.
What I need to have happen is regardless of the visible state of the Legend, the Height of the grid needs to remain the same.
Is this more clear now?
Thanks!
- Attachments
-
- Legend.png (17.39 KiB) Viewed 11373 times
Re: Determine Height of Legend
Hello,
Then, you should set the legend CustomPostition to true and set both the legend position and the chart margin manually. Ie:
Then, you should set the legend CustomPostition to true and set both the legend position and the chart margin manually. Ie:
Code: Select all
TChart1.Aspect.View3D = False
Dim i As Integer
For i = 0 To 4
TChart1.AddSeries scLine
TChart1.Series(0).FillSampleValues
Next i
TChart1.Legend.Alignment = laBottom
TChart1.Legend.CustomPosition = True
TChart1.Environment.InternalRepaint
TChart1.Legend.PositionUnits = puPixels
TChart1.Legend.Top = TChart1.ChartBounds.Bottom - 30
TChart1.Legend.Left = 80
TChart1.Panel.MarginBottom = 10
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |