Building a Custom Filter or Control-Panel Component for Apache Superset

Two different things get called a “Superset custom filter”, and they are built in completely different places.The first is a control: a widget in the Explore control panel that configures a single chart. Metrics, group-by, colour scheme, a threshold slider. Controls belong to the chart plugin and are declared in controlPanel.ts.

The second is a native filter: a widget in the dashboard filter bar that pushes a value into every chart in scope. Select, range, time range, time column. Native filters belong to the dashboard, not to any chart, and are implemented inside the Superset frontend.

There is a third thing that sits between them: a chart that acts as a filter, so that clicking a bar or a region filters the rest of the dashboard. That is cross-filtering, and it is something a plugin can do on its own.

This guide covers all three, in order of how much of Superset you have to touch. Most requirements are satisfied by the first, which needs no changes to Superset at all.

Part 1: Custom controls inside a plugin

A control panel is data, not code: a ControlPanelConfig object listing sections, each with rows of controls. Each control has a type naming a React component that Superset already ships, plus configuration. You can go a long way by composing those components well.

The control types you already have

@superset-ui/chart-controls exposes the components Superset’s own charts use. The ones that cover most needs:

type What it renders Typical use
SelectControl Single or multi select, optionally free-form Pick a column, a mode, an aggregation
TextControl Text or number input Thresholds, labels, limits
TextAreaControl Multi-line text, optional code highlighting Custom SQL, JSON, templates
CheckboxControl Boolean toggle Show legend, stack bars
SliderControl Numeric slider Opacity, radius, bucket count
RadioButtonControl Mutually exclusive options Chart orientation, sort order
ColorPickerControl Single colour Highlight colour
ColorSchemeControl Registered categorical scheme Series colours
BoundsControl Min and max pair Axis bounds
MetricsControl Saved or ad-hoc metrics Any measure
AdhocFilterControl Filter builder Where clauses
CollectionControl Repeating group of sub-controls Multiple thresholds, multiple series

You reference them by string in the type field. The shared, pre-configured versions for metrics, group-by, filters and row limits live in sharedControls; spread one and override the label and description rather than configuring from scratch.

Dynamic visibility

Controls can appear and disappear based on other controls. The visibility function receives the current control state and returns a boolean:

typescript
[
  {
    name: 'threshold_mode',
    config: {
      type: 'RadioButtonControl',
      label: t('Threshold'),
      default: 'none',
      options: [
        ['none', t('None')],
        ['fixed', t('Fixed value')],
        ['percentile', t('Percentile')],
      ],
      renderTrigger: true,
    },
  },
],
[
  {
    name: 'threshold_value',
    config: {
      type: 'TextControl',
      label: t('Threshold value'),
      isFloat: true,
      default: 0,
      renderTrigger: true,
      visibility: ({ controls }) => controls?.threshold_mode?.value === 'fixed',
    },
  },
],
[
  {
    name: 'threshold_percentile',
    config: {
      type: 'SliderControl',
      label: t('Percentile'),
      min: 1,
      max: 99,
      default: 90,
      renderTrigger: true,
      visibility: ({ controls }) => controls?.threshold_mode?.value === 'percentile',
    },
  },
],

This pattern replaces a great deal of what people initially think needs a custom component. A control panel that shows only the relevant options feels bespoke without being bespoke.

Options that depend on the dataset

Controls can derive their options from the dataset and the rest of the form through mapStateToProps. The canonical example is a select whose choices are the dataset’s columns filtered by type:

typescript
{
  name: 'geo_column',
  config: {
    type: 'SelectControl',
    label: t('Geometry column'),
    description: t('A column holding WKT or GeoJSON'),
    mapStateToProps: ({ datasource }) => ({
      choices: (datasource?.columns ?? [])
        .filter(col => /geom|geo|wkt|shape/i.test(col.column_name))
        .map(col => [col.column_name, col.verbose_name || col.column_name]),
    }),
    validators: [validateNonEmpty],
  },
}

mapStateToProps runs whenever the Explore state changes, so keep it cheap.

Validation

validators is an array of functions that take the value and return an error string or nothing. validateNonEmpty, validateInteger and validateNumber are provided; writing your own is one function:

