Free Support Forum - aspose.com

How to format X/Y/Z Axis and Data Series of chart using .NET

Hi there,


My requirement is to generate the chart shown in RequiredChart.docx. The chart that I’ve drawn using Aspose.Words is in AsposeChart.docx. How do I format the chart generated by Aspose to make it appear as in RequiredChart.docx?

1) Format y-axis as percentage with no decimal places
2) Increase the width of the bar and decrease the distance between them
3) Rotate the x-axis labels so that we can see all of them
4) Adjust the font and font size for both x and y axes
5) Show tick marks on the x axis

Thanks,

Manish

Code:
var doc = new Document();
var builder = new DocumentBuilder(doc);

// Insert Column chart.
Shape shape = builder.InsertChart(ChartType.Column, 432, 252);
Chart chart = shape.Chart;

string[] categories = new[]
{
“Ile-de-France”
, “Rhône-Alpes”
, “Provence-Alpes-C. d’A.”
, “Pays de la Loire”
, “Aquitaine”
, “Nord-Pas-de-Calais”
, “Bretagne”
, “Midi-Pyrénées”
, “Languedoc-Roussillon”
, “Centre”
, “Picardie”
, “Poitou-Charentes”
, “Haute-Normandie”
, “Bourgogne”
, “Basse-Normandie”
, “Lorraine”
, “Franche-Comté”
, “Champagne-Ardenne”
, “Auvergne”
, “Alsace”
, “Outre mere”
, “Limousin”
, “Corse”
};

var values = new double[]
{
0.194372183D,
0.147479912D,
0.083899396D,
0.059394619D,
0.054359659D,
0.049243849D,
0.048839045D,
0.045104807D,
0.043224621D,
0.038800961D,
0.032232298D,
0.027040804D,
0.02532743D,
0.021028801D,
0.020453847D,
0.018948876D,
0.016291886D,
0.016227647D,
0.015733969D,
0.015656409D,
0.014246797D,
0.007295779D,
0.004796405D
};

chart.Series.Clear();
// Use this overload to add series to any type of Bar, Column, Line and Surface charts.
chart.Series.Add(“Regional distribution”, categories, values);

// Saves the document to disk.
string outputFile = “AsposeChart.docx”;
doc.Save(outputFile, SaveFormat.Docx);
Hi Manish,

Thanks for your inquiry. Unfortunately, Aspose.Words does not support the requested features at the moment. However, we have logged these features in our issue tracking system.

WORDSNET-13512 : Add feature to Format X and Y Axis of chart
WORDSNET-13513 : Add feature to format Data Series (Gap Width)

You will be notified via this forum thread once these features are available. We apologize for your inconvenience.

Thanks for the prompt reply Tahir

@mdb123

It is to inform you that we added formatting support of chart axis X/Y/Z in Aspose.Words 17.12.0. We suggest you please read the complete API changes from here:
Aspose.Words for .NET 17.12 Release Notes

For more detail, please read the following article:
How to Set Chart Axis Properties