public static void main(String[] args) {

    // The path to the documents directory.
    String dataDir = Utils.getDataDir(SettingCustomRotationAngleForTextframe.class);

    Presentation pres = new Presentation();

    IChart chart =
        pres.getSlides()
            .get_Item(0)
            .getShapes()
            .addChart(ChartType.ClusteredColumn, 50, 50, 500, 300);

    IChartSeries series = chart.getChartData().getSeries().get_Item(0);

    series.getLabels().getDefaultDataLabelFormat().setShowCategoryName(true);
    series
        .getLabels()
        .getDefaultDataLabelFormat()
        .getTextFormat()
        .getTextBlockFormat()
        .setRotationAngle(65);

    chart.hasTitle();
    chart
        .getChartTitle()
        .addTextFrameForOverriding("Custom title")
        .getTextFrameFormat()
        .setRotationAngle(-30);

    pres.save(dataDir + "out.pptx", SaveFormat.Pptx);
  }
  public static void main(String[] args) {

    // The path to the documents directory.
    String dataDir = Utils.getDataDir(AddingCustomErrorBarValueForChart.class);

    // 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 custom Error bars and setting its format
    IChartSeries series = chart.getChartData().getSeries().get_Item(0);
    IErrorBarsFormat errBarX = series.getErrorBarsXFormat();
    IErrorBarsFormat errBarY = series.getErrorBarsYFormat();
    errBarX.isVisible();
    errBarY.isVisible();
    errBarX.setValueType((byte) ErrorBarValueType.Custom);
    errBarY.setValueType((byte) ErrorBarValueType.Custom);

    // Accessing chart series data point and setting error bars values for
    // individual point
    IChartDataPointCollection points = series.getDataPoints();
    points
        .getDataSourceTypeForErrorBarsCustomValues()
        .setDataSourceTypeForXPlusValues((byte) DataSourceType.DoubleLiterals);
    points
        .getDataSourceTypeForErrorBarsCustomValues()
        .setDataSourceTypeForXMinusValues((byte) DataSourceType.DoubleLiterals);
    points
        .getDataSourceTypeForErrorBarsCustomValues()
        .setDataSourceTypeForYPlusValues((byte) DataSourceType.DoubleLiterals);
    points
        .getDataSourceTypeForErrorBarsCustomValues()
        .setDataSourceTypeForYMinusValues((byte) DataSourceType.DoubleLiterals);

    // Setting error bars for chart series points
    for (int i = 0; i < points.size(); i++) {
      points.get_Item(i).getErrorBarsCustomValues().getXMinus().setAsLiteralDouble(i + 1);
      points.get_Item(i).getErrorBarsCustomValues().getXPlus().setAsLiteralDouble(i + 1);
      points.get_Item(i).getErrorBarsCustomValues().getYMinus().setAsLiteralDouble(i + 1);
      points.get_Item(i).getErrorBarsCustomValues().getYPlus().setAsLiteralDouble(i + 1);
    }

    // Saving presentation
    pres.save(dataDir + "ErrorBarsCustomValues.pptx", SaveFormat.Pptx);
  }
