superset icon indicating copy to clipboard operation
superset copied to clipboard

Filters as a native dashboard (v2) construct

Open mistercrunch opened this issue 8 years ago • 37 comments

Making a list of ideas around how dashboard filters should work in dashboard v2.

Scope awareness. The filter affect only the charts and elements in its scope. Existing scopes should include:

  • global (above tab-line)
  • tab
  • section
  • more granular?

Maybe hovering the filter highlights the charts affected by the filter.

Per-filter configuration:

  • type: select - radio - ? (radio probably not critical / MVP)
  • multiple or single select
  • sort order (based on metric / reverse / alphabetical)
  • limit?
  • show background bar (histogram)
  • cascading-options (wether higher level filter should affect the values in the dropdown), maybe a whitelist blacklist approach?

Making it clear on charts that are filtered, maybe a filter icon that highlight which control are affecting the chart when hovered?

More input is welcomed.

mistercrunch avatar Jun 22 '18 05:06 mistercrunch

Jinja templating filters, i.e. changes in the filter affect values in the template params. We currently have a few use cases where templates seem like a good solution for producing many related but still slightly different charts while using fewer data sources (currently working on a feature to enable overriding the datasource template params in the chart). This would probably need some sort of schema to be able to generate the filter, so probably not something for MVP, but potentially down the road.

villebro avatar Jun 22 '18 07:06 villebro

Some additional ideas on this:

  • Any chance for Filtered MultiSelect with Selections like this: http://insin.github.io/react-filtered-multiselect/. This would be great when you have larger lists and can easily search on selected (right) and unselected (left). Not sure if this is a different viz or can be incorporated to existing viz

  • Default Capabilities at filter level? First/Last Value by whatever Sort Order (Metric, Alphabetical).

Would any of these be viable?

ahsanshah avatar Jun 22 '18 15:06 ahsanshah

Has single select in Table view functioning as a “filter on” action been given any further thought? Similar to Tableau in some ways

fordhamedu avatar Jun 24 '18 04:06 fordhamedu

@fordhamedu there's clearly a need for better constructs around visualizations being able to post filter actions to the dashboard (like the Table viz can currently do). Not sure how those should be scoped (should it affect the whole dashbaord? the section? the tab?)

Maybe really good dashboard-native filtering removes some of the need for that.

mistercrunch avatar Jun 28 '18 17:06 mistercrunch

@fordhamedu there's clearly a need for better constructs around visualizations being able to post filter actions to the dashboard (like the Table viz can currently do). Not sure how those should be scoped (should it affect the whole dashbaord? the section? the tab?)

Maybe really good dashboard-native filtering removes some of the need for that.

mistercrunch avatar Jun 28 '18 17:06 mistercrunch

On-the-fly grouping. I often find that my filters affect how I want to group my charts. If, for instance I filter by region I might want to se a chart grouped by product, but if I then change my filter to product, I want to see that same chart grouped by region. Etc. So having a groupby element which can be made to affect specific charts would be very valuable.

villebro avatar Jun 30 '18 06:06 villebro

the process of “select then deselect then select another” to isolate and explore the connected data in multiple charts within one dashboard can be counterintuitive to most users. Especially within longer tables it’s an easy oversight to forget the last deselect, and then confusing the data that’s displayed. A optional single select and optional filter on would enable a user to easily switch between aggregate and isolated selections and passing variables through markdown, iframe, and any url Parmaters On a single Dashboard. That would be awesome

fordhamedu avatar Jun 30 '18 08:06 fordhamedu

In addition to showing background bar (histogram), would it be helpful to include statistics (e.g. % count, raw count) for each value? This way the user can get an accurate measure which may not be apparent from histogram? Or maybe the stats show up when you hover over the histogram bar.

JamshedRahman avatar Jul 02 '18 22:07 JamshedRahman

We have some work in progress that would enable context-aware filtering for multiple filter boxes in dashboard / explore view. I feel that could be useful here. Adding @emlittleworth

JamshedRahman avatar Jul 02 '18 22:07 JamshedRahman

Hey everyone, as @JamshedRahman mentioned at Twitter we have work in progress for cascading (or context-aware) filtering.

Another project we have coming up that is relevant here is cross-filtering. We brought this up at the Superset meeting on 6/29. We haven't yet decided on design but are hoping it'd have similar functionality to this example: https://dc-js.github.io/dc.js/. For example, when you select "Loss" in the "Days by Gain/Loss" chart, the other charts filter using that value as well.

emlittleworth avatar Jul 03 '18 19:07 emlittleworth

@emlittleworth curious whether you're thinking client-side cross filtering or more of a "filter events emitted from within charts"?

The first one would require massive changes, I doubt whether it's actually reasonable or even possible to do this.

The second is totally doable, and the Table visualization can actually do this today if you turn on the feature.

