Legend title cropped

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
user2016
Newbie
Newbie
Posts: 6
Joined: Wed Mar 02, 2016 12:00 am

Legend title cropped

Post by user2016 » Tue Oct 18, 2016 3:05 am

I'm having problem with the legend title being cropped when I resize my WinForms.
I've already set TeeChart to Fill. When resize, the legend title will move to 2nd line when most of the title is being cropped.
please refer to attachment.
Attachments
TeeChartLegend-TitleCropped.png
TeeChartLegend-TitleCropped.png (29.55 KiB) Viewed 7647 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Legend title cropped

Post by Christopher » Tue Oct 18, 2016 10:49 am

Hello,

You can modify the column widths of the Legend using code such as the following:

Code: Select all

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;

      for (int i = 0; i < 4; i++)
      {
        tChart1.Series.Add(typeof(Line));
        tChart1[i].FillSampleValues();
        tChart1[i].Title = "Se title of seventy characters " + i.ToString();
      }

      tChart1.Legend.Alignment = LegendAlignments.Bottom;
      tChart1.Legend.ColumnWidthAuto = false;
      tChart1.Legend.ColumnWidths[0] = 10;
      tChart1.Legend.ColumnWidths[1] = 300;
    }
which here gives me:
636123916932203286.jpg
636123916932203286.jpg (63.1 KiB) Viewed 7641 times
Best Regards,
Christopher Ireland / 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

user2016
Newbie
Newbie
Posts: 6
Joined: Wed Mar 02, 2016 12:00 am

Re: Legend title cropped

Post by user2016 » Tue Oct 18, 2016 12:05 pm

Hi Christopher, thanks for your reply. Is there another way besides hard code the column width. Because my legend display title is dynamic not a fixed characters.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Legend title cropped

Post by Christopher » Tue Oct 18, 2016 1:29 pm

user2016 wrote:Hi Christopher, thanks for your reply. Is there another way besides hard code the column width. Because my legend display title is dynamic not a fixed characters.
As you can see in the code, the options are either to have ColumnWidthAuto set to true or to false.

What you could consider is measuring the length of your dynamic legend display title and then turning ColumnWidthAuto on or off as required - the limit for turning on or off will depend on the height and width of the chart, a few empirical tests should be able to determine for you what it will be.
Best Regards,
Christopher Ireland / 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

Post Reply