I am unable to get the connecting lines for the outliers point and the box if the range between outlier point and upper quartile exceeds some value. I have attached the expected outcome excel sheet.
Here is the code :
var index = 0;
List colorList = new List { Color.Red, Color.Black, Color.AliceBlue};
const string excelTemplateRelativePath =
@“C:\Users\Documents\Visual Studio 2015\Projects\BoxPlot\ExcelFolder\ReportExcelTemplate.xlsx”;
var templatePath = excelTemplateRelativePath;
var excel = new Workbook(templatePath);
excel.Worksheets.AddCopy(index);
var sheet = excel.Worksheets[index];
var datacell = sheet.Cells[“A” + 1];
datacell.PutValue("");
sheet.Cells["A2"].PutValue("Jan");
sheet.Cells["A3"].PutValue("Jan");
sheet.Cells["A4"].PutValue("Jan");
sheet.Cells["A5"].PutValue("Jan");
sheet.Cells["A6"].PutValue("Jan");
sheet.Cells["A7"].PutValue("June");
sheet.Cells["A8"].PutValue("June");
sheet.Cells["A9"].PutValue("June");
sheet.Cells["A10"].PutValue("June");
sheet.Cells["A11"].PutValue("June");
sheet.Cells["B1"].PutValue("Team A");
sheet.Cells["B2"].PutValue(60);
sheet.Cells["B3"].PutValue(70);
sheet.Cells["B4"].PutValue(90);
sheet.Cells["B5"].PutValue(150);
sheet.Cells["B6"].PutValue(70);
sheet.Cells["B7"].PutValue(80);
sheet.Cells["B8"].PutValue(90);
sheet.Cells["B9"].PutValue(110);
sheet.Cells["B10"].PutValue(130);
sheet.Cells["B11"].PutValue(150);
sheet.Cells["C1"].PutValue("Team B");
sheet.Cells["C2"].PutValue(40);
sheet.Cells["C3"].PutValue(50);
sheet.Cells["C4"].PutValue(60);
sheet.Cells["C5"].PutValue(160);
sheet.Cells["C6"].PutValue(30);
sheet.Cells["C7"].PutValue(50);
sheet.Cells["C8"].PutValue(20);
sheet.Cells["C9"].PutValue(120);
sheet.Cells["C10"].PutValue(140);
sheet.Cells["C11"].PutValue(160);
var chartArea = "B" + 2 + ":" + "C" + 11;
var categoryData = "A" + 2 + ":A" + 11;
int index1 = sheet.Charts.Add(ChartType.BoxWhisker, 0, 3, 0 + 20, 10);
var chart = sheet.Charts[index1];
chart.SetChartDataRange(chartArea, true);
chart.NSeries.CategoryData = categoryData;
var seriesName = new List<string> { "Team 1","Team 2"};
int series_index = 0;
int colorindex = 0;
foreach (var series in seriesName)
{
chart.NSeries[series_index].Name = series;
chart.NSeries[series_index].Area.FillFormat.FillType = FillType.None;
chart.NSeries[series_index].LayoutProperties.ShowMeanLine = false;
chart.NSeries[series_index].Border.WeightPt = 1;
chart.NSeries[series_index].LayoutProperties.QuartileCalculation = QuartileCalculationType.Inclusive;
chart.NSeries[series_index].LayoutProperties.ShowInnerPoints = false;
chart.NSeries[series_index].Border.FormattingType = ChartLineFormattingType.Solid;
chart.NSeries[series_index].Border.Style = LineType.Solid;
chart.NSeries[series_index].Border.Color = colorList[series_index];
series_index++;
}
chart.ValueAxis.Title.RotationAngle = 0;
chart.ValueAxis.AxisLine.IsVisible = false;
chart.PlotArea.Border.IsVisible = false;
chart.PlotArea.Area.ForegroundColor = Color.White;
chart.ChartArea.Border.IsVisible = false;
excel.Save(templatePath + "_output.xlsx");
DemoChart.zip (14.9 KB)