Adding Error Bars for Charts using Aspose.Slides
Contents
[
Hide
]
Aspose.Slides - Adding Error Bars for Charts
Aspose.Slides for Java provides a simple API for managing error bar values.
The sample code applies when using a custom value type. To specify a value, use theErrorBarCustomValues property of a specific data point in the DataPoints collection of series:
- Create an instance of the Presentation class.
- Add a bubble chart on desired slide.
- Access the first chart series and set the error bar X format.
- Access the first chart series and set the error bar Y format.
- Setting bars values and format.
- Write the modified presentation to a PPTX file.
Java
//Creating empty presentation
Presentation pres = new Presentation();
//Creating a bubble chart
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Bubble, 50, 50, 400, 300, true);
//Adding Error bars and setting its format
IErrorBarsFormat errBarX = chart.getChartData().getSeries().get_Item(0).getErrorBarsXFormat();
IErrorBarsFormat errBarY = chart.getChartData().getSeries().get_Item(0).getErrorBarsYFormat();
errBarX.setVisible(true);
errBarY.setVisible(true);
errBarX.setValueType((byte)ErrorBarValueType.Fixed);
errBarX.setValue(0.1f);
errBarY.setValueType((byte)ErrorBarValueType.Percentage);
errBarY.setValue(5);
errBarX.setType((byte)ErrorBarType.Plus);
errBarY.getFormat().getLine().setWidth(2.0f);
errBarX.setEndCap(true);
//Saving presentation
pres.save(dataDir + "AsposeErrorBars.pptx", SaveFormat.Pptx);
Download Running Code
Download Sample Code
For more details, visit Adding Error Bars For Charts.