apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
60.84k stars 13.17k forks source link

Dashboard-level filters are not applying to charts (that are in-scope) #29519

Open clavidk opened 2 weeks ago

clavidk commented 2 weeks ago

Bug description

In mixed charts, query B does not seem to inherit default dashboard-level filters sometimes...

How to reproduce the bug

Hard to reproduce consistently but:

  1. Create a mixed chart with 2 queries, and a primary AND secondary Y-axis.
  2. Primary chart should be a line chart, secondary chart should be a bar chart.
  3. Create a dashboard-level date filter with a default value that is from 2023-11-01 to Now.
  4. Refresh dashboard
  5. Repeat steps 1&2
  6. Refresh dashboard
  7. Notice that query B is not filtered to the default dashboard-level date filter.
  8. Go into edit the chart and notice that query A has automatically added the dashboard-level filter in its filter section: image

However, query B does not seem to have inherited the dashboard level filter. image

What I expect: All charts are filtered to date ranges from 2023-11-01 to Now. All queries in mixed chart have inherited the dashboard-level filters into its filter section.

What I see: My chart I created after my dashboard filter shows all date ranges (not filtered)

Screenshots/recordings

See above

Superset version

master / latest-dev

Python version

I don't know

Node version

I don't know

Browser

Chrome

Additional context

No response

Checklist

dosubot[bot] commented 2 weeks ago

Hey @clavidk,

I'm here to help you with your Superset issue. I'm a bot designed to assist you with bugs, questions, and contributions while you wait for a human maintainer. Let's tackle this together!

The issue you're experiencing with dashboard-level filters not applying to some mixed charts (combo line + bar charts with a primary and secondary y-axis) is likely due to the adhoc_filters and adhoc_filters_b parameters having a comparator set to "No filter". This configuration means that the chart is not set up to apply any date range filter by default.

To resolve this, ensure that the comparator values in both adhoc_filters and adhoc_filters_b are set to accept the date range filter from the dashboard. Here is an example configuration:

adhoc_filters:
  - clause: WHERE
    subject: order_date
    operator: TEMPORAL_RANGE
    comparator: No filter
    expressionType: SIMPLE

adhoc_filters_b:
  - clause: WHERE
    subject: order_date
    operator: TEMPORAL_RANGE
    comparator: No filter
    expressionType: SIMPLE

Additionally, the transformProps function in the superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts file handles the transformation of chart properties, including the application of filters. Ensuring that the filterState and queriesData are correctly processed in this function can help in applying the dashboard-level date range filter to mixed charts [[1]](https://github.com/apache/superset/blob/master/superset/examples/configs/charts/Featured Charts/Mixed.yaml)[2].

If the issue persists, you might want to check for any recent updates or changes in the Superset codebase that address the application of dashboard-level filters to mixed charts. Recent updates have improved the dashboard native filter feature, which provides a way to apply and manipulate filters over many charts at the dashboard level, including mixed charts [3][4][5][6].

To continue talking to Dosu, mention @dosu.

clavidk commented 1 week ago

Ah edit: it seems like query B is not inheriting the dashboard level filters: image Query B ^ date filter says no filter

Whereas Query A inherits the dashboard filter: image