# Chart

> Master charts with Aspose.Slides for Node.js via Java: create, format, bind data, and export charts in PPT, PPTX, and ODP with JavaScript examples.

Source: https://docs.aspose.com/slides/nodejs-java/examples/elements/chart/
Updated: 2026-08-05


Examples for adding, accessing, removing, and updating different chart types with **Aspose.Slides for Node.js via Java**. The snippets below demonstrate basic chart operations.

## **Add a Chart**

This method adds a simple area chart to the first slide.

```js
var aspose = aspose || {};
aspose.slides = require("aspose.slides.via.java");

function addChart() {
    let presentation = new aspose.slides.Presentation();
    try {
        let slide = presentation.getSlides().get_Item(0);

        // Add a simple area chart to the first slide.
        let chart = slide.getShapes().addChart(aspose.slides.ChartType.Area, 50, 50, 400, 300);

        presentation.save("chart.pptx", aspose.slides.SaveFormat.Pptx);
    } finally {
        presentation.dispose();
    }
}
```

## **Access a Chart**

After creating a chart, you can retrieve it through the shape collection.

```js
var aspose = aspose || {};
aspose.slides = require("aspose.slides.via.java");
const java = require("java");

function accessChart() {
    let presentation = new aspose.slides.Presentation("chart.pptx");
    try {
        let slide = presentation.getSlides().get_Item(0);

        // Access the first chart on the slide.
        let firstChart = null;
        for (let i = 0; i < slide.getShapes().size(); i++) {
            let shape = slide.getShapes().get_Item(i);
            if (java.instanceOf(shape, "com.aspose.slides.IChart")) {
                firstChart = shape;
                break;
            }
        }
    } finally {
        presentation.dispose();
    }
}
```

## **Remove a Chart**

The following code removes the chart from the slide.

```js
var aspose = aspose || {};
aspose.slides = require("aspose.slides.via.java");

function removeChart() {
    let presentation = new aspose.slides.Presentation("chart.pptx");
    try {
        let slide = presentation.getSlides().get_Item(0);

        // Remove the chart.
        slide.getShapes().removeAt(0);

        presentation.save("chart_removed.pptx", aspose.slides.SaveFormat.Pptx);
    } finally {
        presentation.dispose();
    }
}
```

## **Update Chart Data**

You can change chart properties such as the title.

```js
var aspose = aspose || {};
aspose.slides = require("aspose.slides.via.java");

function updateChartData() {
    let presentation = new aspose.slides.Presentation("chart.pptx");
    try {
        let slide = presentation.getSlides().get_Item(0);
        let chart = slide.getShapes().get_Item(0);

        // Change the chart title. The title must be turned on, otherwise
        // its text is dropped when the presentation is saved.
        chart.setTitle(true);
        chart.getChartTitle().addTextFrameForOverriding("Sales Report");

        presentation.save("chart_title.pptx", aspose.slides.SaveFormat.Pptx);
    } finally {
        presentation.dispose();
    }
}
```



## Related articles

- [Create and Customize PowerPoint Charts in JavaScript](https://docs.aspose.com/slides/nodejs-java/powerpoint-charts/)
- [Note](https://docs.aspose.com/slides/nodejs-java/examples/elements/note/)
- [Examples](https://docs.aspose.com/slides/nodejs-java/examples/)