Windows Forms Wrap Legend Items

Hey, how can I wrap ChartLegendItems so they stay in multiple lines? I've tried changing ItemSize, Orientation and ItemsTextAlignment properties but none of them seem to do what I want.


3 Replies

MK Muneesh Kumar G Syncfusion Team September 11, 2018 10:05 AM UTC

Hi Saulo, 
 
Greetings from Syncfusion. 
 
We have analyzed your requirement and you can achieve this by using RowsCount property in legend as per the below code snippet.  
 
[C#] 
 
            //Place legend outside the chart area 
            this.chartControl1.LegendsPlacement = ChartPlacement.Outside; 
 
            //Place legend at the top of chart area 
            this.chartControl1.Legend.Position = ChartDock.Top; 
 
            //Center align the legend items 
            this.chartControl1.Legend.Alignment = ChartAlignment.Center; 
 
            //Number of rows required for legend 
            int numberOfLegendsInRow = 4; 
 
            //Set required number of rows using RowsCount property             
            this.chartControl1.Legend.RowsCount = (int)Math.Floor((double)this.chartControl1.Legend.Items.Length / numberOfLegendsInRow); 
 
 
We have prepared a sample based on this, please find the sample from the following location.  
 
 
Note: When legend is positioned at right or left side of the chart area, legend items will be displayed in multiple lines by default. 
 
 Output:  
 
 
Hope this helps.  
 
Regards, 
Muneesh Kumar G 



SA Saulo September 11, 2018 09:05 PM UTC

Thank you, this works perfectly!


MK Muneesh Kumar G Syncfusion Team September 12, 2018 05:10 AM UTC

Hi Saulo,  
 
Thanks for the update. 
  
We are glad to know that the given solution works. Please let us know if you need any further assistance. 
 
Regards, 
Muneesh Kumar G. 


Loader.
Up arrow icon