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

Free Support Forum - aspose.com

Doughnut Chart - data labels

Not able to show data labesl out side the doughnut charts .

working with pie charts-
chart.NSeries[i].HasLeaderLines = true;

what else to do in doughnut charts.

Hi,


Thanks for your query.

How could you do this in Ms Excel manually using Format Data Labels options for a doughnut chart? If you think this is possible in MS Excel manually, kindly provide a sample Excel file containing your desired chart, we will check it on how to do it via Aspose.Cells APIs. Also provide your current output Excel file via Aspose.Cells APIs.

Thank you.

No ,this is not possible in ms excel . but is there some other option to avoid labels overlapping.

Hi,


Well, I am afraid, there is no better way to do it. I think you may try to extend the width/height of your chart object(s).

Thank you.

Hi,


I have searched a lot and found a solution in excel by which we can genetate donut charts with legend lines and tried also it works-
Please check this- http://www.extendoffice.com/documents/excel/2326-doughnut-chart-leader-lines.html#a1

Also find the attached excel sheet.


Now Please let me know how this can be done in aspose.cells.



Thanks
Noopur

Hi,


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.
e.g
Sample code:

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.

Thanks a lot…it seems to be helpful

One more question -


when iam saving the chart as image in that case leader lines are not shown in the image
–doughnut_chart2.png

Please let me know the solution

Code-
Workbook workbook1 = new Workbook(“c:\work\doughnut_chart1.xlsx”);

Worksheet sheet1 = workbook1.Worksheets[0];

int chartIndex1 = 0;
chartIndex1 = sheet1.Charts.Add(ChartType.Doughnut, 1, 1, 25, 10);
Chart chart2 = sheet1.Charts[chartIndex];
//Set properties of chart
chart2.PlotArea.Area.Formatting = FormattingType.None;
chart2.PlotArea.Border.IsVisible = false;


//Set properties of nseries
chart2.NSeries.Add(“B2:B4”, true);
chart2.NSeries.CategoryData = “A2:A4”;
chart2.NSeries.IsColorVaried = true;

//Set the ChartArea
ChartArea chartarea = chart2.ChartArea;
//Show legend
chart2.ShowLegend = true;

//Insert another series of Pie chart type.
int index = chart2.NSeries.Add(“B2:B4”, true);
Series series = chart2.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
chart2.Calculate();
int DELTA = 100;
for (int i = 0; i < series.Points.Count; i++)
{

int X = series.Points[i].DataLabels.X;
if (X > 2000)

series.Points[i].DataLabels.X = X + DELTA;

else

series.Points[i].DataLabels.X = X - DELTA;

}

chart2.ToImage(“c:\work\doughnut_chart2.png”);
//Save the excel file
workbook1.Save(“c:\work\doughnut_chart2.xlsx”);


------------------------------------------------

Hi,


Which version of the product you are using?

We recommend you to kindly try our latest version/ fix: Aspose.Cells for .NET v8.6.1.1

I have tested with it, it works fine and the leader lines are shown for the data labels.

Thank you.

its 7.7.2 version …is it because of that .


Can you please let me know if it works with this version or not?


have to got my question i wonder…?
the leader lines are shown in excel sheet but not shown when saving as image.


because i have added the dll version you shared still iam not able to see the leader lines in image.


Hi,


I am afraid, we cannot check your issue in older version, neither we could fix issues in older versions if there is any bug in the older versions. We only evaluate issues in the latest APIs set and can fix issues (if found) in the latest versions of the product.

So, kindly try using our latest version and then share the results. Also, you might not use the latest version with your existing license (your license might be expired to use latest versions of the product), so you may comment out the lines of code regarding setting license.

Thank you.

Hi,


Please see the screen shot of the image using my previous sample code (with addition of line: chart.ToImage(“e:\test2\out1doughnut_chart1.png”);), it is Ok:
http://prntscr.com/8waj9u

Thank you.

ok will try to do it again …but in your shared screen shot no leader line is shown for the percentage -4%.


this is happening with me also when displayed in excel

Hi,


Yes, this is one minor issue which our product team can try to fix it (if possible). Do you need us to log a ticket for it to fix that issue in latest versions?

Thank you.

yes Please fix that and let me know

Iam able to see the leader lines in image also now with this newer version …the only thing iam stuck is with the previous issue -one % is now showing the leader line in my image also-

please see the attached image.

And let me know the solution.

Hi,


Thanks for the screen shot.

As I already observed the issue. I found all leader lines are shown with the data labels except for one data label (“4%”) in the output image for the custom oriented chart. I have logged a ticket with an id “CELLSNET-44026” for your issue into our database. Our concerned developer from product team will look into it and try to figure it out (if possible) soon.

Once we have any update on it, we will let you know here.

Thank you.

Hi,


Please try our latest version/fix: Aspose.Cells for .NET v8.6.1.6 (attached).

We have fixed your issue “CELLSNET-44026” now.

Let us know here your feedback.

Thank you.

The issues you have found earlier (filed as CELLSNET-44026) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
Hi,

I have used v8.6.1.6 version of Aspose.Cells
to generate Doughnut Chart with data labels. It works fine.

Currently in my solution I am using v7.2.2.0.

I am planning to upgrade my Aspose.Cells dll but before
that I want to know the major differences between v7.2.2.0 and v8.6.1.6
versions of Aspose.Cells.

Please let me know.

Thanks
Harsh Kulshreshtha