- Default legend position
- legend1.jpg (22.87 KiB) Viewed 13574 times
- Expected legend position
- legend2.jpg (21.33 KiB) Viewed 13571 times
Code: Select all
Private Sub AdjustLegend()
Dim tmpWidth, tmpMargin As Integer
tmpWidth = TChart1.Legend.ShapeBounds.Right - TChart1.Legend.ShapeBounds.Left
tmpMargin = 10
TChart1.Legend.CustomPosition = True
TChart1.Panel.MarginUnits = muPixels
TChart1.Panel.MarginRight = tmpWidth + tmpMargin * 2
TChart1.Legend.Left = TChart1.ChartBounds.Right - tmpWidth - tmpMargin
End Sub
Private Sub TChart1_OnAfterDraw()
AdjustLegend
End Sub
![]() | Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) |
![]() ![]() ![]() ![]() ![]() ![]() |
Please read our Bug Fixing Policy |
Code: Select all
int nWidth = m_chart.GetLegend().GetShapeBounds().GetRight()-m_chart.GetLegend().GetShapeBounds().GetLeft();
int nMgn = 10;
m_chart.GetLegend().SetCustomPosition(TRUE);
m_chart.GetPanel().SetMarginUnits(muPixels);
m_chart.GetPanel().SetMarginRight(nWidth + nMgn*2);
int nRmgn = m_chart.GetChartBounds().GetRight();
m_chart.GetLegend().SetLeft(nRmgn - nWidth - nMgn);
![]() | Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) |
![]() ![]() ![]() ![]() ![]() ![]() |
Please read our Bug Fixing Policy |
Code: Select all
BOOL CChartLegendTestDlg::OnInitDialog()
{
//...
m_chart1.GetAspect().SetView3D(FALSE);
m_chart1.AddSeries(scFastLine);
m_chart1.AddSeries(scFastLine);
m_chart1.AddSeries(scFastLine);
m_chart1.Series(1).SetVerticalAxis(aRightAxis);
m_chart1.GetAxis().GetRight().GetTitle().SetCaption("Test");
m_chart1.GetAxis().GetRight().GetLabels().SetSize(42);
m_chart1.GetAxis().GetRight().GetTitle().GetFont().SetSize(12);
m_chart1.GetAxis().GetRight().SetAutomatic(TRUE);
m_chart1.GetLegend().SetCustomPosition(TRUE);
m_chart1.GetEnvironment().InternalRepaint();
return TRUE;
}
//...
void CChartLegendTestDlg::OnAfterDrawTchart1()
{
int nWidth = m_chart1.GetLegend().GetShapeBounds().GetRight()-m_chart1.GetLegend().GetShapeBounds().GetLeft();
int nMgn = 10;
int axisMgn = 65;
m_chart1.GetPanel().SetMarginUnits(muPixels);
m_chart1.GetPanel().SetMarginRight(nWidth - axisMgn + nMgn*2);
m_chart1.GetLegend().SetLeft(m_chart1.GetAxis().GetBottom().GetIEndPos() + nMgn);
}
![]() | Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) |
![]() ![]() ![]() ![]() ![]() ![]() |
Please read our Bug Fixing Policy |
Code: Select all
m_chart1.GetLegend().SetAlignment(laTop);
int nWidth = m_chart1.GetLegend().GetShapeBounds().GetRight()-m_chart1.GetLegend().GetShapeBounds().GetLeft();
Code: Select all
BOOL CChartLegendTestDlg::OnInitDialog()
{
//...
m_chart1.GetLegend().SetCustomPosition(TRUE);
m_chart1.GetLegend().SetAlignment(laTop);
m_chart1.GetEnvironment().InternalRepaint();
m_chart1.GetEnvironment().InternalRepaint();
![]() | Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) |
![]() ![]() ![]() ![]() ![]() ![]() |
Please read our Bug Fixing Policy |