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?
- Format y-axis as percentage with no decimal places
- Increase the width of the bar and decrease the distance between them
- Rotate the x-axis labels so that we can see all of them
- Adjust the font and font size for both x and y axes
- 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);