How to Add a Spider Chart to Presentation Using Aspose.Slides for Java?

sample_spiderChart.png (21.7 KB)

Please let me know how to create spider chart .I have uploaded sample file.

Thanks in advance.

@Ramya_D,
Welcome to our community! Thank you for posting the query.

The simple code example below shows you how to create a Radar (Spider) chart.

var presentation = new Presentation();
var slide = presentation.getSlides().get_Item(0);

slide.getShapes().addChart(ChartType.Radar, 20, 20, 400, 300);

presentation.save(folderPath + "example.pptx", SaveFormat.Pptx);
presentation.dispose();

Documents: PowerPoint Charts
API Reference: ChartType Class

Thank you for your response.

I have to create spider chart like sample slide attached in this query.

Thanks in advance

@Ramya_D,
The following code example generates a similar chart.

Presentation presentation = new Presentation();
try
{
    // Access first slide
    ISlide slide = presentation.getSlides().get_Item(0);

    // Add Radar chart
    IChart chart = slide.getShapes().addChart(ChartType.Radar, 0, 0, 400, 480);

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

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

    // Set chart title
    chart.getChartTitle().addTextFrameForOverriding("Spider Chart");

    // Delete default generated series and categories
    chart.getChartData().getCategories().clear();
    chart.getChartData().getSeries().clear();

    // Adding new categories
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 1, 0, "Text 1"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 2, 0, "Text 2"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 3, 0, "Text 3"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 4, 0, "Text 4"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 5, 0, "Text 5"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 6, 0, "Text 6"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 7, 0, "Text 7"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 8, 0, "Text 8"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 9, 0, "Text 9"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 10, 0, "Text 10"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 11, 0, "Text 11"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 12, 0, "Text 12"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 13, 0, "Text 13"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 14, 0, "Text 14"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 15, 0, "Text 15"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 16, 0, "Text 16"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 17, 0, "Text 17"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 18, 0, "Text 18"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 19, 0, "Text 19"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 20, 0, "Text 20"));
    chart.getChartData().getCategories().add(workbook.getCell(defaultWorksheetIndex, 21, 0, "Text 21"));

    // Adding new series
    chart.getChartData().getSeries().add(workbook.getCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.getType());

    // Now populating series data
    IChartSeries series = chart.getChartData().getSeries().get_Item(0);
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 1, 1, 2.7));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 2, 1, 2.4));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 3, 1, 1.5));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 4, 1, 3.5));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 5, 1, 5));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 6, 1, 3.5));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 7, 1, 2));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 8, 1, 4));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 9, 1, 4.2));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 10, 1, 1.2));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 11, 1, 3.8));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 12, 1, 2.5));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 13, 1, 5));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 14, 1, 4.5));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 15, 1, 1));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 16, 1, 1.5));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 17, 1, 2.5));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 18, 1, 3.5));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 19, 1, 1.5));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 20, 1, 4.5));
    series.getDataPoints().addDataPointForRadarSeries(workbook.getCell(defaultWorksheetIndex, 21, 1, 2.5));

    // Set series color
    series.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
    series.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.BLUE);

    // Set legend position
    chart.setLegend(false);
    //chart.getLegend().setPosition(LegendPositionType.Bottom);

    // Setting Category Axis Text Properties
    IChartPortionFormat txtCat = chart.getAxes().getHorizontalAxis().getTextFormat().getPortionFormat();
    txtCat.setFontBold(NullableBool.True);
    txtCat.setFontHeight(10);
    txtCat.getFillFormat().setFillType(FillType.Solid);
    txtCat.getFillFormat().getSolidFillColor().setColor(new Color(PresetColor.DimGray));
    txtCat.setLatinFont(new FontData("Calibri"));

    // Setting Legends Text Properties
    IChartPortionFormat txtleg = chart.getLegend().getTextFormat().getPortionFormat();
    txtleg.setFontBold(NullableBool.True);
    txtleg.setFontHeight(10);
    txtleg.getFillFormat().setFillType(FillType.Solid);
    txtleg.getFillFormat().getSolidFillColor().setColor(new Color(0x000028));
    txtCat.setLatinFont(new FontData("Calibri"));

    // Setting Value Axis Text Properties
    IChartPortionFormat txtVal = chart.getAxes().getVerticalAxis().getTextFormat().getPortionFormat();
    txtVal.setFontBold(NullableBool.True);
    txtVal.setFontHeight(10);
    txtVal.getFillFormat().setFillType(FillType.Solid);
    txtVal.getFillFormat().getSolidFillColor().setColor(new Color(PresetColor.DimGray));
    txtVal.setLatinFont(new FontData("Calibri"));

    // Setting value axis number format
    chart.getAxes().getVerticalAxis().setNumberFormatLinkedToSource(false);
    //chart.getAxes().getVerticalAxis().setNumberFormat("\"$\"#,##0.00");

    // Setting chart major unit value
    chart.getAxes().getVerticalAxis().setAutomaticMajorUnit(false);
    chart.getAxes().getVerticalAxis().setMajorUnit(1.25f);

    // Save generated presentation
    presentation.save(folderPath + "example.pptx", SaveFormat.Pptx);
}
finally
{
    if (presentation != null) presentation.dispose();
}

Result: example.zip (33.6 KB)

1 Like

Thank you Team

Hi Team

Please let me know is it possible to remove white space from PNG image.

Thanks in advance

@Ramya_D,
Unfortunately, I don’t have enough information to help you. Please share the following:

  • input presentation file
  • code example generating the image
  • srcreenshot with the problem

A post was split to a new topic: Is it possible to remove white space from PNG image?

@Ramya_D,
Your requirements are related to Aspose.Words product. I have moved them to Aspose.Words forum. Our support team will help you properly there.