I have the following code to generate a pie chart.
IChart chart = sld.getShapes().addChart(ChartType.Doughnut, x, y, width, height);
chart.getChartTitle().addTextFrameForOverriding(" ");
if (null != strategyValue && strategyValue.length() > 0) {
ITextFrame titleTextFrame = chart.getChartTitle().addTextFrameForOverriding("Sample title for PieChart");
for (IParagraph paragraph : titleTextFrame.getParagraphs()) {
for (IPortion portion : paragraph.getPortions()) {
portion.getPortionFormat().setLatinFont(new FontData("Arial"));
portion.getPortionFormat().setFontHeight(8);
}
}
chart.getChartTitle().getTextFrameForOverriding().getTextFrameFormat().setMarginBottom(300);
chart.setTitle(true);
chart.setLegend(false);
chart.getChartTitle().setX(0.63f);
chart.getChartTitle().setY(0.07f);
}
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);
int defaultWorksheetIndex = 0;
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartSeries iChartSeries = chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 1, "series"), chart.getType());
// Setting hole size and colors of the series
iChartSeries.getParentSeriesGroup().setColorVaried(true);
iChartSeries.getParentSeriesGroup().setDoughnutHoleSize((byte) 55);
for (int i = 0; i < listData.size(); i++) {
Map<String, BigDecimal> data = listData.get(i);
for (Entry<String, BigDecimal> l1EntrySet : data.entrySet()) {
iChartSeries.getDataPoints().addDataPointForDoughnutSeries(fact.getCell(defaultWorksheetIndex, i + 1, 1, l1EntrySet.getValue()));
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
series.getDataPoints().get_Item(i).getFormat().getFill().setFillType(FillType.Solid);
series.getDataPoints().get_Item(i).getFormat().getFill().getSolidFillColor().setColor(colorMap.get(l1EntrySet.getKey()) != null ? Color.decode(colorMap.get(l1EntrySet.getKey())) : Color.WHITE);
chart.setLegend(false);
}
}
The title overlaps with the body of the piechart generated.
Is there a way to solve this issue.
I’m using aspose 18.12.