typescript
const validateRange = (value: unknown) => {
  const n = Number(value);
  return n >= 0 && n <= 100 ? false : t('Must be between 0 and 100');
};

Explore shows the error under the control and disables the Update button until it clears. That is a better experience than letting a bad value through and handling it in transformProps.

Repeating groups

CollectionControl renders a list of sub-control groups the user can add to and remove from. It is how you get “add another threshold band” without writing a component. Each item is an object with the sub-control values, and it arrives in transformProps as an array.

If a requirement survives all of the above, you genuinely need a new component, and that means Part 3.

Building this control for more than one dashboard?

A one-off control panel is a weekend project; one that survives Superset upgrades and gets reused across dashboards is not. A Plugin Scoping Call scopes that difference before you commit engineering time.

Book a Plugin Scoping Call

Part 2: Making a chart act as a filter

A chart that filters the dashboard when the user clicks it is the most requested “custom filter” and needs no changes to Superset. It needs three things in the plugin.

First, declare the behaviour in index.ts:

typescript
behaviors: [Behavior.InteractiveChart],

Second, in transformProps, pass through the hooks Superset gives you:

typescript
const { hooks, filterState } = chartProps;
return {
  // ...other props
  setDataMask: hooks.setDataMask,
  selectedValues: filterState?.value ?? [],
  emitCrossFilters: formData.emitCrossFilters ?? false,
};

Third, in the component, call setDataMask when the user selects something, and clear it when they deselect:

typescript
function handleSelect(column: string, value: string | number, currentlySelected: boolean) {
  if (!emitCrossFilters) return;
  if (currentlySelected) {
    setDataMask({ extraFormData: { filters: [] }, filterState: { value: null } });
    return;
  }
  setDataMask({
    extraFormData: {
      filters: [{ col: column, op: 'IN', val: [value] }],
    },
    filterState: { value: [value], selectedValues: [value] },
  });
}

extraFormData.filters is what other charts receive as an additional where clause. filterState.value is what Superset uses to remember the selection, show it in the filter indicator, and hand it back to you as selectedValues so you can highlight the selected element. Set both, always; setting one leaves the dashboard confused.

The emitCrossFilters form-data flag is set by the dashboard’s cross-filter toggle, so respect it. Users expect to be able to turn cross-filtering off per dashboard.

Test this on a dashboard with at least two charts, not in Explore. Cross-filters do not exist outside a dashboard, and the failure modes (stale data in other charts, a selection that will not clear) only appear there.

Part 3: A genuinely new control type or native filter

Sometimes the requirement is a widget Superset does not have: a hierarchical tree picker for an org structure, a map-drawn bounding box, a date range with fiscal-quarter presets, a filter fed by an external service. Superset’s plugin API does not let a chart plugin register new control component types or new native filter types. Both are registries populated inside the Superset frontend, so both require a change to your Superset fork.

That is not a reason to avoid it. It is a reason to do it in a way that keeps the fork thin.

A new control component

  • Put the component in its own package, exactly as you would a chart plugin, so that it is versioned, tested and built independently. It receives value, onChange, and the config fields you declare, and it renders inside Explore’s control frame.
  • In the fork, register it in the control map. In 4.x that map lives in the Explore controls module (superset-frontend/src/explore/components/controls/index.js). One import and one entry:
javascript
import OrgTreeControl from 'superset-control-org-tree';
// ...
const controlMap = {
  // existing controls
  OrgTreeControl,
};
  • Reference it from any plugin by type: 'OrgTreeControl'.

Your fork diff is two lines. When Superset moves the control map, which it does occasionally, the rebase is a two-line conflict.

A new native filter type

Native filters are filter plugins in superset-frontend/src/filters, each with a control panel config, a buildQuery (for filters that need to fetch their own options) and a component that calls setDataMask just like a cross-filtering chart. Start by copying the select filter, which is the most complete example, and register the new plugin in the native filter preset alongside the built-ins.

The component contract is the same setDataMask call from Part 2. A native filter is, in effect, a chart that has no visualisation and lives in the filter bar. If you got a chart filtering the dashboard, you already know how to write one.

