How to create PowerPoint box and whisker chart in C#, VB.NET?
This article explains how to create a box and whisker chart in PowerPoint using Presentation.
What is a box and whisker chart?
A box and whisker chart shows distribution of data into quartiles, highlighting the mean and outliers. Box and Whisker charts are most commonly used in statistical analysis.

Box and whisker chart created using Presentation
To create a box and whisker chart in PowerPoint using Presentation, you need to do the following steps.
Steps to create box and whisker chart
- Initialize chart
Create a chart object by calling the slide.Charts.AddChart method and specify the chart type to OfficeChartType.BoxAndWhisker enum value.
//Create the chart IPresentationChart chart = slide.Charts.AddChart(50, 50, 500, 400); //Set chart type to BoxAndWhisker chart.ChartType = OfficeChartType.BoxAndWhisker;
- Assign data
Set a range of data from the chartData to chart’s DataRange property. To plot the series values in column and categories in row, set chart’s IsSeriesInRows property to false.
//Set region of Chart data chart.DataRange = chart.ChartData[1, 1, 16, 4]; //Set chart series in column for assigned data region chart.IsSeriesInRows = false;
- Apply basic chart elements
Add the basic elements like chart title and legend with the below list of properties.
- ChartTitle of chart object.
- Set TRUE to chart’s HasLegend property, to show the legend.
//Apply chart elements //Set Chart Title chart.ChartTitle = "Box And Whisker Chart"; //Set Legend chart.HasLegend = true;
Applicable properties of box and whisker chart
Below is the list of other properties that is applicable for a box and whisker chart.
1. GapWidth
5. ShowMeanLine
1)Applying other properties unrelated to this chart might throw exception or the changes will not be reflected in the output document because those properties are not related to box and whisker chart.
2)As box and whisker chart is introduced in MS PowerPoint 2016, it can’t be viewed in MS PowerPoint 2013 and its earlier versions.
To know more about creating charts with various settings using Presentation please refer the documentation.
The following C#/ VB.NET complete code snippet shows the creation of box and whisker chart using Presentation.
C#
using Syncfusion.Presentation;
using Syncfusion.OfficeChart;
namespace ChartSample
{
class Program
{
static void Main(string[] args)
{
using (IPresentation pptxDoc = Presentation.Create())
{
// Adds a blank slide to the Presentation
ISlide slide1 = pptxDoc.Slides.Add(SlideLayoutType.Blank);
// Adds chart to the slide with position and size
IPresentationChart chart = slide1.Charts.AddChart(50, 50, 500, 400);
chart.ChartType = OfficeChartType.BoxAndWhisker;
//Assign data
chart.DataRange = chart.ChartData[1, 1, 16, 4];
chart.IsSeriesInRows = false;
//Apply chart elements
//Set Chart Title
chart.ChartTitle = "Box And Whisker Chart";
//Set data to the chart RowIndex, columnIndex, and data
SetChartData(chart);
//Set Legend
chart.HasLegend = true;
//Box and Whisker settings on first series
IOfficeChartSerie seriesA = chart.Series[0];
seriesA.SerieFormat.ShowInnerPoints = false;
seriesA.SerieFormat.ShowOutlierPoints = true;
seriesA.SerieFormat.ShowMeanMarkers = true;
seriesA.SerieFormat.ShowMeanLine = false;
seriesA.SerieFormat.QuartileCalculationType = QuartileCalculation.ExclusiveMedian;
//Box and Whisker settings on second series
IOfficeChartSerie seriesB = chart.Series[1];
seriesB.SerieFormat.ShowInnerPoints = false;
seriesB.SerieFormat.ShowOutlierPoints = true;
seriesB.SerieFormat.ShowMeanMarkers = true;
seriesB.SerieFormat.ShowMeanLine = false;
seriesB.SerieFormat.QuartileCalculationType = QuartileCalculation.InclusiveMedian;
//Box and Whisker settings on third series
IOfficeChartSerie seriesC = chart.Series[2];
seriesC.SerieFormat.ShowInnerPoints = false;
seriesC.SerieFormat.ShowOutlierPoints = true;
seriesC.SerieFormat.ShowMeanMarkers = true;
seriesC.SerieFormat.ShowMeanLine = false;
seriesC.SerieFormat.QuartileCalculationType = QuartileCalculation.ExclusiveMedian;
// Save and close the presentation
pptxDoc.Save("BoxAndWhisker.pptx");
pptxDoc.Close();
}
}
/// <summary>
/// Set the values for the chart
/// </summary>
/// <param name="chart">Represent the instance of the Presentation chart</param>
private static void SetChartData(IPresentationChart chart)
{
chart.ChartData.SetValue(1, 1, "Course");
chart.ChartData.SetValue(1, 2, "SchoolA");
chart.ChartData.SetValue(1, 3, "SchoolB");
chart.ChartData.SetValue(1, 4, "SchoolC");
chart.ChartData.SetValue(2, 1, "English");
chart.ChartData.SetValue(2, 2, 63);
chart.ChartData.SetValue(2, 3, 53);
chart.ChartData.SetValue(2, 4, 45);
chart.ChartData.SetValue(3, 1, "Physics");
chart.ChartData.SetValue(3, 2, 61);
chart.ChartData.SetValue(3, 3, 55);
chart.ChartData.SetValue(3, 4, 65);
chart.ChartData.SetValue(4, 1, "English");
chart.ChartData.SetValue(4, 2, 63);
chart.ChartData.SetValue(4, 3, 50);
chart.ChartData.SetValue(4, 4, 65);
chart.ChartData.SetValue(5, 1, "Math");
chart.ChartData.SetValue(5, 2, 62);
chart.ChartData.SetValue(5, 3, 51);
chart.ChartData.SetValue(5, 4, 64);
chart.ChartData.SetValue(6, 1, "English");
chart.ChartData.SetValue(6, 2, 46);
chart.ChartData.SetValue(6, 3, 53);
chart.ChartData.SetValue(6, 4, 66);
chart.ChartData.SetValue(7, 1, "English");
chart.ChartData.SetValue(7, 2, 58);
chart.ChartData.SetValue(7, 3, 56);
chart.ChartData.SetValue(7, 4, 67);
chart.ChartData.SetValue(8, 1, "Math");
chart.ChartData.SetValue(8, 2, 62);
chart.ChartData.SetValue(8, 3, 53);
chart.ChartData.SetValue(8, 4, 66);
chart.ChartData.SetValue(9, 1, "Math");
chart.ChartData.SetValue(9, 2, 62);
chart.ChartData.SetValue(9, 3, 53);
chart.ChartData.SetValue(9, 4, 66);
chart.ChartData.SetValue(10, 1, "English");
chart.ChartData.SetValue(10, 2, 63);
chart.ChartData.SetValue(10, 3, 54);
chart.ChartData.SetValue(10, 4, 64);
chart.ChartData.SetValue(11, 1, "English");
chart.ChartData.SetValue(11, 2, 63);
chart.ChartData.SetValue(11, 3, 52);
chart.ChartData.SetValue(11, 4, 67);
chart.ChartData.SetValue(12, 1, "Physics");
chart.ChartData.SetValue(12, 2, 60);
chart.ChartData.SetValue(12, 3, 56);
chart.ChartData.SetValue(12, 4, 64);
chart.ChartData.SetValue(13, 1, "English");
chart.ChartData.SetValue(13, 2, 60);
chart.ChartData.SetValue(13, 3, 56);
chart.ChartData.SetValue(13, 4, 64);
chart.ChartData.SetValue(14, 1, "Math");
chart.ChartData.SetValue(14, 2, 61);
chart.ChartData.SetValue(14, 3, 56);
chart.ChartData.SetValue(14, 4, 45);
chart.ChartData.SetValue(15, 1, "Math");
chart.ChartData.SetValue(15, 2, 63);
chart.ChartData.SetValue(15, 3, 58);
chart.ChartData.SetValue(15, 4, 64);
chart.ChartData.SetValue(16, 1, "English");
chart.ChartData.SetValue(16, 2, 59);
chart.ChartData.SetValue(16, 3, 54);
chart.ChartData.SetValue(16, 4, 65);
}
}
}
VB
Imports Syncfusion.Presentation
Imports Syncfusion.OfficeChart
Namespace ChartSample
Class Program
Public Shared Sub Main(ByVal args As String())
'Creates a PowerPoint instance
Dim pptxDoc As IPresentation = Presentation.Create()
Dim slide1 As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank)
'Initialize chart
Dim chart As IPresentationChart = slide1.Charts.AddChart(50, 50, 500, 400)
chart.ChartType = OfficeChartType.BoxAndWhisker
'Assign data
chart.DataRange = chart.ChartData[1, 1, 16, 4]
chart.IsSeriesInRows = False
'Apply chart elements
'Set Chart Title
chart.ChartTitle = "Box And Whisker Chart"
'Set data
SetChartData (chart)
'Set Legend
chart.HasLegend = True
'Box and Whisker settings on first series
Dim seriesA As IOfficeChartSerie = chart.Series(0)
seriesA.SerieFormat.ShowInnerPoints = False
seriesA.SerieFormat.ShowOutlierPoints = True
seriesA.SerieFormat.ShowMeanMarkers = True
seriesA.SerieFormat.ShowMeanLine = False
seriesA.SerieFormat.QuartileCalculationType = QuartileCalculation.ExclusiveMedian
'Box and Whisker settings on second series
Dim seriesB As IOfficeChartSerie = chart.Series(1)
seriesB.SerieFormat.ShowInnerPoints = False
seriesB.SerieFormat.ShowOutlierPoints = True
seriesB.SerieFormat.ShowMeanMarkers = True
seriesB.SerieFormat.ShowMeanLine = False
seriesB.SerieFormat.QuartileCalculationType = QuartileCalculation.InclusiveMedian
'Box and Whisker settings on third series
Dim seriesC As IOfficeChartSerie = chart.Series(2)
seriesC.SerieFormat.ShowInnerPoints = False
seriesC.SerieFormat.ShowOutlierPoints = True
seriesC.SerieFormat.ShowMeanMarkers = True
seriesC.SerieFormat.ShowMeanLine = False
seriesC.SerieFormat.QuartileCalculationType = QuartileCalculation.ExclusiveMedian
'Saving and closing the presentation
pptxDoc.Save("BoxAndWhisker.pptx")
pptxDoc.Close()
End Sub
''' <summary>
''' Set the values for the chart
''' </summary>
''' <param name="chart">Represent the instance of the Presentation chart</param>
Private Shared Sub SetChartData (ByVal chart As IPresentationChart)
chart.ChartData.SetValue(1, 1, "Course")
chart.ChartData.SetValue(1, 2, "SchoolA")
chart.ChartData.SetValue(1, 3, "SchoolB")
chart.ChartData.SetValue(1, 4, "SchoolC")
chart.ChartData.SetValue(2, 1, "English")
chart.ChartData.SetValue(2, 2, 63)
chart.ChartData.SetValue(2, 3, 53)
chart.ChartData.SetValue(2, 4, 45)
chart.ChartData.SetValue(3, 1, "Physics")
chart.ChartData.SetValue(3, 2, 61)
chart.ChartData.SetValue(3, 3, 55)
chart.ChartData.SetValue(3, 4, 65)
chart.ChartData.SetValue(4, 1, "English")
chart.ChartData.SetValue(4, 2, 63)
chart.ChartData.SetValue(4, 3, 50)
chart.ChartData.SetValue(4, 4, 65)
chart.ChartData.SetValue(5, 1, "Math")
chart.ChartData.SetValue(5, 2, 62)
chart.ChartData.SetValue(5, 3, 51)
chart.ChartData.SetValue(5, 4, 64)
chart.ChartData.SetValue(6, 1, "English")
chart.ChartData.SetValue(6, 2, 46)
chart.ChartData.SetValue(6, 3, 53)
chart.ChartData.SetValue(6, 4, 66)
chart.ChartData.SetValue(7, 1, "English")
chart.ChartData.SetValue(7, 2, 58)
chart.ChartData.SetValue(7, 3, 56)
chart.ChartData.SetValue(7, 4, 67)
chart.ChartData.SetValue(8, 1, "Math")
chart.ChartData.SetValue(8, 2, 62)
chart.ChartData.SetValue(8, 3, 53)
chart.ChartData.SetValue(8, 4, 66)
chart.ChartData.SetValue(9, 1, "Math")
chart.ChartData.SetValue(9, 2, 62)
chart.ChartData.SetValue(9, 3, 53)
chart.ChartData.SetValue(9, 4, 66)
chart.ChartData.SetValue(10, 1, "English")
chart.ChartData.SetValue(10, 2, 63)
chart.ChartData.SetValue(10, 3, 54)
chart.ChartData.SetValue(10, 4, 64)
chart.ChartData.SetValue(11, 1, "English")
chart.ChartData.SetValue(11, 2, 63)
chart.ChartData.SetValue(11, 3, 52)
chart.ChartData.SetValue(11, 4, 67)
chart.ChartData.SetValue(12, 1, "Physics")
chart.ChartData.SetValue(12, 2, 60)
chart.ChartData.SetValue(12, 3, 56)
chart.ChartData.SetValue(12, 4, 64)
chart.ChartData.SetValue(13, 1, "English")
chart.ChartData.SetValue(13, 2, 60)
chart.ChartData.SetValue(13, 3, 56)
chart.ChartData.SetValue(13, 4, 64)
chart.ChartData.SetValue(14, 1, "Math")
chart.ChartData.SetValue(14, 2, 61)
chart.ChartData.SetValue(14, 3, 56)
chart.ChartData.SetValue(14, 4, 45)
chart.ChartData.SetValue(15, 1, "Math")
chart.ChartData.SetValue(15, 2, 63)
chart.ChartData.SetValue(15, 3, 58)
chart.ChartData.SetValue(15, 4, 64)
chart.ChartData.SetValue(16, 1, "English")
chart.ChartData.SetValue(16, 2, 59)
chart.ChartData.SetValue(16, 3, 54)
chart.ChartData.SetValue(16, 4, 65)
End Sub
End Class
End Namespace