aspose-words / Aspose.Words-for-Java

Aspose.Words for Java examples, plugins and showcases
https://products.aspose.com/words/java
MIT License
403 stars 206 forks source link

builder.insertChart() How can set different colors #72

Closed tanhuang2016 closed 3 years ago

tanhuang2016 commented 3 years ago

The sample code

public void HideChartAxis(String dataDir) throws Exception
{
    // ExStart:HideChartAxis
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    Shape shape = builder.insertChart(ChartType.COLUMN, 432, 252);
    Chart chart = shape.getChart();

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

    // Add a custom series with categories for the X-axis, and respective decimal values for the Y-axis.
    chart.getSeries().add("AW Series 1",
            new String[]{"Item 1", "Item 2", "Item 3", "Item 4", "Item 5"},
            new double[]{1.2, 0.3, 2.1, 2.9, 4.2});

    // Hide the axis
    chart.getAxisY().setHidden(true);

    dataDir = dataDir + "HideChartAxis_out.docx";
    doc.save(dataDir);
    //ExEnd:HideChartAxis
    System.out.println("\nY Axis of chart has been hidden successfully. \nFile saved at " + dataDir);
}

like this image

how to set different colors image

AlexNosk commented 3 years ago

@tanhuang2016 The requested feature will be available in the next version of Aspose.Words through the ChartDataPoint class. The corresponding issue number is WORDSNET-12275. We will let you know once the next version is available (in a week or two).

AlexNosk commented 3 years ago

The issues you have found earlier (filed as WORDSNET-12275) have been fixed in this Aspose.Words 21.6. You can download it here: https://downloads.aspose.com/words/java Also see the release notes for code example. https://docs.aspose.com/words/java/aspose-words-for-java-21-6-release-notes/#implemented-ability-to-set-fill-and-stroke-formatting-for-chart-series-data-points-and-markers