We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Labels on Outside End with stacked column chart

Hi,

I am using version of Aspose.Cells 7.2.2 to draw 100% Stacked column chart. And in some cases chart data labels are overlapping.
Is there a way to get the labels on the Outside End with a stacked column chart?

Thanks

Hi,

Thanks for your posting and using Aspose.Cells.

Please download and try the latest version: Aspose.Cells
for .NET v8.5.0.3
it should resolve this issue.

If your issue still occurs, then please provide us your sample excel file with your chart and sample code replicating this issue. We will look into it and help you asap.

Hi,


Thank you for the update.

I tried 100% Stacked column chart with the latest version i.e. Aspose.Cells for .NET v8.5.0.3. But this is not solving my problem. Attaching here the code snippet and output chart image file for the same.

Worksheet worksheet = workbook.Worksheets[0];
worksheet.Name = “Data”;
int sheetIndex = workbook.Worksheets.Add(SheetType.Chart);
Worksheet sheet = workbook.Worksheets[sheetIndex];
//Set the name of worksheet
sheet.Name = “StackedBarChart”;
sheetIndex = sheet.Charts.Add(ChartType.Column100PercentStacked, 0, 0, 0, 0);
//Initialize Chart
Chart chart = sheet.Charts[sheetIndex];

Cells cells = workbook.Worksheets[sheetIndex].Cells;
cells[“A1”].PutValue(“Item”);
cells[“B1”].PutValue(“1”);
for (int rowIndex = 0; rowIndex < 6; rowIndex++)
{
cells[“A” + (rowIndex + 2).ToString()].PutValue(“LG” + (rowIndex+1));
rowIndex = rowIndex + 1;
}
cells[“B” + (0 + 2).ToString()].PutValue(4.5);
cells[“B” + (1 + 2).ToString()].PutValue(0.4);
cells[“B” + (2 + 2).ToString()].PutValue(0.4);
cells[“B” + (4 + 2).ToString()].PutValue(0.5);
cells[“B” + (5 + 2).ToString()].PutValue(0);
cells[“B” + (6 + 2).ToString()].PutValue(94.2);
chart.NSeries.Add(“Data!B2:B” + “8”, false);
chart.NSeries.CategoryData = “Data!B1:B1”;

DataLabels datalabels;
for (int i = 0; i < chart.NSeries.Count; i++)
{
chart.NSeries[i].HasLeaderLines = true;
datalabels = chart.NSeries[i].DataLabels;
datalabels.ShowValue = true;
datalabels.NumberFormat = “#0.0”%"";
datalabels.Font.Name = “Arial”;
datalabels.Font.Size = 8;
datalabels.ShowPercentage = true;
datalabels.ShowLegendKey = false;
datalabels.Position = LabelPositionType.OutsideEnd;
}

chart.NSeries.IsColorVaried = true;


Thanks,

Hi,

Thanks for your posting and using Aspose.Cells.

We have looked into this issue and noticed the issue. However to investigate this issue further, we need your actual output excel file and the expected output excel file. You can create your expected output excel file manually using Microsoft Excel.

Please also let us know what steps did you take in Microsoft Excel to fix your expected output excel file.

I have attached the actual output excel file generated with your code for a reference.

C#


Workbook workbook = new Workbook();


Worksheet worksheet = workbook.Worksheets[0];

worksheet.Name = “Data”;


int sheetIndex = workbook.Worksheets.Add(SheetType.Chart);


Worksheet sheet = workbook.Worksheets[sheetIndex];

//Set the name of worksheet

sheet.Name = “StackedBarChart”;

sheetIndex = sheet.Charts.Add(ChartType.Column100PercentStacked, 0, 0, 0, 0);


//Initialize Chart

Chart chart = sheet.Charts[sheetIndex];


Cells cells = workbook.Worksheets[sheetIndex].Cells;

cells[“A1”].PutValue(“Item”);

cells[“B1”].PutValue(“1”);

for (int rowIndex = 0; rowIndex < 6; rowIndex++)

{

cells[“A” + (rowIndex + 2).ToString()].PutValue(“LG” + (rowIndex + 1));


rowIndex = rowIndex + 1;

}


cells[“B” + (0 + 2).ToString()].PutValue(4.5);

cells[“B” + (1 + 2).ToString()].PutValue(0.4);

cells[“B” + (2 + 2).ToString()].PutValue(0.4);


cells[“B” + (4 + 2).ToString()].PutValue(0.5);

cells[“B” + (5 + 2).ToString()].PutValue(0);

cells[“B” + (6 + 2).ToString()].PutValue(94.2);

chart.NSeries.Add(“Data!B2:B” + “8”, false);

chart.NSeries.CategoryData = “Data!B1:B1”;


DataLabels datalabels;

for (int i = 0; i < chart.NSeries.Count; i++)

{

chart.NSeries[i].HasLeaderLines = true;

datalabels = chart.NSeries[i].DataLabels;

datalabels.ShowValue = true;

datalabels.NumberFormat = “#0.0”%"";

datalabels.Font.Name = “Arial”;

datalabels.Font.Size = 8;

datalabels.ShowPercentage = true;

datalabels.ShowLegendKey = false;

datalabels.Position = LabelPositionType.OutsideEnd;

}


chart.NSeries.IsColorVaried = true;


workbook.Save(“output.xls”);


Hello Aspose Support Team,

Expected output in our case is to show values for all the sections/bars on chart clearly.However in current scenario some values are showing up as overlapping with each other. Actual output (with values being shown as overlapping) is already sent. Sample for expected output cannot be actually make out using excel for the same scenario. Not sure if this helps. Also wanted to check if a property to control ‘allow overlapping’ OR to show values as ‘callouts’ to avoid any overlapping; attaching a different scenario snapshot ‘just to specify callouts’ though in a different chart format.
Please note this quite ‘urgent’ for us because we have client going live using this functionality by the end of this month.



Thanks,
Jyoti

Hi Jyoti,

Thanks for your posting and using Aspose.Cells.

Aspose.Cells provides the subset of the Microsoft Excel functionality. It seems you cannot fix the overlapping of the labels problem which you are facing and is present inside the output.xls attached earlier using Microsoft Excel.

If something could not be fixed with Microsoft Excel then it can also not be fixed by Aspose.Cells.