Keep the same discipline: the filter code in its own package, the registration in the fork.

When to say no

A new control or filter type is justified when the widget will be used across several charts or dashboards. For a one-off, restructure the requirement: a SelectControl with mapStateToProps and a CollectionControl cover more than people expect, and they upgrade for free.

Frequently Asked Questions

Can I add a custom control to a Superset chart plugin without forking Superset?

Yes, and that is the right default. A plugin’s control panel is built from the control types Superset already ships, and mapStateToProps gives them dataset-aware options, conditional visibility and validation. A separate plugin package survives upgrades; a fork turns every future Superset release into a merge.

How do I make one chart filter another dashboard?

Use cross-filters rather than building anything. A chart emits the clicked value as a filter that other charts on the dashboard respond to, which covers the majority of requests that arrive worded as “can this chart be a filter”. Reach for a custom native filter type only when the interaction genuinely cannot be expressed that way.

When is a genuinely new control type justified?

When the widget will be used across several charts or dashboards. For a one-off, restructure the requirement instead: SelectControl with mapStateToProps and CollectionControl cover more ground than people expect, and they inherit improvements from upstream for free. A bespoke control is a maintenance commitment at every upgrade.

Where does control state live?

In the form data that the control panel produces and buildQuery consumes, which is what makes a control’s value part of the saved chart and of the query it generates. Keeping state there, rather than in component-local state, is what lets a chart be saved, shared, embedded and rendered by the reports worker with the same result.

Build It With Andolasoft

Extending Superset beyond charts and filters follows the same rule of thin forks and separate packages. We wrote about that from a different angle in adding collaboration features to Apache Superset, and the mechanics of the plugin package itself are in the build guide. The wider service is on the Superset plugin development page.

If you are weighing a plugin-only approach against a fork for a specific requirement, that is exactly the question our Plugin Scoping Call answers: free, 45 minutes, and you leave with a written recommendation and estimate. If you would rather describe the requirement first, talk to us.

Superset Plugin Performance: Rendering 100k-Row Datasets Without Freezing the Dashboard

The complaint arrives as “the dashboard is slow”, and the first instinct is to look at the database. Check the query time in Superset’s chart data response and it is often under a second. The other nine seconds are in the browser: parsing the response, transforming it, and drawing a hundred thousand DOM nodes.Custom plugins are especially prone to this because they are written against a sample dataset and shipped before anyone tries them on the real one. (If you have not built one yet, start with how to build a custom chart plugin for Apache Superset; this post assumes that structure.) This post is about finding where the time goes and fixing it, in the order that gives the most improvement for the least rework.

Where the time goes

A chart render in Superset has five stages. Each can be the bottleneck, and the fix for each is different.

Stage Where it runs What makes it slow
Query Database Missing indexes, no aggregation, huge row limits
Transfer Network Large JSON payloads, no compression
Transform Browser, transformProps Per-row work, sorting, string building, repeated parsing
Render Browser, your component SVG node count, layout thrash, re-rendering on every prop
Interaction Browser Tooltips and hover on thousands of elements, cross-filter round trips

Measure before you change anything. Three tools give you the whole picture:

  • Superset’s own timing. Open the chart in Explore, use “View query” and “View as table” to see row counts, and check the network tab for the /api/v1/chart/data response time and size.
  • Chrome Performance panel. Record a dashboard load and look at the flame chart. Long yellow blocks under your plugin’s function names are transform time; long purple and green blocks are layout and paint.
  • React Profiler. Shows how many times your component rendered and why. A chart that renders four times per load is doing four times the work.

Write down the numbers. Ninety per cent of the time one stage dominates, and it is usually transform or render.

Fix 1: Do not fetch what you will not draw

A chart 900 pixels wide cannot display 100,000 distinct points. If the plugin fetches them anyway, every downstream stage pays for it. The right place to fix this is buildQuery, because it is the only stage where the database does the work.

Aggregate. If the chart shows a value per category, group by the category. If it shows a time series, apply a time grain. buildQueryContext does this from the standard controls; make sure the plugin’s controls expose them rather than pulling raw rows.

Limit series, not just rows. For multi-series charts, series_limit and series_limit_metric keep the top N series and drop the tail that nobody can read anyway.