mistercrunch avatar Jul 04 '18 21:07 mistercrunch

Definitely filter events emitted from within charts. This seems reasonable since we already have a notion of dashboard filters through the filter box. This feature would enable other visualizations to trigger dashboard-wide filtering. Thanks, I'll have to look into the Table visualization.

emlittleworth avatar Jul 05 '18 14:07 emlittleworth

Here's how it's done in the Table visualization: https://github.com/apache/incubator-superset/blob/master/superset/assets/src/visualizations/table.js#L155-L159

It's more or less just a matter of hooking filter events up in other visualizations, though it's a bit more complicated than that. Beyond emitting the filtering event, it'd be nice to have visual components (tooltip, context menu, ...) that would make it clear what is about to happen when you click and present multiple options where necessary. While the table component knows about the dimensional context (we know one cell correspond to a single dimension value) it's easier there. A single bar in a bar chart may represent 2 dimension members and may have to emit 2 filters.

mistercrunch avatar Jul 05 '18 14:07 mistercrunch

Oh yeah good point about multiple dimensions. And I agree about the visual components as well. Another thing to keep in mind there is how we should display charts that cannot be filtered because they don't contain the filter dimension.

emlittleworth avatar Jul 05 '18 15:07 emlittleworth

Ideally the dashboard app should make it very clear which filters are active and which charts they affect. Maybe hovering an active filter components would highlight the targets, or hovering a filtered chart would highlight the related "source" filters.

mistercrunch avatar Jul 06 '18 14:07 mistercrunch

Yeah that sounds good. Can you elaborate your thinking on cascading filters? What do you mean by "maybe a whitelist blacklist approach"?

emlittleworth avatar Jul 10 '18 15:07 emlittleworth

@mistercrunch

We would like to add a proposal for the native dashboard filter as outlined in the first post. We are looking for feedback and approval before implementing.

Dashboard changes

  • Global filters will be the focus of the MVP
    • Tab and section filters would work similarly but will not be included in the initial implementation. The initial focus will be to replace the existing Filter Box chart with a native, global dashboard filter
  • The filter component is drag & drop from the insert panel, similar to tabs
    • Global filters go above dashboard-level tabs and below the dashboard title (see images below for an example)
    • Tab filters go below tabs
    • Section filters go at the top of the section
  • New filters can be added when the dashboard is in "Edit Mode" via a button that appears after the list of filters
    • Individual filters are added based on datasource / column name
    • Clicking the New Filter button will open a modal with "Data Source" and "Column" options to select the filter column
    • If the column selected is a time column, the 'Since' / 'Until' filters will be added
  • Filter controls for the dashboard are initially collapsed and can be expanded / collapsed as needed (see images below for an example)
  • Additional options such as timegrain and instant filtering are added via the configuration cog

Chart changes

  • Filter box will be removed as a chart type
  • Filter boxes that are currently included in dashboards will need to be removed from the dashboard and options will be added as global filter options
  • All existing filter box charts are deleted (not sure what else can be done with them since they can't be added to dashboards anymore)

URL changes

  • The preselect_filters query parameter can still be used to fill in filters via a link. It is currently a map which includes the Filter Box ID. The format will need to change into a map of column name to arrays instead
    • Old format
    {
        "414": {
            "column1": [
                "value1",
                "value2"
            ]
        },
        "12": {
            "column2": [
                "value3"
            ]
        }
    }
    
    • New format
    {
      "column1": [
          "value1",
           "value2"
      ],
      "column2": [
          "value3"
      ]
    }
    
    • This change can be made backwards compatible by collecting the filters in the old format, ignoring the ID, and applying the filter values based on the column name

Dashboard mockups

Collapsed filters

global filter closed

Opened filters

global filter open

New filter dialog

filters opened edit edit filter

jaylindquist avatar Aug 08 '18 12:08 jaylindquist

hi @jaylindquist i like your proposal. Can we have a more generic time range filter, which is used for setting time range for charts in scope (global, single tab level or single section)? It doesn't associated with any datasource, but when apply this time filter to each chart, probably need some smart way to bind to the right column of different chart.

graceguo-supercat avatar Aug 09 '18 20:08 graceguo-supercat

@graceguo-supercat Today superset has a "Time Column" for filters that it uses to manage which column to filter on.

I'm not sure how a generic time filter would work. For instance, a table of events that have a start_date column and end_date column. If a user wanted to filter on all events starting in January, they wouldn't want the filter to apply to the end_date column as well.

They would need to specify which column(s) the time range should apply to.

jaylindquist avatar Aug 10 '18 15:08 jaylindquist

@mistercrunch @graceguo-supercat Just pinging to see if there is any other feedback before we start planning our implementation

jaylindquist avatar Aug 13 '18 14:08 jaylindquist