aspose-words / Aspose.Words-for-Java

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

the overlapping of labels and values for pie charts #99

Open fusheng-fate opened 1 year ago

fusheng-fate commented 1 year ago

how to deal with the overlapping of labels and values for pie charts? Can I set the percentage accuracy of the label?

AlexNosk commented 1 year ago

@fusheng-fate Could you please attach your source and output documents here for testing? We will check the issue and provide you more information.

PS: the main place for getting support is Aspose.Words support forum. It is better to post the questions there to get faster reply.

fusheng-fate commented 1 year ago
@Test
public void testas() throws Exception {

    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);
    // Insert a chart shape with a document builder and get its chart.
    Shape chartShape = builder.insertChart(ChartType.PIE, 432, 256);
    Chart chart = chartShape.getChart();
    chart.getSeries().clear();
    chart.getSeries().add("Aspose Test Series",
            new String[]{"Word", "PDF", "Excel", "GoogleDocs", "Note"},
            new double[]{500.0, 1.0, 1.0, 2.0, 2.0});

    ChartDataLabelCollection dataLabels = chart.getSeries().get(0).getDataLabels();
    for (int i = 0; i < 5 ; i++) {
        dataLabels.add(i).setShowLeaderLines(true);
        dataLabels.get(i).setShowPercentage(true);
        dataLabels.get(i).setShowValue(true);
        dataLabels.get(i).getNumberFormat().setFormatCode("0.00%");
        dataLabels.get(i).setShowDataLabelsRange(true);
    }
    // Use the "Title" property to give our chart a title, which appears at the top center of the chart area.
    ChartTitle title = chart.getTitle();
    title.setText("My Chart");
    // Set the "Show" property to "true" to make the title visible.
    title.setShow(true);
    // Set the "Overlay" property to "true" Give other chart elements more room by allowing them to overlap the title
    title.setOverlay(false);
    doc.save("d:/" + "Charts.ChartTitle.docx");
}

aspose_pie

fusheng-fate commented 1 year ago

@AlexNosk Thank you for your reply. This is my test code. I have found a corresponding API to handle the issue of setting percentage accuracy, but the issue of overlapping labels cannot be resolved.

AlexNosk commented 1 year ago

@fusheng-fate Unfortunately, currently there is no way to specify position of data labels. This feature request is logged as WORDSNET-21965. We will keep you updated and let you know once it is resolved.

fusheng-fate commented 1 year ago

@AlexNosk Thank you.