Docs Menu
Docs Home
/
Atlas Charts
/

Create and Manage Charts Views

On this page

  • Use Cases
  • Create a Charts View from a Collection
  • Example Pipelines
  • Modify a Charts View's Pipeline
  • Disconnect a Charts View
  • Delete a Charts View

If you are the Project Owner, you can create and modify a charts view. A charts view is a data source that applies an 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.

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. See example.

  • Hide fields which may contain sensitive data from Charts users using $project. See example.

  • Convert data types, such as a string field to a date. See example.

1

To learn more, see Connect a Deployment to Charts.

2
  1. 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.

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

3

Charts opens the Add Charts View modal.

4
5

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

6

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 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

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

The following example adds a pipeline to a data source pointing to the sample_mflix.movies collection from the Sample Mflix Dataset provided by Atlas. The pipeline performs a $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.

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

The following example adds a pipeline to a data source pointing to the sample_supplies.sales collection from the Sample Supply Store Dataset provided by Atlas. The pipeline hides the customer.email field, making that field unavailable to charts using this data source:

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

To learn more about the $project aggregation stage, see $project.

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:

[
{
$addFields: {
saleDateAsDate: { $toDate: '$saleDate' }
}
}
]
1

To learn more, see Connect a Deployment to Charts.

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

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

3
4

Tip

See also:

To learn about other settings on this page, see Manage Data Sources.

5
6

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

Charts validates your pipeline when you save your changes.

To disconnect a charts view, see disconnect a data source.

If you are the Project Owner, you can permanently delete a charts view.

To delete a charts view:

1

To learn more, see Connect a Deployment to Charts.

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

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

3
4

On the modal that appears:

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

  2. Click Delete.

Back

Manage Deployments