I have done a pie chart in Excel using ExcelEngine and IChartShape. The legend of the pie chart is repeating.
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
object[] yValues = new object[] { 2000, 1000, 1000 };
object[] xValues = new object[] { "Total Income", "Expenses", "Profit" };
//Adding series and values
IChartShape chart = sheet.Charts.Add();
//chart.Legend.IsVerticalLegend = false;
//chart.Legend.Position = ExcelLegendPosition.Bottom;
chart.HasLegend = false;
IChartSerie serie = chart.Series.Add(ExcelChartType.Pie);
//Enters the X and Y values directly
serie.EnteredDirectlyValues = yValues;
//serie.EnteredDirectlyCategoryLabels = xValues;
application.DefaultVersion = ExcelVersion.Excel2013;
application.XlsIORenderer = new XlsIORenderer();
application.XlsIORenderer.ChartRenderingOptions.ImageFormat = ExportImageFormat.Png;
MemoryStream stream = new MemoryStream();
//Saving the chart as image
chart.SaveAsImage(stream);
stream.Position = 0;
//Download the PDF document in the browser
FileStreamResult fileStreamResult = new FileStreamResult(stream, "image/png");
fileStreamResult.FileDownloadName = "Sample.png";
return fileStreamResult;
}