TCPDashboard/dashboard/callbacks/data_analysis.py

49 lines
2.0 KiB
Python

"""
Data analysis callbacks for the dashboard.
"""
from dash import Output, Input, html, dcc
import dash_bootstrap_components as dbc
from utils.logger import get_logger
from dashboard.components.data_analysis import (
VolumeAnalyzer,
PriceMovementAnalyzer,
create_volume_analysis_chart,
create_price_movement_chart,
create_volume_stats_display,
create_price_stats_display
)
logger = get_logger("data_analysis_callbacks")
def register_data_analysis_callbacks(app):
"""Register data analysis related callbacks."""
logger.info("🚀 STARTING to register data analysis callbacks...")
# Initial callback to populate charts on load
@app.callback(
[Output('analysis-chart-container', 'children'),
Output('analysis-stats-container', 'children')],
[Input('analysis-type-selector', 'value'),
Input('analysis-period-selector', 'value')],
prevent_initial_call=False
)
def update_data_analysis(analysis_type, period):
"""Update data analysis with statistical cards only (no duplicate charts)."""
logger.info(f"🎯 DATA ANALYSIS CALLBACK TRIGGERED! Type: {analysis_type}, Period: {period}")
# Return placeholder message since we're moving to enhanced market stats
info_msg = dbc.Alert([
html.H4("📊 Statistical Analysis", className="alert-heading"),
html.P("Data analysis has been integrated into the Market Statistics section above."),
html.P("The enhanced statistics now include volume analysis, price movement analysis, and trend indicators."),
html.P("Change the symbol and timeframe in the main chart to see updated analysis."),
html.Hr(),
html.P("This section will be updated with additional analytical tools in future versions.", className="mb-0")
], color="info")
return info_msg, html.Div()
logger.info("✅ Data analysis callbacks registered successfully")