MongoDB Atlas Charts

MongoDB Atlas Charts

1. Atlas Charts Overview

Atlas Charts is MongoDB’s built-in BI and data visualization layer, native to the Atlas platform. No separate cluster, ETL pipeline, or data warehouse needed — it queries Atlas collections directly.

Key characteristics:

When NOT to use:

2. Chart Types

Chart type Best for
Bar / Column Comparing discrete categories
Line Trends over time
Scatter Correlation between two numeric fields
Geo / Map Plotting GeoJSON Point data or country codes
Heatmap Two-dimensional frequency matrix
KPI / Number Single aggregated metric
Table Tabular output with sorting, pagination
Gauge Progress toward a target
Candlestick OHLC financial data

3. Data Sources

4. Aggregation Pipeline in Charts

5. Dashboard Features

6. Embedded Charts

Unauthenticated (public) embedding

Generates a public embed URL. Suitable for public-facing dashboards with non-sensitive data. Always configure a restrictive base filter in embed settings.

Authenticated SDK embedding (@mongodb-js/charts-embed-dom)

Uses the Charts JavaScript SDK. Requires a backend-issued signed JWT.

const chart = sdk.createChart({
  chartId: 'a1b2c3d4-...',
  getUserToken: async () => {
    const res = await fetch('/api/charts-token');
    const { token } = await res.json();
    return token;
  },
});

7. JWT-based Filter Security

CRITICAL: Never pass filter values directly from untrusted client input. Always sign tenant-scoped filters in a backend-issued JWT:

// Backend only — NEVER in browser code
const token = jwt.sign(
  { sub: 'user-123', mongodbFilter: { tenantId: 'acme' } },
  process.env.CHARTS_EMBEDDING_SIGNING_KEY,
  { expiresIn: '30m' }
);

The JWT must be signed with the Embedding Signing Key configured in Charts project settings.

8. Charts API (REST)

Base URL: https://cloud.mongodb.com/api/atlas/v1.0/groups/{groupId}/charts/ Authentication: Atlas programmatic API keys with Digest authentication.

Common operations: list/get/create/delete dashboards, list/get/update chart definitions.

Use cases: CI/CD version control of chart definitions, tenant provisioning (clone template dashboard via API), bulk updates.

9. Access Control

Role Scope Capabilities
Viewer Dashboard View and interact; cannot edit
Author Dashboard or project Create and edit charts/dashboards
Admin Project Manage data sources, embedding keys, user permissions

Atlas project Owners automatically receive Charts Admin.

10. Anti-Patterns

11. Cost Model

12. SDK Quick Reference

Installation: npm install @mongodb-js/charts-embed-dom

SDK initialization checklist:

  1. Configure embedding signing key in Atlas Charts project settings
  2. Build backend endpoint issuing short-lived signed JWTs with mongodbFilter claims
  3. Use getUserToken in SDK — never generate/hardcode signing key client-side
  4. Set maxDataAge for data freshness/cost control
  5. Subscribe to click events for drilldown navigation