fix a bit time logic and refresh of the graph

This commit is contained in:
Vasily.onl
2025-06-06 11:59:44 +08:00
parent 87843a1d35
commit 74b83d77fc
2 changed files with 34 additions and 2 deletions

View File

@@ -103,6 +103,11 @@ def register_chart_callbacks(app):
triggered_id = ctx.triggered_id
logger.debug(f"Update_price_chart triggered by: {triggered_id}")
# If the update is from the interval and the chart is locked, do nothing.
if triggered_id == 'interval-component' and analysis_mode == 'locked':
logger.debug("Analysis mode is 'locked'. Skipping interval-based chart update.")
return no_update, no_update
days_back, status_message = calculate_time_range(
time_range_quick, custom_start_date, custom_end_date, analysis_mode, n_intervals
)
@@ -208,6 +213,21 @@ def register_chart_callbacks(app):
error_status = f"❌ Error: {str(e)}"
return error_fig, error_status
@app.callback(
Output('analysis-mode-toggle', 'value'),
Input('price-chart', 'relayoutData'),
State('analysis-mode-toggle', 'value'),
prevent_initial_call=True
)
def auto_lock_chart_on_interaction(relayout_data, current_mode):
"""Automatically switch to 'locked' mode when the user zooms or pans."""
# relayout_data is triggered by zoom/pan actions.
if relayout_data and 'xaxis.range' in relayout_data:
if current_mode != 'locked':
logger.debug("User chart interaction detected (zoom/pan). Switching to 'locked' analysis mode.")
return 'locked'
return no_update
# Strategy selection callback - automatically load strategy indicators
@app.callback(
[Output('overlay-indicators-checklist', 'value'),