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

Free Support Forum - aspose.com

Formatting the Axis in Dot Net Chart


We have created charts using Aspose.Cells in C# and converted it into image which we finally show on a word document. I have achieved everything related to this but getting some formatting issues.

We want the format of value axis to be percent. As we are returning the values of the chart in a dataset, if we get the final data only with percent format like (70 %), it comes in varchar type from DB and so the chart did not get plotted from it but if we return integers or decimals (70 or 70.75), we can see the graph.

My questions:
1. Can we plot a chart from values return in varchar format from our database. If yes, how?
2. this is more important as I am very close in achieving this. Once the chart is plotted, is there any way in the code where we can change the data format of its axes value? I have checked few properties but did not find the exact solution. Attaching the chart image we have plotted so far.

The highlighted area, we want to show % in front of the values.
Thanks in advance…!!


1) Well, Aspose.Cells creates chart based on existing dataset / range of cells data in the Workook, so you got to import data from your data source/ database to fill the worksheet cells then you may create chart based on the data range accordingly. To import data from database, you may use your own .NET code (using ADO.NET etc.) to fill a DataTable or array, then you may use Aspose.Cells’ data importing options to import data from the source to Excel worksheets. Please see the document on various Data Importing Options provided by Aspose.Cells APIs:

2) Well, you may try to use the following line of code to format your tick labels accordingly:
Sample code:

chart.ValueAxis/ CategoryAxis.TickLabels.NumberFormat = “0%”;

Hope, this helps a bit.

Thank you.

The second option worked perfectly for me.


Good to know that it figures out your issue now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.