> This page location: /docs.md > /docs/development.md > /docs/charts.md > /docs/charts/data-sources.md

> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# Create and Manage Charts Views

If you are the [`Project Owner`](https://docs.atlas.mongodb.com/reference/user-roles/#mongodb-authrole-Project-Owner), you can create and modify a charts view. A charts view is a data source that applies an [aggregation pipeline](https://www.mongodb.com/docs/manual/core/aggregation-pipeline.md#std-label-aggregation-pipeline) to a collection to pre-process data before it is used for Charts. You can create multiple charts views from a single collection.

After you create a charts view, you can select the charts view as a data source when you create a chart.

## Use Cases

Pre-processing a data source with a pipeline is useful when your collection data is not optimized for data visualization.

Pre-processing your data can help accomplish the following tasks:

- Join data from multiple collections into a single data source using [`$lookup`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup.md#mongodb-pipeline-pipe.-lookup). [See example.](https://www.mongodb.com/docs/charts/create-manage-charts-view.md#std-label-join-data)

- Hide fields which may contain sensitive data from Charts users using [`$project`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/project.md#mongodb-pipeline-pipe.-project). [See example.](https://www.mongodb.com/docs/charts/create-manage-charts-view.md#std-label-hide-data)

- Convert data types, such as a string field to a date. [See example.](https://www.mongodb.com/docs/charts/create-manage-charts-view.md#std-label-convert-data-tye)

## Create a Charts View from a Collection

1. Connect your deployment.

   To learn more, see [Connect a Deployment to Charts.](https://www.mongodb.com/docs/charts/manage-deployment.md#std-label-connect-deployment)

2. Select a database and collection.

   In the deployment's Data Access section, click the name of the database that contains the collection to use for the charts view. The collections list appears.

   Click the collection to use for the charts view. Charts also displays any existing charts views that use the collection.

3. Click Charts View next to the collection's information.

   Charts opens the Add Charts View modal.

4. Specify a Name for your charts view.

5. Add an aggregation pipeline.

   Your pipeline must be an array. Specify each stage of your pipeline as an object within the array.

6. (Optional) Click Test Pipeline.

   Atlas Charts validates your pipeline. Charts reports any errors in your pipeline below the editor. If the pipeline is valid, Charts shows a sample document from the results or displays No documents returned.

   **Tip:**

   For help creating your pipeline, you can utilize the [Aggregation Pipeline Builder](https://www.mongodb.com/docs/atlas/data-explorer/cloud-agg-pipeline/) in the Atlas Data Explorer.

   You can create your pipeline using the Atlas pipeline builder and paste it into the Atlas Charts pipeline editor.

7. Click Save.

   After you save the charts view, it displays in the Data Access section for the collection it uses.

## Example Pipelines

### Join Data from Two Collections

The following example adds a pipeline to a data source pointing to the `sample_mflix.movies` collection from the [Sample Mflix Dataset](https://www.mongodb.com/docs/atlas/sample-data/sample-mflix/) provided by Atlas. The pipeline performs a [`$lookup`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup.md#mongodb-pipeline-pipe.-lookup) to join data from the `comments` collection based on `movie_id`. The result is a new field in this data source called `comments` containing data from a separate collection.

```js
[
 {
   $lookup:
     {
       from: 'comments',
       localField: '_id',
       foreignField: 'movie_id',
       as: 'comments'
     }
 }
]
```

### Hide Sensitive Data

The following example adds a pipeline to a data source pointing to the `sample_supplies.sales` collection from the [Sample Supply Store Dataset](https://www.mongodb.com/docs/atlas/sample-data/sample-supplies/) provided by Atlas. The pipeline hides the `customer.email` field, making that field unavailable to charts using this data source:

```js
[
  {
    $project: { "customer.email": 0 }
  }
]
```

To learn more about the `$project` aggregation stage, see [`$project`.](https://www.mongodb.com/docs/manual/reference/operator/aggregation/project.md#mongodb-pipeline-pipe.-project)

### Convert the Type of a Data Field

The following example adds a pipeline to a data source containing a string field that we want to convert to a date. The pipeline adds a new field to the data source with the string field `saleDate` converted to a date field called `saleDateAsDate`:

```js
[
  {
    $addFields: {
      saleDateAsDate: { $toDate: '$saleDate' }
    }
  }
]
```

## Modify a Charts View's Pipeline

1. Connect your deployment.

   To learn more, see [Connect a Deployment to Charts.](https://www.mongodb.com/docs/charts/manage-deployment.md#std-label-connect-deployment)

2. Select the database and collection.

   In the deployment's Data Access section, click the name of the database that contains the collection associated with the charts view.

   Click the name of the collection associated with the charts view. Charts displays information for all existing charts view that use the collection.

3. Click Manage next to the chart view's information.

4. Click Pipeline tab to edit the charts view's pipeline.

   **See also:**

   To learn about other settings on this page, see [Manage Data Sources.](https://www.mongodb.com/docs/charts/manage-data-sources.md#std-label-charts-modify-data-source)

5. Edit the aggregation pipeline.

6. (Optiona) Click Test Pipeline.

   Charts reports any errors in your pipeline next to the editor. If the pipeline is valid, Charts shows a sample document from the results or displays No documents returned.

7. Click Save.

   Charts validates your pipeline when you save your changes.

## Disconnect a Charts View

To disconnect a charts view, see [disconnect a data source.](https://www.mongodb.com/docs/charts/manage-data-sources.md#std-label-disconnect-data-source)

## Delete a Charts View

If you are the [`Project Owner`](https://docs.atlas.mongodb.com/reference/user-roles/#mongodb-authrole-Project-Owner), you can permanently delete a charts view.

To delete a charts view:

1. Connect your deployment.

   To learn more, see [Connect a Deployment to Charts.](https://www.mongodb.com/docs/charts/manage-deployment.md#std-label-connect-deployment)

2. Select the database and collection.

   In the deployment's Data Access section, click the name of the database that contains the collection associated with the charts view.

   Click the name of the collection associated with the charts view. Charts displays information for all existing charts views based upon the collection.

3. Click Manage next to the chart view's information.

4. Click the ellipsis () and click Delete.

   On the modal that appears:

   Click Check for connected charts to learn whether any charts use the charts view as a data source.

   Click Delete.
