Cálculos de Gráficos

Calcular Valores Reales de Elementos del Gráfico

Aspose.Slides para Android a través de Java proporciona una API simple para obtener estas propiedades. Las propiedades de la interfaz IAxis proporcionan información sobre la posición real del elemento de gráfico del eje (IAxis.getActualMaxValue, IAxis.getActualMinValue, IAxis.getActualMajorUnit, IAxis.getActualMinorUnit, IAxis.getActualMajorUnitScale, IAxis.getActualMinorUnitScale). Es necesario llamar al método IChart.validateChartLayout() previamente para llenar las propiedades con valores reales.

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();
}

Calcular la Posición Real de los Elementos del Gráfico Padre

Aspose.Slides para Android a través de Java proporciona una API simple para obtener estas propiedades. Las propiedades de la interfaz IActualLayout proporcionan información sobre la posición real del elemento de gráfico padre (IActualLayout.getActualX, IActualLayout.getActualY, IActualLayout.getActualWidth, IActualLayout.getActualHeight). Es necesario llamar al método IChart.validateChartLayout() previamente para llenar las propiedades con valores reales.

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();
}

Ocultar Información del Gráfico

Este tema te ayuda a entender cómo ocultar información del gráfico. Usando Aspose.Slides para Android a través de Java puedes ocultar Título, Eje Vertical, Eje Horizontal y Líneas de Cuadrícula del gráfico. El siguiente ejemplo de código muestra cómo usar estas propiedades.

Presentation pres = new Presentation();
try {
    ISlide slide = pres.getSlides().get_Item(0);
    IChart chart = slide.getShapes().addChart(ChartType.LineWithMarkers, 140, 118, 320, 370);

    //Ocultando el Título del gráfico
    chart.setTitle(false);

    //Ocultando el eje de Valores
    chart.getAxes().getVerticalAxis().setVisible(false);

    //Visibilidad del Eje de Categoría
    chart.getAxes().getHorizontalAxis().setVisible(false);

    //Ocultando la Leyenda
    chart.setLegend(false);

    //Ocultando las Líneas de la Cuadrícula Mayor
    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);

    //Estableciendo el color de línea de la serie
    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();
}