Introduction
Apache Superset provides powerful filtering options to enhance data visualization and user experience. This document explains how to use native filters and prefilters in dashboards, how to integrate filtered dashboards into web applications, and how to manage permissions to restrict users from editing charts.
Prerequisites
- Apache Superset installed and configured.
- Administrator credentials for Apache Superset.
- A dashboard with filters configured.
- A web application if the dashboard needs to be embedded.
- Access to Superset role and permission settings.
Implementation
Filter Options in Apache Superset
Apache Superset provides two primary methods to filter data in dashboards:
1. Prefilter
- Prefiltering allows predefined filtering on the dashboard before the user interacts with it.
- Useful for restricting data visibility based on user roles or predefined criteria.
2. Native Filter
- Native filters provide an interactive filtering experience for users directly in the dashboard.
- They allow dynamic data filtering based on selected criteria.
A sample Filter-ID and Token are provided below:
- Filter ID:
NATIVE_FILTER-xxxxxxxxxxxxxx1 - Token:
43Tbxxxxxx890RT
Using these, you can filter data in a dashboard URL as follows:
https://localhost:5000/superset/dashboard/b669334e-7948-4fb5-80eb-6f4eac6d86bc/?permalink_key=pAzJAb0Mg3K&standalone=1&native_filters=(${filterId}:((__cache:(label:'${token}',validateStatus:!f,value:!('${token}')),extraFormData:(filters:!((col:token,op:IN,val:!('${token}'))),apply:!t),filterState:(label:'${token}',validateStatus:!f,value:!('${token}')),id:${filterId},ownState:()))&random=${Math.random()}
This URL can be used to pass the selected filter value to the dashboard.
Embedding Apache Superset Dashboards in Web Applications
To integrate an Apache Superset dashboard into a web application, use an iframe as follows:
https://localhost:5000/superset/dashboard/b669334e-7948-4fb5-80eb-6f4eac6d86bc/?standalone=1
This will display the dashboard within your application. However, users may see an Edit Chart option when clicking the three dots on a chart. This allows direct access to Apache Superset without requiring login credentials.
To restrict this permission, follow the steps below:
Restricting the “Edit Chart” Permission
Step 1: Log in to Apache Superset
Log in using your administrator credentials.
Step 2: Navigate to Role Management
- Click on Settings → List Roles.
- Locate the public role (or the role assigned to embedded dashboard users).
Step 3: Modify Permissions
- Click Edit on the Public role.
- Look for the permission “Can explore on Superset“.
- Remove this permission and save the role.
Step 4: Validate Changes
- Open your embedded dashboard again.
- The Edit Chart option should now be removed.
Conclusion
Apache Superset provides flexible options for filtering dashboard data and embedding dashboards into web applications. Prefilters and native filters can be used to control and dynamically filter dashboard data.
When dashboards are embedded into external applications, managing user permissions is also important. Removing the Can explore on Superset permission from the appropriate role can restrict users from accessing the chart editing functionality.
FAQs
1. What are native filters in Apache Superset?
Native filters provide an interactive way for users to filter dashboard data based on selected criteria.
2. What is the purpose of prefiltering?
Prefiltering allows predefined filters to be applied to a dashboard before users interact with it. It can be useful for restricting data based on predefined conditions.
3. Why does the Edit Chart option appear in an embedded dashboard?
The Edit Chart option can appear when the user or role has the required Superset permissions, such as Can explore on Superset.
4. How can I remove the Edit Chart option?
Log in as an administrator, navigate to Settings → List Roles, edit the relevant role, remove Can explore on Superset, and save the changes.
5. Can an Apache Superset dashboard be embedded into another website?
Yes. A Superset dashboard can be displayed inside a web application using an iframe or other supported embedding methods.
Related Articles
Install Apache Superset on Ubuntu via Docker Compose
Learn how to install and configure Apache Superset on Ubuntu using Docker Compose.
How to Install Apache Superset on Ubuntu via Docker Compose
Embed Superset Dashboard with Authentication and RLS
Learn how to embed an Apache Superset dashboard into a private website while implementing authentication and Row-Level Security (RLS).
Embedding Superset Dashboard into a Private Website with Authentication and RLS
Talk to our experts
Looking for the right technology solution for your business? Our team of experts can help you with development, cloud, DevOps, design, and a wide range of other technology needs. Get in touch with our team here.