We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

set label width in chart

Hi,

How can I set the width of data label.

For example, in these charts, I want the 260;44% in a single line, but I don't know how set the width.

I try this:

            IOfficeChartSerie serie = chart.Series.Add("Serie");
            serie.Values = chart.ChartData[2, 2, tmpDatosChart.Count + 2, 2];
            serie.CategoryLabels = chart.ChartData[2, 1, tmpDatosChart.Count + 2, 1];
            serie.DataPoints.DefaultDataPoint.DataLabels.Layout.ManualLayout.WidthMode = LayoutModes.factor;
            serie.DataPoints.DefaultDataPoint.DataLabels.Layout.ManualLayout.Width = 400;

But I doesn't work


Thanks

3 Replies

MN Meikanda Nayanar Syncfusion Team April 8, 2019 12:18 PM UTC


Hi Manolo, 

Thank you for contacting Syncfusion support. 

Using the below code snippet will modify the height and width of the Data Label of the particular series of chart.  
  
//Get the first occurrence of chart  
IPresentationChart chart = presentation.Slides[0].Charts[0];  
  
//Change the Height of the dataLabel of the first series of the chart.  
chart.Series[0].DataPoints[1].DataLabels.Layout.ManualLayout.Height = 0.25;  
  
//Change the Width of the dataLabel of the first series of the chart.  
chart.Series[0].DataPoints[1].DataLabels.Layout.ManualLayout.Width = 0.5;  
  
//Change the Height of the dataLabel of the Second series of the chart.  
chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Width = 0.5;  
  
//Change the Height of the dataLabel of the Second series of the chart.  
chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Height = 0.20;  
  
Note: Value ranges from 0 to 1.  
  
For more reference, please use this sample which will be helpful for you.  

Thanks 
Meikandan 




MC Manolo Capdevila April 12, 2019 10:05 AM UTC

Thanks


MN Meikanda Nayanar Syncfusion Team April 12, 2019 11:18 AM UTC

Hi Manolo,

Welcome. We are always happy to help.

We hope our code snippets worked at your end to modify the height and width of the Data Label of the series of a chart, and our products suit your business requirements.

Please let us know if you need any further assistance in this.

Thanks

Meikandan


Loader.
Live Chat Icon For mobile
Up arrow icon