Chart Calculations
Calculate Actual Values of Chart Elements
Aspose.Slides for Android via Java provides a simple API for getting these properties. Properties of IAxis interface provide information about actual position of axis chart element (IAxis.getActualMaxValue, IAxis.getActualMinValue, IAxis.getActualMajorUnit, IAxis.getActualMinorUnit, IAxis.getActualMajorUnitScale, IAxis.getActualMinorUnitScale). It is necessary to call method IChart.validateChartLayout() previously to fill properties with actual values.
Presentation pres = new Presentation();
try {
Chart chart = (Chart)pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Area, 100, 100, 500, 350);
chart.validateChartLayout();
double maxValue = chart.getAxes().getVerticalAxis().getActualMaxValue();
double minValue = chart.getAxes().getVerticalAxis().getActualMinValue();
double majorUnit = chart.getAxes().getHorizontalAxis().getActualMajorUnit();
double minorUnit = chart.getAxes().getHorizontalAxis().getActualMinorUnit();
} finally {
if (pres != null) pres.dispose();
}
Calculate Actual Position of Parent Chart Elements
Aspose.Slides for Android via Java provides a simple API for getting these properties. Properties of IActualLayout interface provide information about actual position of parent chart element (IActualLayout.getActualX, IActualLayout.getActualY, IActualLayout.getActualWidth, IActualLayout.getActualHeight). It is necessary to call method IChart.validateChartLayout() previously to fill properties with actual values.
Presentation pres = new Presentation();
try {
Chart chart = (Chart) pres.getSlides().get_Item(0).getShapes().addChart(ChartType.ClusteredColumn, 100, 100, 500, 350);
chart.validateChartLayout();
double x = chart.getPlotArea().getActualX();
double y = chart.getPlotArea().getActualY();
double w = chart.getPlotArea().getActualWidth();
double h = chart.getPlotArea().getActualHeight();
} finally {
if (pres != null) pres.dispose();
}
Hide Information from Chart
This topic helps you to understand how to hide information from chart. Using Aspose.Slides for Android via Java you can hide Title, Vertical Axis, Horizontal Axis and Grid Lines from chart. Below code example shows how to use these properties.
Presentation pres = new Presentation();
try {
ISlide slide = pres.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.LineWithMarkers, 140, 118, 320, 370);
//Hiding chart Title
chart.setTitle(false);
///Hiding Values axis
chart.getAxes().getVerticalAxis().setVisible(false);
//Category Axis visibility
chart.getAxes().getHorizontalAxis().setVisible(false);
//Hiding Legend
chart.setLegend(false);
//Hiding MajorGridLines
chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
for (int i = 0; i < chart.getChartData().getSeries().size(); i++)
{
chart.getChartData().getSeries().removeAt(i);
}
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
series.getMarker().setSymbol(MarkerStyleType.Circle);
series.getLabels().getDefaultDataLabelFormat().setShowValue(true);
series.getLabels().getDefaultDataLabelFormat().setPosition(LegendDataLabelPosition.Top);
series.getMarker().setSize(15);
//Setting series line color
series.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
series.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.MAGENTA);
series.getFormat().getLine().setDashStyle(LineDashStyle.Solid);
pres.save("HideInformationFromChart.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}