Data Lables on a Chart

I have created a chart on a slide using Presentation but can not find how to add data labels.  I also need to se the Font on the data labels.  Can anybody provide an example of how this is done?

My code:

Dim chart1 As IPresentationChart = chart_Slide_A.Charts.AddChart(40, 140, 200, 150)

'Specifies the chart title

chart1.ChartTitle = "Sales Analysis"

chart1.ChartTitleArea.Size = 10

'Sets chart data - Row1

chart1.ChartData.SetValue(1, 2, "Jan")

chart1.ChartData.SetValue(1, 3, "Feb")

chart1.ChartData.SetValue(1, 4, "March")

'Sets chart data - Row2

chart1.ChartData.SetValue(2, 1, 2010)

chart1.ChartData.SetValue(2, 2, 60)

chart1.ChartData.SetValue(2, 3, 70)

chart1.ChartData.SetValue(2, 4, 80)

'Sets chart data - Row3

chart1.ChartData.SetValue(3, 1, 2011)

chart1.ChartData.SetValue(3, 2, 80)

chart1.ChartData.SetValue(3, 3, 70)

chart1.ChartData.SetValue(3, 4, 60)

'Sets chart data - Row4

chart1.ChartData.SetValue(4, 1, 2012)

chart1.ChartData.SetValue(4, 2, 60)

chart1.ChartData.SetValue(4, 3, 70)

chart1.ChartData.SetValue(4, 4, 80)

'Creates a new chart series with the name

Dim seriesJan1 As IOfficeChartSerie = chart1.Series.Add("Jan")

'Sets the data range of chart series – start row, start column, end row, end column

seriesJan1.Values = chart1.ChartData(2, 2, 4, 2)

'Creates a new chart series with the name

Dim seriesFeb1 As IOfficeChartSerie = chart1.Series.Add("Feb")

'Sets the data range of chart series – start row, start column, end row, end column

seriesFeb1.Values = chart1.ChartData(2, 3, 4, 3)

'Creates a new chart series with the name

Dim seriesMarch1 As IOfficeChartSerie = chart1.Series.Add("March")

'Sets the data range of chart series – start row, start column, end row, end column

seriesMarch1.Values = chart1.ChartData(2, 4, 4, 4)

'Sets the data range of the category axis

chart1.PrimaryCategoryAxis.CategoryLabels = chart1.ChartData(2, 1, 4, 1)

'Specifies the chart type

'chart.ChartType = OfficeChartType.Column_Clustered

chart1.ChartType = OfficeChartType.Column_Stacked

 

1 Reply

RM Ramaraj Marimuthu Syncfusion Team June 22, 2018 12:27 PM UTC

Hi Corey,

Thank you for contacting Syncfusion support.
 
Please use the below code snippet to add and modify the the data label in Presentation chart using Syncfusion Presentation library.  
'Add data label and its position 
seriesJan1.DataPoints.DefaultDataPoint.DataLabels.IsValue = True 
 
seriesJan1.DataPoints.DefaultDataPoint.DataLabels.Position = OfficeDataLabelPosition.Outside 
 
'Default font name of the data label 
 
Dim font As String = seriesJan1.DataPoints.DefaultDataPoint.DataLabels.FontName 
 
'sets the data label for specific data point 
 
seriesJan1.DataPoints(0).DataLabels.Text = "Hello World" 
 
'Sets the font name for data label for specific data point 
 
seriesJan1.DataPoints(0).DataLabels.FontName = "ALGERIAN" 
 
'sets the data label value bold for specific data point 
 
seriesJan1.DataPoints(0).DataLabels.Bold = True 
 
'Font name of the data label for specific data point 
 
Dim fontName As String = seriesJan1.DataPoints(0).DataLabels.FontName 
 
 
We have created a sample to add and modify the font properties of data label in Presentation chart using Syncfusion Presentation library. Please find the sample from below link, 
Regards,
Ramaraj Marimuthu
 


Loader.
Up arrow icon