diff --git a/dtale/dash_application/layout/layout.py b/dtale/dash_application/layout/layout.py index 3d8d4389..b23aabd3 100644 --- a/dtale/dash_application/layout/layout.py +++ b/dtale/dash_application/layout/layout.py @@ -1709,27 +1709,31 @@ def show_map_style(show): ), className="row pt-3 pb-3 charts-filters", ), - html.Div( + ( html.Div( - [ - html.Div( - [ - query_label, - dcc.Input( - id="query-input", - type="text", - placeholder=query_placeholder, - className="form-control", - value=query_value, - style={"lineHeight": "inherit"}, - ), - ], - className="input-group mr-3", - ) - ], - className="col", - ), - className="row pt-3 pb-3 charts-filters", + html.Div( + [ + html.Div( + [ + query_label, + dcc.Input( + id="query-input", + type="text", + placeholder=query_placeholder, + className="form-control", + value=query_value, + style={"lineHeight": "inherit"}, + ), + ], + className="input-group mr-3", + ) + ], + className="col", + ), + className="row pt-3 pb-3 charts-filters", + ) + if global_state.load_flag(inputs["data_id"], "enable_custom_filters", False) + else None ), html.Div( html.Div( diff --git a/dtale/views.py b/dtale/views.py index c0dc4969..4acfc984 100644 --- a/dtale/views.py +++ b/dtale/views.py @@ -3380,9 +3380,12 @@ def get_chart_data(data_id): max: maxY, } or {error: 'Exception message', traceback: 'Exception stacktrace'} """ + custom_query = None + if global_state.load_flag(data_id, "enable_custom_filters", False): + custom_query = get_str_arg(request, "query") data = run_query( handle_predefined(data_id), - build_query(data_id, get_str_arg(request, "query")), + build_query(data_id, custom_query), global_state.get_context_variables(data_id), ) x = get_str_arg(request, "x") diff --git a/tests/dtale/test_views.py b/tests/dtale/test_views.py index 2cc9d4d4..6154bfa5 100644 --- a/tests/dtale/test_views.py +++ b/tests/dtale/test_views.py @@ -1975,6 +1975,7 @@ def test_get_chart_data(unittest, rolling_data): with app.test_client() as c: build_data_inst({c.port: test_data}) + global_state.set_app_settings(dict(enable_custom_filters=True)) response = c.get( "/dtale/chart-data/{}".format(c.port), query_string=dict(query="missing_col == 'blah'"), @@ -1997,6 +1998,7 @@ def test_get_chart_data(unittest, rolling_data): response_data["error"], 'query "security_id == 51" found no data, please alter', ) + global_state.set_app_settings(dict(enable_custom_filters=False)) df = pd.DataFrame([dict(a=i, b=np.nan) for i in range(100)]) df, _ = views.format_data(df)