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

Free Support Forum - aspose.com

Edit font size , format number in chart column in aspose word version 19.9

Hi there,
As title, How to edit font size the chart, format number in the chart with aspose 19.9?
For example, when number in the chart is 100000( one hunderd thoudsand), I want it display with format is: 1.000.000.
Thanks so much !

@Tran_Tan_Thinh Unfortunately, currently there is no public API to change font size of title in charts. This feature request has been logged in our defect tracking system as WORDSNET-13661. We will keep you informed and let you know once this feature is available.
You can use ChartAxis.NumberFormat to specify format of numbers in chart axis.

Hi @alexey.noskov,
I tried using NumberFormat as you mentioned. But seemes it’s not active.
I tried to debug with my format pattern in java, then results as my expected result. But, pass the pattern into the function of aspose then got unexpected result. Can you give me one pattern for Euro format number (as mentioned) ? Thanks !

@Tran_Tan_Thinh You can use the following simple format code: "#,##0". However, you should note that MS Word uses the current system locale to format values in chart. For example see the following simple code:

Locale currentLocale = CurrentThreadSettings.getLocale();
CurrentThreadSettings.setLocale(Locale.GERMANY);

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape = builder.insertChart(ChartType.COLUMN, 500, 300);
Chart chart = shape.getChart();

// Clear the chart's demo data series to start with a clean chart.
chart.getSeries().clear();

// Add a custom series to the chart with categories for the X-axis,
// and large respective numeric values for the Y-axis.
chart.getSeries().add("Aspose Test Series",
        new String[] { "Word", "PDF", "Excel", "GoogleDocs", "Note" },
        new double[] { 1900000, 850000, 2100000, 600000, 1500000 });

// Set the number format of the Y-axis tick labels to not group digits with commas.
chart.getAxisY().getNumberFormat().setFormatCode("#,##0");

doc.save("C:\\Temp\\out.docx");
doc.save("C:\\Temp\\out.pdf");

CurrentThreadSettings.setLocale(currentLocale);

out.docx (8.7 KB)
out.pdf (19.8 KB)

If you open the output PDF you will notice that dot is used as groups delimiter, but if you open DOCX document in MS Word, it will use groups delimiter from your locale settings:

@alexey.noskov, Thanks so much ! It’s worrking.
About font size, you can see label on the top of the column, if text of the label is long, then texts will be overlapping mutually. How to increase width of column or increase/decrease font size ? Thanks !
image.png (32.1 KB)

@Tran_Tan_Thinh Unfortunately, currently there is no way to change font size of data labels in charts. This feature request is logged as WORDSNET-15706. We will let you know once it is supported.
In MS Word width of columns can be adjusted using Gap Width and Series Overlap properties. Unfortunately, Aspose.Words does not provide API to adjust these properties. This feature is logged as WORDSNET-17602.

Currently the only way to avoid data labels overlapping is increasing width of whole chart.

Hi @alexey.noskov,
At the moment, I also was finding a way to custom color legend in the chart. Can you please suggest one function to do that?
The library is so new for me.

@Tran_Tan_Thinh You can achieve this by customizing Series colors using ChartSeries.Format.

@alexey.noskov In my java code, I call series1.Format.Fill.ForeColor = Color.Red as the example then an error of compile-time occurs. I also tried to call it by method get set but the error is still occur

@Tran_Tan_Thinh This feature is available starting 21.6 version of Aspose.Words.
Also, here is Java example:
https://apireference.aspose.com/words/java/com.aspose.words/chartformat#Fill