Thanks for providing us sample file and referenced document for generating your custom oriented chart.
I have written the following sample code to accomplish your task, kindly refer to it and you may add/update your code accordingly for your requirements. The code uses your template file for your desired chart’s data source and creates your desired chart separately in the same sheet in the workbook.
Workbook workbook = new Workbook(“e:\test2\Donut+With+Leagend+Lines.xlsx”);
Worksheet sheet = workbook.Worksheets[0];
int chartIndex = 0;
chartIndex = sheet.Charts.Add(ChartType.Doughnut, 1, 1, 25, 10);
Chart chart = sheet.Charts[chartIndex];
//Set properties of chart
chart.PlotArea.Area.Formatting = FormattingType.None;
chart.PlotArea.Border.IsVisible = false;
//Set properties of nseries
chart.NSeries.Add(“B2:B9”, true);
chart.NSeries.CategoryData = “A2:A9”;
chart.NSeries.IsColorVaried = true;
//Set the ChartArea
ChartArea chartarea = chart.ChartArea;
//Show legend
chart.ShowLegend = true;
//Insert another series of Pie chart type.
int index = chart.NSeries.Add(“B2:B9”, true);
Series series = chart.NSeries[index];
series.Type = ChartType.Pie;
series.HasLeaderLines = true;
DataLabels datalabels = series.DataLabels;
datalabels.ShowPercentage = true;
datalabels.Position = LabelPositionType.OutsideEnd;
series.Area.Formatting = FormattingType.None;
//Remove its legent entry (if you want).
series.LegendEntry.IsDeleted = true;
//You need to move DataLabels a little leftward or rightward depending on their position
//to show leader lines
chart.Calculate();
int DELTA = 100;
for (int i = 0; i < series.Points.Count; i++)
{
int X = series.Points[i].DataLabels.X;
Debug.WriteLine(X);
///e.g if it is greater than 2000, then move the X position rightward
//otherwise move the X position leftward
if (X > 2000)
series.Points[i].DataLabels.X = X + DELTA;
else
series.Points[i].DataLabels.X = X - DELTA;
}
//Save the excel file
workbook.Save(“e:\test2\doughnut_chart1.xlsx”);
Hope, this helps a bit.
Thank you.