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

Free Support Forum - aspose.com

How to create charts in ASPOSE Word

Hi,


How to create BAR chart, PIE chart and line charts in ASPOSE Word for .Net.

Note: I am not looking to create charts in aspose.cell and copy it as image in word document.

Regards,
Aniket Khorjuvekar

Hi Aniket,


Thanks for your inquiry. Please upgrade to the latest version of Aspose.Words for .NET 15.10.0 and refer to the following section of documentation:

Working with Charts using Aspose.Words

Best regards,

Thanks.


I have few additional questions:

1) How to add border on all four sides for the chart.
2) How to provide title to value axis. (Y axis)
2) How to change color of category series.

Output is attached with the post. Please find the code below. Thanks.

Code:
Shape shape = builder.InsertChart(ChartType.Column, 473, 165);

Chart chart = shape.Chart;
chart.Title.Text = chartTitle;
chart.Title.Overlay = false;
chart.Legend.Position = LegendPosition.Right;
chart.Legend.Overlay = false;

ChartSeriesCollection seriesColl = chart.Series;
seriesColl.Clear();

string[] categories = categoryName;
seriesColl.Add(“Existing Solution”, categories, new double[] { existingUnits });
seriesColl.Add(“Recommended Solution”, categories, new double[] { replacementUnits });


Hi Aniket,

Thanks for your inquiry. Could you please attach your input Word document and expected document here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document using Microsoft Word. We will then provide you code to achieve the same using Aspose.Words.

Best regards,

Hi Awais,


Input document can be an new document/empty word file.
Expected output is attached with the post.

Also please refer to the code currently used and output generated through that code given in previous post.

Regards,
Aniket Khorjuvekar

Hi Awais,


Do you have any updated on below queries?

Also along with other questions, can you please also let me know the alternative for below code in aspose.word. Below code works for Aspose.cell.
chart.ValueAxis.TickLabels.NumberFormat = “0%”;

Regards,
Aniket

Hi Aniket,


Thanks for your inquiry. We are working over your query and will get back to you soon.

Best regards,

Hi,


Do we have any updates on above queries. Its been couple of weeks I are waiting for the update.

Please do the needful.

Regards,
Aniket

Hi Aniket,


Thanks for being patient. We have logged following issues in our issue tracking system.

WORDSNET-12746: Provide Border API for Chart Area
WORDSNET-12747: Provide API to set Vertical (Value) Axis Title of Chart
WORDSNET-12748: Provide API to change Color of Category Series of Chart

Your thread has also been linked to these issues and you will be notified as soon as these issues are resolved. Sorry for the inconvenience.

Best regards,

Thanks for the reply.


Can you please let me know if we can have a line indicating 80% and 100% in column chart as per image attached with the post.

Regards,
Aniket
Hi Aniket,

Thanks for sharing the image but please also attach real expected Word document here for our reference.

Best regards,

Please find attached word report.

Hi Aniket,


Thanks for the additional information. We have logged the following issue in our issue tracking system and will update you as soon as it is resolved. Sorry for the inconvenience.

WORDSNET-12769: Support creation of Composite Charts

Best regards,

Hi Aniket,


Regarding WORDSNET-12746, a Chart is just a simple shape with all related properties. So to make border around shape you have to use Stroke property of shape as follows:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

// Add chart with default data.

Shape shape = builder.InsertChart(ChartType.Column, 432, 252);

shape.Stroke.On = true;

shape.Stroke.Color = Color.Red;

doc.Save(MyDir + @"16.1.0.docx");


Hope, this helps.

Best regards,

The issues you have found earlier (filed as WORDSNET-12748) have been fixed in this Aspose.Words for .NET 21.6 update and this Aspose.Words for Java 21.6 update.