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

Free Support Forum - aspose.com

ChartSeries.DataLabels Missing Position Property

I’m using DocumentBuilder.InsertChart to add a simple Column Chart to a Word document.

The code is working well, but I can’t find how to change the data label position to “Inside End”.

Am I missing something?

@Bill_Hanson,

We do not see any problems during inserting a sample Column Chart in Word document by using following C# code (see column chart output.zip (7.9 KB)):

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Add chart with default data. You can specify different chart types and sizes.
Shape shape = builder.InsertChart(ChartType.Column, 432, 252);

// Chart property of Shape contains all chart related options.
Chart chart = shape.Chart;

// Get chart series collection.
ChartSeriesCollection seriesColl = chart.Series;
// Check series count.
Console.WriteLine(seriesColl.Count);

// Delete default generated series.
seriesColl.Clear();

// Create category names array, in this example we have two categories.
string[] categories = new string[] { "AW Category 1", "AW Category 2" };

// Adding new series. Please note, data arrays must not be empty and arrays must be the same size.
seriesColl.Add("AW Series 1", categories, new double[] { 1, 2 });
seriesColl.Add("AW Series 2", categories, new double[] { 3, 4 });
seriesColl.Add("AW Series 3", categories, new double[] { 5, 6 });
seriesColl.Add("AW Series 4", categories, new double[] { 7, 8 });
seriesColl.Add("AW Series 5", categories, new double[] { 9, 10 });

doc.Save("C:\\Temp\\21.3.docx");

We suggest you to please upgrade to the latest (21.3) version of Aspose.Words for .NET and see how it goes on your end? In case the problem still remains, then please ZIP and attach the following resources here for testing:

  • Your simplified input Word document (if any)
  • Aspose.Words for .NET 21.3 generated output DOCX/PDF file showing the undesired behavior
  • Your expected DOCX/PDF file showing the desired output. You can create this document manually by using MS Word.
  • Please also create a standalone simple Console application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words DLL files in it to reduce the file size.

As soon as you get these pieces of information ready, we will start further investigation into your particular scenario/issue and provide you more information.

Thank you for your reply.

Unfortunately, my question was not how to create a chart. I am able to produce many charts, but now I need to change the position of the data labels in a column chart.

Here is an example of what I would expect, but this does not work because the DataLabels.Position property is not exposed.

ChartSeries series1 = seriesColl.Add(“AW Series 1”, categories, new double[] { 1, 2 });
series1.DataLabels.Position = LabelPositionType.InsideEnd;

This works in Aspose.Cells, but I don’t see how accomplish this in Aspose.Words.

Is it possible to change the position of the data labels in Aspose.Words?

@Bill_Hanson,

We have logged your requirement in our issue tracking system:

  • WORDSNET-21965: Provide API to change Chart’s Data Label Position to Center, Inside End, Inside Base or Outside End

We will further look into the details of this problem and will keep you updated on the status of linked issue. We apologize for any inconvenience.

Hi,
I am currently using 23.1 version of the Aspose.Words.
Has the feature described in WORDSNET-21965 already been implemented and I just do not see it? Or, this is still not supported?
NOTE: I am looking for ability to control position of the data label

@AlexH84 Unfortunately, this feature is not available yet. The issue WORDSNET-21965 is currently postponed and is not yet scheduled for development. So no estimates regarding it are available.
We will be sure to inform you once API for setting data labels position is implemented.