Set a sensible `row_limit`. The default row limit is often far higher than any chart needs. A row limit control with a default matched to the chart’s capacity protects users from themselves.

Use server-side post-processing. Superset’s query object accepts a post_processing list of pandas operations that run on the backend after the query: pivot, aggregate, rolling, resample, cum, contribution, sort, rename, flatten. Rolling averages, pivots for a heatmap, and percentage-of-total calculations belong here, not in transformProps:

typescript
return buildQueryContext(formData, baseQueryObject => [
  {
    ...baseQueryObject,
    post_processing: [
      {
        operation: 'pivot',
        options: {
          index: ['__timestamp'],
          columns: formData.groupby,
          aggregates: { [metricLabel]: { operator: 'mean' } },
        },
      },
      {
        operation: 'rolling',
        options: { rolling_type: 'mean', window: 7, min_periods: 1, columns: { [metricLabel]: metricLabel } },
      },
    ],
  },
]);

The payload that reaches the browser is already in the shape the chart needs. This one change often removes the transform stage entirely.

Fix 2: Keep transformProps cheap and pure

transformProps runs on every render trigger, which means every time the user touches a cosmetic control. Anything expensive in it is paid repeatedly.

  • No per-row string formatting. Format values at draw time for the visible elements, or in the tooltip, not for every row up front.
  • No sorting of large arrays if the query can return them sorted (orderby in buildQuery).
  • No nested loops. Building a lookup map once and indexing into it is O(n); the nested find is O(n²) and 100,000 rows makes that ten billion operations.
  • Return plain data, not React elements. Keep transformProps framework-free so it is cheap to test and impossible to accidentally allocate components in.

A useful guardrail is a unit test that runs transformProps on a 100,000-row fixture and asserts it completes under a threshold. It fails the moment someone adds a quadratic step.

Fix 3: Choose the rendering technology for the data size

This is the change people reach for first, and it is the third most effective, because the first two usually make it unnecessary. When it is necessary, the guidance is simple.

SVG is fine up to a few thousand elements. Each element is a DOM node with layout, style and event handling. Past roughly 5,000 to 10,000 nodes the page becomes sluggish regardless of how well the code is written.

Canvas draws pixels, not nodes, and handles hundreds of thousands of points. ECharts, which Superset’s own charts use, renders to canvas by default. If your plugin wraps ECharts, three options matter for large data:

typescript
series: [{
  type: 'line',
  sampling: 'lttb',      // downsample to the visible pixel width while preserving shape
  large: true,           // enable large-data mode for bar and scatter
  largeThreshold: 2000,
  progressive: 4000,     // render in chunks so the UI stays responsive
  progressiveThreshold: 10000,
  data,
}]

sampling: 'lttb' (largest triangle three buckets) is the single most valuable one for time series: it reduces a 100,000-point line to the number of pixels available without losing peaks and troughs.

WebGL through deck.gl is for the cases canvas cannot handle: millions of points, geospatial layers, 3D. Superset ships deck.gl plugins, and the patrol analytics guide shows the pattern in a real deployment. The cost is complexity and a harder testing story, so reach for it only when the data justifies it.

Applied these and it’s still slow at your row counts?

Some performance ceilings are architectural, not fixable with these seven changes alone. A Plugin Scoping Call looks at your specific dataset shape and rendering approach.

Book a Plugin Scoping Call

Fix 4: Virtualise tables and lists

Table-style plugins are a special case. Users expect to see every row, so aggregation is not an option, but rendering 100,000 table rows as DOM nodes is exactly the SVG problem in a different costume.

The fix is virtualisation: render only the rows in the viewport plus a small buffer, and swap them as the user scrolls. react-window and @tanstack/react-virtual both do this well. Superset’s own table chart also supports server-side pagination, where each page is a separate query; that is the better choice when the dataset is large enough that even transferring it is slow.

Fix 5: Stop re-rendering

