Androidでのプレゼンテーション向けチャート計算の最適化

チャート要素の実際の値を計算する

Aspose.Slides for Android via Java は、これらのプロパティを取得するためのシンプルな API を提供します。IAxis インターフェイスのプロパティは、軸チャート要素の実際の位置に関する情報を提供します(IAxis.getActualMaxValueIAxis.getActualMinValueIAxis.getActualMajorUnitIAxis.getActualMinorUnitIAxis.getActualMajorUnitScaleIAxis.getActualMinorUnitScale。プロパティに実際の値を設定するには、事前にメソッド IChart.validateChartLayout() を呼び出す必要があります。

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

親チャート要素の実際の位置を計算する

Aspose.Slides for Android via Java は、これらのプロパティを取得するためのシンプルな API を提供します。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();
}

チャート要素を非表示にする

このトピックでは、チャートから情報を非表示にする方法を説明します。Aspose.Slides for Android via Java を使用すると、チャートから タイトル、縦軸、横軸 および グリッド線 を非表示にできます。以下のコード例は、これらのプロパティの使用方法を示しています。

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

    //チャートのタイトルを非表示にする
    chart.setTitle(false);

    ///数値軸を非表示にする
    chart.getAxes().getVerticalAxis().setVisible(false);

    //カテゴリ軸の表示
    chart.getAxes().getHorizontalAxis().setVisible(false);

    //凡例を非表示にする
    chart.setLegend(false);

    //主要グリッド線を非表示にする
    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);

    //シリーズ線の色を設定
    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();
}

FAQ

外部の Excel ワークブックをデータ ソースとして使用できますか?また、再計算にどのように影響しますか?

はい。チャートは外部ワークブックを参照できます。外部ソースに接続またはリフレッシュすると、数式と値はそのワークブックから取得され、チャートは開く/編集する操作中に更新を反映します。API を使用すると、外部ワークブックのパスを specify the external workbook で指定し、リンクされたデータを管理できます。

自分で回帰分析を実装せずにトレンドラインを計算・表示できますか?

はい。 Trendlines(線形、指数など)は Aspose.Slides によって追加および更新され、パラメータはシリーズデータから自動的に再計算されるため、独自の計算を実装する必要はありません。

プレゼンテーションに外部リンクを持つ複数のチャートがある場合、各チャートが計算値に使用するワークブックを個別に制御できますか?

はい。各チャートはそれぞれの external workbook を指定できます。または、チャートごとに外部ワークブックを作成または置き換えて、他のチャートとは独立して管理できます。