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

Free Support Forum - aspose.com

Word template - How to format legend line spacing

Hi

I am using Aspose.Words for .NET 18.9.0 (Core Standard 2.0).
A chart in a given Word document that is used as a template shall be changed programatically.
The chart in the template is prepared with one series that has 12 categories with labels and values.

My logic that creates the report clears the series and adds the categories sourced by a database.
The issue is that the legend text (category text) line spacing cannot be set. Instead the spacing is set automatically dependend on the number of categories I added to the series.

Is there a way to format the legend text in a Piechart?

I use the following code snipped to modify the Word Template that contains a chart:

public class MyChartCategory
{
public string CategoryText { get; set; } //title and percentage string
public double CategoryAmount { get; set; }
public int Order { get; set; }
}

var categories = new List { new MyChartCategory { CategoryText = “Apple”, CategoryAmount = 30, Order = 1 }, new MyChartCategory { CategoryText = “Grape”, CategoryAmount = 70, Order = 2 };

NodeCollection shapes = document.GetChildNodes(NodeType.Shape, true);
        foreach (Shape shape in shapes)
        {
            if (shape.HasChart)
            {
                var chart = shape.Chart;
                if (chart != null)
                {
                    bookmarks[bookMarkName].Text = string.Empty;
                    shape.Chart.Series.Clear();
                    var va = categories.OrderBy(c => c.Order).Select(c => c.CategoryAmount).ToArray();
                    var ca = categories.OrderBy(c => c.Order).Select(c => c.CategoryText).ToArray();
                    shape.Chart.Series.Add("MyCategories", ca, va);

                    break;
                }
            }
        }

@bck

Could you please ZIP and attach your input and expected output Word documents here for our reference? We will then provide you more information about your query.