Legend Size

TeeChart for ActiveX, COM and ASP
Post Reply
Jenn
Newbie
Newbie
Posts: 19
Joined: Fri Jul 08, 2005 4:00 am
Location: Logan, Utah United States

Legend Size

Post by Jenn » Tue Sep 26, 2006 8:30 pm

Hello,

When I add a new series at run-time, the legend box is resized to accomodate the wider text. That's great. This works perfectly when I use the default font.

However, the font in my legend is Lucida Sans Typewriter, and it appears that the font size is ignored when calculating the size of the legend box.

I tried fixing this by manually setting the ShapeBounds when I add the series. However, it looks like I can read the size, but I can not set it. The CTeeRect structure provides no Set... routines.

I am using TeeChart Pro v7.0.0.8 for VC++

Code: Select all

 
  CLegend  legend = chartData.get_Legend();
  CTeeRect rect   = legend.GetShapeBounds();

  long right = rect.GetRight();
  // rect.SetRight(right + xxx);   Can't do this!
Any help will be greatly appreciated.

Thank you,

Jennifer Britt
Campbell Scientific

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Oct 02, 2006 8:41 am

Hi Jennifer,

how are you reproducing the problem ? Using the following code the legend is resized acording to the font size :

Code: Select all

	// TODO: Add extra initialization here
	m_chart.AddSeries(1);
	m_chart.Series(0).FillSampleValues(10);

void CLegendwDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
	m_chart.AddSeries(1);
	m_chart.GetLegend().GetFont().SetName("Lucida Sans");
	m_chart.GetLegend().GetFont().SetSize(15);
}
In case you want to resize the legend you should be able to do it using the OnGetLegendRect event.

Jenn
Newbie
Newbie
Posts: 19
Joined: Fri Jul 08, 2005 4:00 am
Location: Logan, Utah United States

Post by Jenn » Tue Oct 03, 2006 8:56 pm

Hello Josep,

Thank you for investigating this. Here is a short code sample, so that you might be able to reproduce this problem.

Code: Select all

void CGraphWindow::OnBnClicked_ChangeLegendFont(unsigned int id)
{
  CLegend  legend = chartData.get_Legend();
  CTeeFont font   = legend.GetFont();

  if (GetCheckedRadioButton(...) == IDC_RADIO_LUCIDA)
    font.SetName("Lucida Sans Typewriter");
  else
    font.SetName("MS Shell");
}

Some other properties of my legend box include:
  • LegendStyle = lsSeries
    Alignment = laLeft
    ResizeChart = true
    HorizMargin = 10;
    TopPercent = 10
    Check Boxes = true
    CheckBoxesStyle = csbCheck
With this set up, my legend text does not entirely fit inside the legend box, but is is partially drawn in the chart area instead. This only happens with the "Lucida Sans Typewriter" font. (MS Shell font works fine). Also note that my series titles can be long (maybe 35 characters long).


Here is some more information. When my attributes are set this way:
  • LegendStyle = lsLastValues
    TextStyle = ltsRightValue
I get something different. In this case, all my text appears inside the legend box. However, the "label" text and "value" text over-write each other. Again, this only happens with the "Lucida Sans Typewriter" font.

I hope this is enough information for you to reproduce this problem.

Thank you for your help,

Jennifer Britt

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Oct 11, 2006 10:24 am

Hi Jennifer,

ok, would you be so kind to send me an example with which I can reproduce the problem, investigate it and try to fix it for the next major releases ?
You can send me it directly to pep@steema.com

Post Reply