Page 1 of 1
Legend title cropped
Posted: Tue Oct 18, 2016 3:05 am
by 16077780
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.
Re: Legend title cropped
Posted: Tue Oct 18, 2016 10:49 am
by Christopher
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 (63.1 KiB) Viewed 8012 times
Re: Legend title cropped
Posted: Tue Oct 18, 2016 12:05 pm
by 16077780
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.
Re: Legend title cropped
Posted: Tue Oct 18, 2016 1:29 pm
by Christopher
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.