Hi,
Here is what I want it to look like:
image.png (86.3 KB)
Here is sample code:
IChart chart = donutChart = slide.getShapes().addChart(ChartType.Doughnut,
Utils.getPixelValue(6.23f),//x
Utils.getPixelValue(2.36f),//y
Utils.getPixelValue(17.96f),//width
Utils.getPixelValue(16.19f), false);//height
IChartDataWorkbook workBook = chart.getChartData().getChartDataWorkbook();
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
chart.setLegend(false);
ArrayList mySeries = new ArrayList();
int seriesIndex = 0;
while (seriesIndex < 15) {
IChartSeries series = chart.getChartData().getSeries().add(workBook.getCell(0, 0, seriesIndex+1, "SERIES "+seriesIndex),chart.getType());
series.setExplosion(0);
series.getParentSeriesGroup().setDoughnutHoleSize((byte)20);
series.getParentSeriesGroup().setFirstSliceAngle(351);
seriesIndex++;
}
int categoryIndex = 0;
while (categoryIndex < 15) {
chart.getChartData().getCategories().add(workBook.getCell(0, categoryIndex+1, 0, "CATEGORY "+categoryIndex));
int i = 0;
while (i < chart.getChartData().getSeries().size()) {
IChartSeries iCS = chart.getChartData().getSeries().get_Item(i);
IChartDataPoint dataPoint = iCS.getDataPoints().addDataPointForDoughnutSeries(workBook.getCell(0, categoryIndex+1, i+1, 1));
dataPoint.getFormat().getFill().setFillType(FillType.Solid);
dataPoint.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
dataPoint.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.WHITE);
dataPoint.getFormat().getLine().setWidth(1);
dataPoint.getFormat().getLine().setStyle(LineStyle.Single);
dataPoint.getFormat().getLine().setDashStyle(LineDashStyle.Solid);
//call out labels just on the outer ring
if (i==chart.getChartData().getSeries().size()-1) {
IDataLabel lbl = dataPoint.getLabel();
lbl.getTextFormat().getTextBlockFormat().setAutofitType(TextAutofitType.Shape);
lbl.getDataLabelFormat().getTextFormat().getPortionFormat().setFontBold(NullableBool.True);
lbl.getDataLabelFormat().getTextFormat().getPortionFormat().setLatinFont (new FontData("DINPro-Bold"));
lbl.getDataLabelFormat().getTextFormat().getPortionFormat().setFontHeight(12);
lbl.getDataLabelFormat().getTextFormat().getPortionFormat().getFillFormat().setFillType (FillType.Solid );
lbl.getDataLabelFormat().getTextFormat().getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.LIGHT_GRAY);
lbl.getDataLabelFormat().getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.WHITE);
lbl.getDataLabelFormat().setShowValue(false);
lbl.getDataLabelFormat().setShowCategoryName(true);
lbl.getDataLabelFormat().setShowSeriesName(false);
lbl.getDataLabelFormat().setShowLabelAsDataCallout(true);
lbl.getDataLabelFormat().setShowLeaderLines(true);
//lbl.getDataLabelFormat().getPosition();
}
i++;
}
categoryIndex++;
}
Generated chart looks like this:
image.png (36.7 KB)
Notice that I moved the label for category 13 so you can see the leader line.
Don’t worry about colours and fonts I can do that.
Challenges are:
- How can I change the data callout shape to rectangle
- How can I then get rid of the line that makes a border around the rectangle so all you see is the text
- How can I move the data callout outside the donut (I guess I can use the setPosition) for this but I haven’t tried yet
This is how to change the callout shape in PowerPoint:
change-data-callout-shape.png (45.8 KB)
Any help much appreciated
Thanks,
Andy