Adding Error Bars for Charts using Aspose.Slides

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:

  1. Create an instance of the Presentation class.
  2. Add a bubble chart on desired slide.
  3. Access the first chart series and set the error bar X format.
  4. Access the first chart series and set the error bar Y format.
  5. Setting bars values and format.
  6. 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