The React Profiler often shows a chart rendering several times per dashboard load: once with empty data, once with data, once when the dashboard finishes laying out, once when a filter indicator updates. Each render repeats any work not memoised.

  • Wrap expensive derived values in useMemo keyed on the data reference and the relevant props.
  • Memoise the component with React.memo if its props are stable.
  • For ECharts, call setOption with notMerge: false and update only the series that changed, rather than recreating the instance.
  • Make sure transformProps returns the same object references for unchanged data. A new array on every call defeats memoisation downstream.

Fix 6: Make interaction cheap

Tooltips that recompute on every mouse move, hover highlighting that touches every element, and cross-filter emissions that fire on drag are all ways to make a fast chart feel slow.

  • Throttle hover handlers to animation frames.
  • For canvas charts, use the library’s built-in hit testing rather than your own.
  • Emit cross-filters on click or on the end of a brush, not continuously.

Fix 7: Let long queries run asynchronously

When the database stage genuinely is slow, the dashboard should not freeze waiting for it. Superset’s global async queries feature runs chart queries through Celery workers and lets the browser poll or receive the result over a websocket. The dashboard renders immediately with loading states, and charts fill in as their data arrives. This is a deployment change (GLOBAL_ASYNC_QUERIES feature flag, Redis, Celery workers) rather than a plugin change, but plugin authors should test that their chart handles the loading and error states it produces.

Async queries do not make a slow query fast. They make a slow query stop blocking everything else. Pair them with caching and query tuning, which is a platform question covered in our production operations guide and in the Architecture Review.

A worked order of operations

Faced with a plugin that takes nine seconds on 100,000 rows:

  • Measure. Say the query is 0.8 s, transfer 0.6 s, transform 3.1 s, render 4.2 s.
  • Move aggregation and the rolling calculation into buildQuery with post-processing. Rows drop to 8,000. Transfer is now 0.1 s, transform 0.3 s, render 1.9 s.
  • Switch the SVG line to ECharts canvas with LTTB sampling. Render drops to 0.2 s.
  • Add useMemo around the option object. Renders per load drop from four to one.

Total: under two seconds, and most of it is the database. No WebGL, no virtualisation, no heroics. That is the usual shape of these fixes: the first two steps do most of the work.

Frequently Asked Questions

How many rows can a Superset chart plugin handle before it gets slow?

It depends on what you render with, not on Superset. SVG is comfortable up to a few thousand elements, because each one is a DOM node with layout, style and event handling, and becomes sluggish somewhere past five to ten thousand nodes however well the code is written. Canvas draws pixels rather than nodes and handles hundreds of thousands of points; WebGL through deck.gl goes further again, at the cost of complexity. Match the technology to the expected row count before writing the plugin.

Should aggregation happen in the browser or in the query?

In the query, nearly always. Aggregating by category, applying a time grain, setting a realistic row_limit, and limiting the number of series with series_limit all keep rows from being fetched at all. Rolling averages, pivots and percentage-of-total belong in the query object’s post_processing list, which runs on the backend, rather than in transformProps. The fastest transform is the one that has less data to transform.

Why does my chart render several times on every dashboard load?

Usually because a prop identity changes on each render, so memoisation never holds. The React Profiler shows the render count and the reason. A chart that renders four times per load does four times the transform and paint work, which is why re-render control often buys more than micro-optimising the transform itself.

What should transformProps avoid doing?

Per-row string formatting, sorting large arrays that the query could have returned sorted through orderby, nested loops, and allocating React elements. A nested find inside a loop is O(n squared), which at 100,000 rows is ten billion operations; building a lookup map once and indexing into it is O(n). Keep the function plain-data-in, plain-data-out and it stays cheap and testable.

Build It With Andolasoft

Performance is much cheaper to design in than to retrofit. When we scope a plugin, expected row counts and interaction patterns are part of the conversation, and they decide the rendering approach before any code is written. If you have a chart in mind, or one that has started to struggle, our Plugin Scoping Call is free and 45 minutes, and the written estimate you get afterwards will say which of the approaches above the design needs. Where the bottleneck turns out to be the platform rather than the plugin, that is the territory of a Superset Architecture Review.

If a dashboard in front of real users is freezing and you need to know whether the fix is the plugin, the query or the deployment, talk to us. We will profile a real load and tell you which of the three it is before anyone commits engineering time.