package com.aspose.slides.examples.Slides.Charts;
import com.aspose.slides.ChartType;
import com.aspose.slides.DataSourceType;
import com.aspose.slides.ErrorBarValueType;
import com.aspose.slides.IChart;
import com.aspose.slides.IChartDataPointCollection;
import com.aspose.slides.IChartSeries;
import com.aspose.slides.IErrorBarsFormat;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import com.aspose.slides.examples.Utils;
public class GetPositionOfChartDataLabel{
public static void main(String[] args) {
ExStart:GetPositionOfChartDataLabel
// The path to the documents directory.
String dataDir = Utils.getDataDir(GetPositionOfChartDataLabel.class);
Presentation pres = new Presentation();
try {
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 500, 400);
for (IChartSeries series : chart.getChartData().getSeries())
{
series.getLabels().getDefaultDataLabelFormat().setPosition(LegendDataLabelPosition.OutsideEnd);
series.getLabels().getDefaultDataLabelFormat().setShowValue(true);
}
chart.validateChartLayout();
for (IChartSeries series : chart.getChartData().getSeries())
{
for (IChartDataPoint point : series.getDataPoints())
{
if (point.getValue().toDouble() > 4)
{
float x = point.getLabel().getActualX();
float y = point.getLabel().getActualY();
float w = point.getLabel().getActualWidth();
float h = point.getLabel().getActualHeight();
IAutoShape shape = chart.getUserShapes().getShapes().addAutoShape(ShapeType.Ellipse, x, y, w, h);
shape.getFillFormat().setFillType(FillType.Solid);
shape.getFillFormat().getSolidFillColor().setColor(new java.awt.Color(0, 255, 0, 100));
}
}
}
pres.save("chartDataLabel.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
ExEnd:GetPositionOfChartDataLabel
}
}