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

Free Support Forum - aspose.com

How to set and get Chart legend and series color using Java

I am generating a column chart below. How can i change the default chart color. Is there a way to position the category names .

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.COLUMN, 432, 252);

Chart chart = shape.getChart();

// Get chart series collection.
ChartSeriesCollection seriesColl = chart.getSeries();

// Delete default generated series.

// Create category names array, in this example we have two categories.
String[] categories = new String[] { "1M", "3M", "1Y", "YTD" };

// Adding new series. Please note, data arrays must not be empty and arrays must be the same size.
seriesColl.add("Series 1", categories, new double[] { 0.73, 5.02, 4.95, 12.51 });
seriesColl.add("Series 2", categories, new double[] { 0.74, 5.16, 7.04, 12.41 });
seriesColl.add("Series 3", categories, new double[] { -0.01, -0.14, -2.09, 0.10 });

chart.getAxisY().getScaling().setMaximum(new AxisBound(14));
chart.getAxisY().getScaling().setMinimum(new AxisBound(-3));

// Save the document in PDF format.


Unfortunately, Aspose.Words does not provide API to change the color of chart legend and series. We will inform you via this forum thread once these features are resolved. The feature IDs are WORDSNET-21056 and WORDSNET-12275. We apologize for your inconvenience.

Could you please ZIP and attach input, problematic and expected output documents? We will then provide you more information on it.

A post was split to a new topic: Set the Chart legend and series color

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