コード例 #3
0
  public static void main(String[] args) {

    // The path to the documents directory.
    String dataDir = Utils.getDataDir(UpdatingExistingChart.class);

    // Instantiate Presentation class that represents PPTX file
    Presentation pres = new Presentation(dataDir + "ExistingChart.pptx");

    // Access first slide
    ISlide sld = pres.getSlides().get_Item(0);

    // Add chart with default data
    IChart chart = (IChart) sld.getShapes().get_Item(0);

    // Setting the index of chart data sheet
    int defaultWorksheetIndex = 0;

    // Getting the chart data WorkSheet
    IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();

    // Changing chart Category Name
    fact.getCell(defaultWorksheetIndex, 1, 0, "Modified Category 1");
    fact.getCell(defaultWorksheetIndex, 2, 0, "Modified Category 2");

    // Take first chart series
    IChartSeries series = chart.getChartData().getSeries().get_Item(0);

    // Now updating series data
    fact.getCell(defaultWorksheetIndex, 0, 1, "New_Series1");

    // modifying series name
    series.getDataPoints().get_Item(0).getValue().setData(90);
    series.getDataPoints().get_Item(1).getValue().setData(123);
    series.getDataPoints().get_Item(2).getValue().setData(44);

    // Take Second chart series
    series = chart.getChartData().getSeries().get_Item(1);

    // Now updating series data
    fact.getCell(defaultWorksheetIndex, 0, 2, "New_Series2");

    // modifying series name
    series.getDataPoints().get_Item(0).getValue().setData(23);
    series.getDataPoints().get_Item(1).getValue().setData(67);
    series.getDataPoints().get_Item(2).getValue().setData(99);

    // Now, Adding a new series
    chart
        .getChartData()
        .getSeries()
        .add(fact.getCell(defaultWorksheetIndex, 0, 3, "Series 3"), chart.getType());

    // Take 3rd chart series
    series = chart.getChartData().getSeries().get_Item(2);

    // Now populating series data
    series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 3, 20));
    series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 3, 50));
    series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 3, 30));

    chart.setType(ChartType.ClusteredCylinder);

    // Save presentation with chart
    pres.save(dataDir + "AsposeChartModified.pptx", SaveFormat.Pptx);
  }
コード例 #4
0
  public static void main(String[] args) throws Exception {
    // The path to the documents directory.
    String dataDir = Utils.getDataDir(ScatteredChart.class);
    Presentation pres = new Presentation();

    ISlide slide = pres.getSlides().get_Item(0);

    // Creating the default chart
    IChart chart = slide.getShapes().addChart(ChartType.ScatterWithSmoothLines, 0, 0, 400, 400);

    // Getting the default chart data worksheet index
    int defaultWorksheetIndex = 0;

    // Getting the chart data worksheet
    IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();

    // Delete demo series
    chart.getChartData().getSeries().clear();

    // Add new series
    chart
        .getChartData()
        .getSeries()
        .add(fact.getCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.getType());
    chart
        .getChartData()
        .getSeries()
        .add(fact.getCell(defaultWorksheetIndex, 1, 3, "Series 2"), chart.getType());

    // Take first chart series
    IChartSeries series = chart.getChartData().getSeries().get_Item(0);

    // Add new point (1:3) there.
    series
        .getDataPoints()
        .addDataPointForScatterSeries(
            fact.getCell(defaultWorksheetIndex, 2, 1, 1),
            fact.getCell(defaultWorksheetIndex, 2, 2, 3));

    // Add new point (2:10)
    series
        .getDataPoints()
        .addDataPointForScatterSeries(
            fact.getCell(defaultWorksheetIndex, 3, 1, 2),
            fact.getCell(defaultWorksheetIndex, 3, 2, 10));

    // Edit the type of series
    series.setType(ChartType.ScatterWithStraightLinesAndMarkers);

    // Changing the chart series marker
    series.getMarker().setSize(10);
    series.getMarker().setSymbol(MarkerStyleType.Star);

    // Take second chart series
    series = chart.getChartData().getSeries().get_Item(1);

    // Add new point (5:2) there.
    series
        .getDataPoints()
        .addDataPointForScatterSeries(
            fact.getCell(defaultWorksheetIndex, 2, 3, 5),
            fact.getCell(defaultWorksheetIndex, 2, 4, 2));

    // Add new point (3:1)
    series
        .getDataPoints()
        .addDataPointForScatterSeries(
            fact.getCell(defaultWorksheetIndex, 3, 3, 3),
            fact.getCell(defaultWorksheetIndex, 3, 4, 1));

    // Add new point (2:2)
    series
        .getDataPoints()
        .addDataPointForScatterSeries(
            fact.getCell(defaultWorksheetIndex, 4, 3, 2),
            fact.getCell(defaultWorksheetIndex, 4, 4, 2));

    // Add new point (5:1)
    series
        .getDataPoints()
        .addDataPointForScatterSeries(
            fact.getCell(defaultWorksheetIndex, 5, 3, 5),
            fact.getCell(defaultWorksheetIndex, 5, 4, 1));

    // Changing the chart series marker
    series.getMarker().setSize(10);
    series.getMarker().setSymbol(MarkerStyleType.Circle);

    pres.save(dataDir + "AsposeScatterChart.pptx", SaveFormat.Pptx);
  }